From f903a4e1799929346fc72a9b6e7586741d72392c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 5 Sep 2011 15:40:52 -0600 Subject: [PATCH] fixed bug with 'keys' and 'clear' --- lib/{json-storage.js => index.js} | 14 ++++++++------ lib/package.json | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) rename lib/{json-storage.js => index.js} (86%) diff --git a/lib/json-storage.js b/lib/index.js similarity index 86% rename from lib/json-storage.js rename to lib/index.js index 29c414c..308e735 100644 --- a/lib/json-storage.js +++ b/lib/index.js @@ -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 () { diff --git a/lib/package.json b/lib/package.json index fe90600..b0bb4f1 100644 --- a/lib/package.json +++ b/lib/package.json @@ -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": {} }