fixed bug with 'keys' and 'clear'

This commit is contained in:
AJ ONeal 2011-09-05 15:40:52 -06:00
parent bf858f6073
commit f903a4e179
2 changed files with 10 additions and 8 deletions

View File

@ -31,7 +31,7 @@
db.prototype.clear = function () {
this.keysAreDirty = true;
self.keys().forEach(function (uuid) {
this.keys().forEach(function (uuid) {
this.remove(uuid);
}, this);
};
@ -51,18 +51,20 @@
};
db.prototype.keys = function () {
var i;
var i
;
if (!this.keysAreDirty) {
return this.keys;
return this.__keys.concat([]);
}
this.keys = [];
this.__keys = [];
for (i = 0; i < this.db.length; i += 1) {
this.keys.push(this.db.key(i));
this.__keys.push(this.db.key(i));
}
this.keysAreDirty = false;
return this.keys.concat([]);
return this.__keys.concat([]);
};
db.prototype.size = function () {

View File

@ -3,7 +3,7 @@
"name": "json-storage",
"description": "A wrapper for storage engines which use the W3C Storage API",
"keywords": ["ender", "localStorage", "sessionStorage", "globalStorage", "Storage"],
"version": "1.0.0",
"version": "1.0.1",
"repository": {
"type": "git",
"url": "git://github.com/coolaj86/json-storage-js.git"
@ -11,7 +11,7 @@
"engines": {
"node": ">= v0.2.0"
},
"main": "json-storage.js",
"main": "index",
"dependencies": {},
"devDependencies": {}
}