diff --git a/dist/store.common.js b/dist/store.common.js index 8bff957..f49c149 100644 --- a/dist/store.common.js +++ b/dist/store.common.js @@ -128,7 +128,7 @@ Store.prototype = { return d; }, forEach: function forEach(callback) { - for (var i = 0; i < storage.length; i++) { + for (var i = 0, len = storage.length; i < len; i++) { var key = storage.key(i); callback(key, this.get(key)); } @@ -139,7 +139,7 @@ Store.prototype = { var arr = this.keys(), dt = {}; - for (var i = 0; i < arr.length; i++) { + for (var i = 0, len = arr.length; i < len; i++) { if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]); } @@ -171,7 +171,7 @@ function store(key, data) { } if (argm.length === 2 && isArray(key) && isFunction(data)) { - for (var i = 0; i < key.length; i++) { + for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } diff --git a/dist/store.common.min.js b/dist/store.common.min.js index 3a9e578..a51c443 100644 --- a/dist/store.common.min.js +++ b/dist/store.common.min.js @@ -1,2 +1,2 @@ /*! storejs v1.0.24 | MIT (c) 2018 kenny wang | https://github.com/jaywcjlove/store.js */ -"use strict";var storage=window.localStorage;function isJSON(t){return t=JSON.stringify(t),/^\{[\s\S]*\}$/.test(t)}function stringify(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)}function deserialize(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}}function isFunction(t){return"[object Function]"==={}.toString.call(t)}function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function dealIncognito(e){var t="_Is_Incognit";try{e.setItem(t,"yes")}catch(t){if("QuotaExceededError"===t.name){var r=function(){};e.__proto__={setItem:r,getItem:r,removeItem:r,clear:r}}}finally{"yes"===e.getItem(t)&&e.removeItem(t)}return e}function Store(){if(!(this instanceof Store))return new Store}storage=dealIncognito(storage),Store.prototype={set:function(t,e){if(t&&!isJSON(t))storage.setItem(t,stringify(e));else if(isJSON(t))for(var r in t)this.set(r,t[r]);return this},get:function(t){if(t)return"?"===t.charAt(0)?this.has(t.substr(1)):deserialize(storage.getItem(t));var r={};return this.forEach(function(t,e){return r[t]=e}),r},clear:function(){return storage.clear(),this},remove:function(t){var e=this.get(t);return storage.removeItem(t),e},has:function(t){return{}.hasOwnProperty.call(this.get(),t)},keys:function(){var e=[];return this.forEach(function(t){e.push(t)}),e},forEach:function(t){for(var e=0;e -1) dt[arr[i]] = this.get(arr[i]); } @@ -169,7 +169,7 @@ function store(key, data) { } if (argm.length === 2 && isArray(key) && isFunction(data)) { - for (var i = 0; i < key.length; i++) { + for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } diff --git a/dist/store.js b/dist/store.js index 364392b..414443b 100644 --- a/dist/store.js +++ b/dist/store.js @@ -132,7 +132,7 @@ return d; }, forEach: function forEach(callback) { - for (var i = 0; i < storage.length; i++) { + for (var i = 0, len = storage.length; i < len; i++) { var key = storage.key(i); callback(key, this.get(key)); } @@ -143,7 +143,7 @@ var arr = this.keys(), dt = {}; - for (var i = 0; i < arr.length; i++) { + for (var i = 0, len = arr.length; i < len; i++) { if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]); } @@ -175,7 +175,7 @@ } if (argm.length === 2 && isArray(key) && isFunction(data)) { - for (var i = 0; i < key.length; i++) { + for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } diff --git a/dist/store.min.js b/dist/store.min.js index f6f2361..7daaebb 100644 --- a/dist/store.min.js +++ b/dist/store.min.js @@ -1,2 +1,2 @@ /*! storejs v1.0.24 | MIT (c) 2018 kenny wang | https://github.com/jaywcjlove/store.js */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.store=e()}(this,function(){"use strict";var i=window.localStorage;function o(t){return t=JSON.stringify(t),/^\{[\s\S]*\}$/.test(t)}function f(t){return"[object Function]"==={}.toString.call(t)}function u(){if(!(this instanceof u))return new u}i=function(e){var t="_Is_Incognit";try{e.setItem(t,"yes")}catch(t){if("QuotaExceededError"===t.name){var r=function(){};e.__proto__={setItem:r,getItem:r,removeItem:r,clear:r}}}finally{"yes"===e.getItem(t)&&e.removeItem(t)}return e}(i),u.prototype={set:function(t,e){if(t&&!o(t))i.setItem(t,void 0===(n=e)||"function"==typeof n?n+"":JSON.stringify(n));else if(o(t))for(var r in t)this.set(r,t[r]);var n;return this},get:function(t){if(t)return"?"===t.charAt(0)?this.has(t.substr(1)):function(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}}(i.getItem(t));var r={};return this.forEach(function(t,e){return r[t]=e}),r},clear:function(){return i.clear(),this},remove:function(t){var e=this.get(t);return i.removeItem(t),e},has:function(t){return{}.hasOwnProperty.call(this.get(),t)},keys:function(){var e=[];return this.forEach(function(t){e.push(t)}),e},forEach:function(t){for(var e=0;e