Ox.localStorage: fix chaining, add tests
This commit is contained in:
parent
d2322388dc
commit
37ee99f884
1 changed files with 10 additions and 6 deletions
|
@ -142,6 +142,13 @@ Ox.localStorage <f> localStorage wrapper
|
|||
(key) -> <*> returns one value
|
||||
(key, val) -> <f> sets one value, returns localStorage object
|
||||
({key: val, ...}) -> <f> sets values, returns localStorage object
|
||||
<script>
|
||||
Ox.test.localStorage = Ox.localStorage('test');
|
||||
</script>
|
||||
> Ox.test.localStorage({foo: 'bar'})('foo')
|
||||
'bar'
|
||||
> Ox.test.localStorage.delete('foo')()
|
||||
{}
|
||||
@*/
|
||||
Ox.localStorage = function(namespace) {
|
||||
if (!window.localStorage) {
|
||||
|
@ -164,7 +171,7 @@ Ox.localStorage = function(namespace) {
|
|||
Ox.forEach(Ox.makeObject(arguments), function(value, key) {
|
||||
localStorage[namespace + '.' + key] = JSON.stringify(value);
|
||||
});
|
||||
ret = this;
|
||||
ret = storage;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
@ -175,8 +182,6 @@ Ox.localStorage = function(namespace) {
|
|||
keys.forEach(function(key) {
|
||||
delete localStorage[namespace + '.' + key];
|
||||
});
|
||||
var keys =
|
||||
keys
|
||||
return storage;
|
||||
};
|
||||
return storage;
|
||||
|
@ -257,7 +262,7 @@ Ox.loop <f> For-loop, functional-style
|
|||
step <n> Step value
|
||||
fn <f> Iterator function
|
||||
i <n> Counter value
|
||||
> Ox.loop(10, function(i) { i == 4 && Ox.Break() })
|
||||
> Ox.loop(10, function(i) { i == 4 && Ox.Break(); })
|
||||
4
|
||||
> Ox.loop(0, 3, 2, function() {})
|
||||
4
|
||||
|
@ -295,8 +300,7 @@ Ox.print <f> Prints its arguments to the console
|
|||
"foo"
|
||||
@*/
|
||||
Ox.print = function() {
|
||||
var args = Ox.toArray(arguments),
|
||||
date = new Date();
|
||||
var args = Ox.toArray(arguments), date = new Date();
|
||||
args.unshift(
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().slice(-3)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue