From 8ed05fb37a2fba5bdb8b887d800c782452db074e Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 30 Mar 2023 01:24:41 +0800 Subject: [PATCH] released v2.0.3 #41 #8 --- dist/store.cjs.js | 32 +++++++++++++++++++------------- dist/store.esm.js | 32 +++++++++++++++++++------------- dist/store.js | 32 +++++++++++++++++++------------- dist/store.min.js | 4 ++-- package.json | 8 +------- 5 files changed, 60 insertions(+), 48 deletions(-) diff --git a/dist/store.cjs.js b/dist/store.cjs.js index 1283e3f..d70206a 100644 --- a/dist/store.cjs.js +++ b/dist/store.cjs.js @@ -1,5 +1,5 @@ /**! - * storejs v2.0.2 + * storejs v2.0.3 * Local storage localstorage package provides a simple API * * Copyright (c) 2023 kenny wang @@ -10,7 +10,6 @@ 'use strict'; -var storage = window.localStorage; function isJSON(obj) { obj = JSON.stringify(obj); if (!/^\{[\s\S]*\}$/.test(obj)) { @@ -39,21 +38,28 @@ function isArray(value) { } // https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError -function dealIncognito(storage) { +function dealIncognito() { + var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage; var _KEY = '_Is_Incognit', _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); + storage.removeItem(_KEY); } catch (e) { - if (e.name === 'QuotaExceededError') { - var _nothing = function _nothing() {}; - storage.__proto__ = { - setItem: _nothing, - getItem: _nothing, - removeItem: _nothing, - clear: _nothing - }; - } + Storage.prototype._data = {}; + Storage.prototype.setItem = function (id, val) { + return this._data[id] = String(val); + }; + Storage.prototype.getItem = function (id) { + return this._data.hasOwnProperty(id) ? this._data[id] : undefined; + }; + Storage.prototype.removeItem = function (id) { + return delete this._data[id]; + }; + Storage.prototype.clear = function () { + return this._data = {}; + }; + storage = Storage; } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } @@ -61,7 +67,7 @@ function dealIncognito(storage) { } // deal QuotaExceededError if user use incognito mode in browser -storage = dealIncognito(storage); +var storage = dealIncognito(); function Store() { if (!(this instanceof Store)) { return new Store(); diff --git a/dist/store.esm.js b/dist/store.esm.js index f2f9f93..9801e1d 100644 --- a/dist/store.esm.js +++ b/dist/store.esm.js @@ -1,5 +1,5 @@ /**! - * storejs v2.0.2 + * storejs v2.0.3 * Local storage localstorage package provides a simple API * * Copyright (c) 2023 kenny wang @@ -8,7 +8,6 @@ * Licensed under the MIT license. */ -var storage = window.localStorage; function isJSON(obj) { obj = JSON.stringify(obj); if (!/^\{[\s\S]*\}$/.test(obj)) { @@ -37,21 +36,28 @@ function isArray(value) { } // https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError -function dealIncognito(storage) { +function dealIncognito() { + var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage; var _KEY = '_Is_Incognit', _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); + storage.removeItem(_KEY); } catch (e) { - if (e.name === 'QuotaExceededError') { - var _nothing = function _nothing() {}; - storage.__proto__ = { - setItem: _nothing, - getItem: _nothing, - removeItem: _nothing, - clear: _nothing - }; - } + Storage.prototype._data = {}; + Storage.prototype.setItem = function (id, val) { + return this._data[id] = String(val); + }; + Storage.prototype.getItem = function (id) { + return this._data.hasOwnProperty(id) ? this._data[id] : undefined; + }; + Storage.prototype.removeItem = function (id) { + return delete this._data[id]; + }; + Storage.prototype.clear = function () { + return this._data = {}; + }; + storage = Storage; } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } @@ -59,7 +65,7 @@ function dealIncognito(storage) { } // deal QuotaExceededError if user use incognito mode in browser -storage = dealIncognito(storage); +var storage = dealIncognito(); function Store() { if (!(this instanceof Store)) { return new Store(); diff --git a/dist/store.js b/dist/store.js index 84f1f52..b4d7933 100644 --- a/dist/store.js +++ b/dist/store.js @@ -1,5 +1,5 @@ /**! - * storejs v2.0.2 + * storejs v2.0.3 * Local storage localstorage package provides a simple API * * Copyright (c) 2023 kenny wang @@ -14,7 +14,6 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.store = factory()); })(this, (function () { 'use strict'; - var storage = window.localStorage; function isJSON(obj) { obj = JSON.stringify(obj); if (!/^\{[\s\S]*\}$/.test(obj)) { @@ -43,21 +42,28 @@ } // https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError - function dealIncognito(storage) { + function dealIncognito() { + var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage; var _KEY = '_Is_Incognit', _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); + storage.removeItem(_KEY); } catch (e) { - if (e.name === 'QuotaExceededError') { - var _nothing = function _nothing() {}; - storage.__proto__ = { - setItem: _nothing, - getItem: _nothing, - removeItem: _nothing, - clear: _nothing - }; - } + Storage.prototype._data = {}; + Storage.prototype.setItem = function (id, val) { + return this._data[id] = String(val); + }; + Storage.prototype.getItem = function (id) { + return this._data.hasOwnProperty(id) ? this._data[id] : undefined; + }; + Storage.prototype.removeItem = function (id) { + return delete this._data[id]; + }; + Storage.prototype.clear = function () { + return this._data = {}; + }; + storage = Storage; } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } @@ -65,7 +71,7 @@ } // deal QuotaExceededError if user use incognito mode in browser - storage = dealIncognito(storage); + var storage = dealIncognito(); function Store() { if (!(this instanceof Store)) { return new Store(); diff --git a/dist/store.min.js b/dist/store.min.js index ba1a634..b9c99e8 100644 --- a/dist/store.min.js +++ b/dist/store.min.js @@ -1,2 +1,2 @@ -/*! storejs v2.0.2 | MIT (c) 2023 kenny wang | https://jaywcjlove.github.io/store.js/ */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).store=e()}(this,(function(){"use strict";var t=window.localStorage;function e(t){return t=JSON.stringify(t),!!/^\{[\s\S]*\}$/.test(t)}function r(t){if("string"==typeof t)try{return JSON.parse(t)}catch(e){return t}}function n(t){return"[object Function]"==={}.toString.call(t)}function i(){if(!(this instanceof i))return new i}t=function(t){var e="_Is_Incognit";try{t.setItem(e,"yes")}catch(e){if("QuotaExceededError"===e.name){var r=function(){};t.__proto__={setItem:r,getItem:r,removeItem:r,clear:r}}}finally{"yes"===t.getItem(e)&&t.removeItem(e)}return t}(t),i.prototype={set:function(r,n){if(r&&!e(r))t.setItem(r,function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)}(n));else if(e(r))for(var i in r)this.set(i,r[i]);return this},get:function(e){if(!e){var n={};return this.forEach((function(t,e){return n[t]=e})),n}if("?"===e.charAt(0))return this.has(e.substr(1));var i=arguments;if(i.length>1){for(var o={},f=0,u=i.length;f-1&&(r[e[n]]=this.get(e[n]));return r}};var o=null;function f(t,r){var u,s=arguments,c=null;if(o||(o=i()),0===s.length)return o.get();if(1===s.length){if("string"==typeof t)return o.get(t);if(e(t))return o.set(t)}if(2===s.length&&"string"==typeof t){if(!r)return o.remove(t);if(r&&"string"==typeof r)return o.set(t,r);r&&n(r)&&(c=null,c=r(t,o.get(t)),f.set(t,c))}if(2===s.length&&(u=t,"[object Array]"===Object.prototype.toString.call(u))&&n(r))for(var a=0,h=t.length;a | https://jaywcjlove.github.io/store.js/ */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).store=e()}(this,(function(){"use strict";function t(t){return t=JSON.stringify(t),!!/^\{[\s\S]*\}$/.test(t)}function e(t){if("string"==typeof t)try{return JSON.parse(t)}catch(e){return t}}function r(t){return"[object Function]"==={}.toString.call(t)}var n=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.localStorage,e="_Is_Incognit";try{t.setItem(e,"yes"),t.removeItem(e)}catch(e){Storage.prototype._data={},Storage.prototype.setItem=function(t,e){return this._data[t]=String(e)},Storage.prototype.getItem=function(t){return this._data.hasOwnProperty(t)?this._data[t]:void 0},Storage.prototype.removeItem=function(t){return delete this._data[t]},Storage.prototype.clear=function(){return this._data={}},t=Storage}finally{"yes"===t.getItem(e)&&t.removeItem(e)}return t}();function o(){if(!(this instanceof o))return new o}o.prototype={set:function(e,r){if(e&&!t(e))n.setItem(e,function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)}(r));else if(t(e))for(var o in e)this.set(o,e[o]);return this},get:function(t){if(!t){var r={};return this.forEach((function(t,e){return r[t]=e})),r}if("?"===t.charAt(0))return this.has(t.substr(1));var o=arguments;if(o.length>1){for(var i={},f=0,u=o.length;f-1&&(r[e[n]]=this.get(e[n]));return r}};var i=null;function f(e,n){var u,s=arguments,a=null;if(i||(i=o()),0===s.length)return i.get();if(1===s.length){if("string"==typeof e)return i.get(e);if(t(e))return i.set(e)}if(2===s.length&&"string"==typeof e){if(!n)return i.remove(e);if(n&&"string"==typeof n)return i.set(e,n);n&&r(n)&&(a=null,a=n(e,i.get(e)),f.set(e,a))}if(2===s.length&&(u=e,"[object Array]"===Object.prototype.toString.call(u))&&r(n))for(var c=0,h=e.length;c", @@ -32,12 +32,6 @@ "dist/*.js", "types/index.d.ts" ], - "markdown-to-html": { - "reurls": { - "./README-zh.md": "index.zh.html", - "./README.md": "index.html" - } - }, "devDependencies": { "@babel/cli": "^7.21.0", "@babel/core": "^7.21.0",