Comparing version 2.0.2 to 2.0.3
@@ -18,3 +18,3 @@ # Documentation | ||
The prefix is used when saving keys. This allows seperate stores with different prefixes to save values under the same key. | ||
The prefix is used when saving keys. This allows separate stores with different prefixes to save values under the same key. | ||
@@ -65,3 +65,3 @@ ```js | ||
Use the `get` method, or its shortcut: `store.)` / `session()`, to retrieve values. | ||
Use the `get` method, or its shortcut: `store()` / `session()`, to retrieve values. | ||
@@ -71,3 +71,3 @@ ```javascript | ||
// Are the same as | ||
store.'key'); // Or: session('key') | ||
store(key'); // Or: session('key') | ||
``` | ||
@@ -104,3 +104,3 @@ | ||
Call `store.all` to get all data saved with the `store. object: | ||
Call `store.all` to get all data saved with the `store` object: | ||
```javascript | ||
@@ -122,3 +122,3 @@ var store.ata = store.all(); | ||
This will remove all of the data that was saved with `store.: | ||
This will remove all of the data that was saved with `store`: | ||
@@ -184,3 +184,3 @@ ```javascript | ||
This appends a string to a `store. / `session` value: | ||
This appends a string to a `store` / `session` value: | ||
@@ -187,0 +187,0 @@ ```javascript |
{ | ||
"name": "xStore", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"main": "src/xStore.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -150,3 +150,3 @@ // Copyright (c) 2012-2016 Florian Hartmann, https://github.com/florian https://github.com/florian/lostorage.js | ||
for (var i = 0, l = keys.length; i < l; i++) { | ||
delete this.store[keys[i]]; | ||
this.store.removeItem(keys[i]); | ||
} | ||
@@ -153,0 +153,0 @@ |
// Copyright (c) 2012-2016 Florian Hartmann, https://github.com/florian https://github.com/florian/lostorage.js | ||
!function(a,b){var c={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},isPlainObj:function(a){return a===Object(a)},toArray:function(a){return Array.prototype.slice.call(a)},prepareArgs:function(a,b){return a=c.toArray(a),a.unshift(b),a},getObjKeyByValue:function(a,b){for(var c in a)if(a.hasOwnProperty(c)&&a[c]===b)return c},retrieve:function(a,b){return null==a?b:a},serialize:function(a){return JSON.stringify(a)},unserialize:function(a){return null==a?b:JSON.parse(a)}},d=function(a,b){this.prefix=a,this.store=b};d.prototype.addPrefix=function(a){return this.prefix+a},d.prototype.get=function(a,d){d=d||b;var e;if(c.isArray(a)){for(var f={},g=0,h=a.length;g<h;g++)e=a[g],f[e]=this.get(e,d);return f}return e=this.addPrefix(a),c.retrieve(c.unserialize(this.store.getItem(e)),d)},d.prototype.set=function(a,b){if(c.isPlainObj(a))for(var d in a)a.hasOwnProperty(d)&&this.set(d,a[d]);else a=this.addPrefix(a),this.store.setItem(a,c.serialize(b));return this},d.prototype.invert=function(a){return this.set(a,!this.get(a))},d.prototype.add=function(a,b){return this.set(a,this.get(a)+parseInt(b,10))},d.prototype.increase=function(a,b){return this.add(a,c.retrieve(b,1))},d.prototype.decrease=function(a,b){return this.add(a,-c.retrieve(b,1))},d.prototype.concat=function(a,b){return this.set(a,this.get(a)+b)},d.prototype.push=function(a,b){var d=c.toArray(arguments),e=this.get(a,[]);return d.splice(0,1),e.push.apply(e,d),this.set(a,e)},d.prototype.extend=function(a,b,d){var e=this.get(a,{});if(c.isPlainObj(b))for(var f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);else e[b]=d;return this.set(a,e)},d.prototype.remove=function(a){a=c.isArray(a)?a:c.toArray(arguments);for(var b=0,d=a.length;b<d;b++)delete this.store[a[b]];return this},d.prototype.empty=function(){return this.store.clear(),this},d.prototype.all=function(){for(var a={},b=0,d=this.store.length;b<d;b++){var e=this.store.key(b);if(0===e.indexOf(this.prefix)){var f=c.unserialize(this.store.getItem(e));e=e.substring(this.prefix.length),a[e]=f}}return a},"function"==typeof define&&define.amd?define(function(){return{xStore:d}}):"undefined"!=typeof exports?module.exports=d:a.xStore=d}(window); | ||
!function(a,b){var c={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},isPlainObj:function(a){return a===Object(a)},toArray:function(a){return Array.prototype.slice.call(a)},prepareArgs:function(a,b){return a=c.toArray(a),a.unshift(b),a},getObjKeyByValue:function(a,b){for(var c in a)if(a.hasOwnProperty(c)&&a[c]===b)return c},retrieve:function(a,b){return null==a?b:a},serialize:function(a){return JSON.stringify(a)},unserialize:function(a){return null==a?b:JSON.parse(a)}},d=function(a,b){this.prefix=a,this.store=b};d.prototype.addPrefix=function(a){return this.prefix+a},d.prototype.get=function(a,d){d=d||b;var e;if(c.isArray(a)){for(var f={},g=0,h=a.length;g<h;g++)e=a[g],f[e]=this.get(e,d);return f}return e=this.addPrefix(a),c.retrieve(c.unserialize(this.store.getItem(e)),d)},d.prototype.set=function(a,b){if(c.isPlainObj(a))for(var d in a)a.hasOwnProperty(d)&&this.set(d,a[d]);else a=this.addPrefix(a),this.store.setItem(a,c.serialize(b));return this},d.prototype.invert=function(a){return this.set(a,!this.get(a))},d.prototype.add=function(a,b){return this.set(a,this.get(a)+parseInt(b,10))},d.prototype.increase=function(a,b){return this.add(a,c.retrieve(b,1))},d.prototype.decrease=function(a,b){return this.add(a,-c.retrieve(b,1))},d.prototype.concat=function(a,b){return this.set(a,this.get(a)+b)},d.prototype.push=function(a,b){var d=c.toArray(arguments),e=this.get(a,[]);return d.splice(0,1),e.push.apply(e,d),this.set(a,e)},d.prototype.extend=function(a,b,d){var e=this.get(a,{});if(c.isPlainObj(b))for(var f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);else e[b]=d;return this.set(a,e)},d.prototype.remove=function(a){a=c.isArray(a)?a:c.toArray(arguments);for(var b=0,d=a.length;b<d;b++)this.store.removeItem(a[b]);return this},d.prototype.empty=function(){return this.store.clear(),this},d.prototype.all=function(){for(var a={},b=0,d=this.store.length;b<d;b++){var e=this.store.key(b);if(0===e.indexOf(this.prefix)){var f=c.unserialize(this.store.getItem(e));e=e.substring(this.prefix.length),a[e]=f}}return a},"function"==typeof define&&define.amd?define(function(){return{xStore:d}}):"undefined"!=typeof exports?module.exports=d:a.xStore=d}(window); |
222960