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

View File

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