From a704e4ad02f08e9b99386fe5b3fd17a7c0ac19b6 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 3 Mar 2012 14:05:37 -0700 Subject: [PATCH] fixed bug where if toJSON is called before keys, it threw an error --- lib/index.js | 3 ++- lib/package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6bddfcf..91b3539 100644 --- a/lib/index.js +++ b/lib/index.js @@ -75,6 +75,7 @@ this._store = w3cStorage; this._keysAreDirty = true; + this._keys = []; if (!this._store.getItem('_json-storage-namespaced_')) { upgradeStorage(this, w3cStorage); } @@ -135,7 +136,7 @@ var json = {} ; - this._keys.forEach(function (key) { + this.keys().forEach(function (key) { json[key] = this.get(key); }, this); diff --git a/lib/package.json b/lib/package.json index 6fd005a..2400d9a 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.1.1", + "version": "1.1.2", "repository": { "type": "git", "url": "git://github.com/coolaj86/json-storage-js.git"