Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More improvements

  • Loading branch information...
commit 6ef06e09c0fc479e96615ef394c74514aa821e1e 1 parent 032ec3b
@quirkey quirkey authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 lib/plugins/sammy.storage.js
View
23 lib/plugins/sammy.storage.js
@@ -146,8 +146,10 @@
},
// Removes the value at `key` from the current store
clear: function(key, callback) {
- this._removeKey(key);
- this.storage.clear(key, _invoke(callback, this));
+ var store = this;
+ this._removeKey(key, function() {
+ this.storage.clear(key, _invoke(callback, store));
+ });
return this;
},
// Clears all the values for the current store.
@@ -176,13 +178,15 @@
each: function(each_callback, complete_callback) {
this.keys(function(keys) {
var i = 0,
+ l = keys.length,
store = this,
returned;
- eachFun = function(val) {
- returned = _invoke(callback, store, val);
+ eachFun = function(key, val) {
+ returned = _invoke(callback, store, key, val);
if (returned === false) { return false; }
};
for (; i < keys.length; i++) {
+ each_callback()
}
});
},
@@ -276,10 +280,11 @@
});
},
_removeKey: function(key) {
- var keys = this.keys();
- var index = $.inArray(key, keys);
- if (index != -1) { keys.splice(index, 1); }
- this.set(this.meta_key, keys);
+ this.keys(function(keys) {
+ var index = $.inArray(key, keys);
+ if (index != -1) { keys.splice(index, 1); }
+ this.set(this.meta_key, keys);
+ });
}
});
@@ -315,7 +320,7 @@
get: function(key, callback) {
return _invoke(callback, false, this.store[key]);
},
- clear: function(key) {
+ clear: function(key, callback) {
delete this.store[key];
return _invoke(callback, false, key);
}
Please sign in to comment.
Something went wrong with that request. Please try again.