Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yaxel Perez
jio
Commits
d21cdad4
Commit
d21cdad4
authored
Feb 12, 2019
by
Yaxel Perez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
aa84a60b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
src/jio.storage/liststorage.js
src/jio.storage/liststorage.js
+49
-0
test/jio.storage/liststorage.tests.js
test/jio.storage/liststorage.tests.js
+38
-0
No files found.
src/jio.storage/liststorage.js
0 → 100644
View file @
d21cdad4
/*global define, jIO */
/*jslint nomen: true*/
(
function
(
jIO
)
{
"
use strict
"
;
function
randomId
()
{
// https://gist.github.com/gordonbrander/2230317
return
'
_
'
+
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
);
}
function
ListStorage
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
this
.
_signature_storage
=
jIO
.
createJIO
({
"
type
"
:
"
indexeddb
"
,
"
database
"
:
randomId
()
});
this
.
_signature_storage
.
post
(
"
_
"
,
{
list
:
[]
});
}
ListStorage
.
prototype
.
post
=
function
()
{
console
.
log
(
'
alright alright alright alright alright ok now ladies
'
);
var
id
=
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
),
updated_list
=
this
.
_signature_storage
.
get
(
"
_
"
).
list
.
concat
(
id
);
this
.
_signature_storage
.
put
(
"
_
"
,
{
list
:
updated_list
});
};
ListStorage
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
ListStorage
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
ListStorage
.
prototype
.
remove
=
function
(
id
)
{
var
updated_list
=
this
.
_signature_storage
.
get
(
"
_
"
)
.
list
.
filter
(
function
(
x
)
{
return
x
!==
id
;
});
this
.
_signature_storage
.
put
(
"
_
"
,
{
list
:
updated_list
});
};
ListStorage
.
prototype
.
list
=
function
()
{
return
this
.
_sub_storage
.
get
(
"
_
"
).
list
;
};
jIO
.
addStorage
(
"
list
"
,
ListStorage
);
}(
jIO
));
test/jio.storage/liststorage.tests.js
0 → 100644
View file @
d21cdad4
(
function
(
jIO
,
RSVP
,
QUnit
)
{
"
use strict
"
;
QUnit
.
module
(
"
ListStorage
"
);
QUnit
.
test
(
'
Constructor does not crash
'
,
function
()
{
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
memory
"
}
});
QUnit
.
expect
(
0
);
});
// line is too long (>80) if I don't do this weird indenting
QUnit
.
test
(
"
Storage list method returns ordered list of ids
"
,
function
(
assert
)
{
var
storage
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
,
}
}
}),
ids
=
RSVP
.
all
([
storage
.
post
(),
storage
.
post
(),
storage
.
post
()]);
ids
.
then
(
function
(
values
)
{
});
}
);
}(
jIO
,
RSVP
,
QUnit
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment