From d4a552509f5bb4f61d913f6760f65dd6279c94dc Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 1 Mar 2023 21:40:56 +0800 Subject: [PATCH] chore(deps): update devDependencies rollup to ^3.17.3 --- dist/store.cjs.js | 58 +++++++++----------------------------------- dist/store.esm.js | 58 +++++++++----------------------------------- dist/store.js | 62 ++++++++++------------------------------------- dist/store.min.js | 4 +-- package.json | 27 ++++++++++----------- scripts/build.js | 2 +- scripts/watch.js | 2 +- 7 files changed, 52 insertions(+), 161 deletions(-) diff --git a/dist/store.cjs.js b/dist/store.cjs.js index a32f071..6103e77 100644 --- a/dist/store.cjs.js +++ b/dist/store.cjs.js @@ -1,9 +1,9 @@ /**! - * storejs v2.0.0 + * storejs v2.0.1 * Local storage localstorage package provides a simple API * - * Copyright (c) 2021 kenny wang - * https://github.com/jaywcjlove/store.js + * Copyright (c) 2023 kenny wang + * https://jaywcjlove.github.io/store.js/ * * Licensed under the MIT license. */ @@ -11,53 +11,42 @@ 'use strict'; var storage = window.localStorage; - function isJSON(obj) { obj = JSON.stringify(obj); - if (!/^\{[\s\S]*\}$/.test(obj)) { return false; } - return true; } - function stringify(val) { return val === undefined || typeof val === "function" ? val + '' : JSON.stringify(val); } - function deserialize(value) { if (typeof value !== 'string') { return undefined; } - try { return JSON.parse(value); } catch (e) { return value; } } - function isFunction(value) { return {}.toString.call(value) === "[object Function]"; } - function isArray(value) { return Object.prototype.toString.call(value) === "[object Array]"; -} // https://github.com/jaywcjlove/store.js/pull/8 +} +// https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError - - function dealIncognito(storage) { var _KEY = '_Is_Incognit', - _VALUE = 'yes'; - + _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); } catch (e) { if (e.name === 'QuotaExceededError') { var _nothing = function _nothing() {}; - storage.__proto__ = { setItem: _nothing, getItem: _nothing, @@ -68,29 +57,23 @@ function dealIncognito(storage) { } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } - return storage; -} // deal QuotaExceededError if user use incognito mode in browser - +} +// deal QuotaExceededError if user use incognito mode in browser storage = dealIncognito(storage); - function Store() { if (!(this instanceof Store)) { return new Store(); } } - Store.prototype = { set: function set(key, val) { if (key && !isJSON(key)) { storage.setItem(key, stringify(val)); } else if (isJSON(key)) { - for (var a in key) { - this.set(a, key[a]); - } + for (var a in key) this.set(a, key[a]); } - return this; }, get: function get(key) { @@ -101,27 +84,20 @@ Store.prototype = { }); return ret; } - if (key.charAt(0) === '?') { return this.has(key.substr(1)); } - var args = arguments; - if (args.length > 1) { var dt = {}; - for (var i = 0, len = args.length; i < len; i++) { var value = deserialize(storage.getItem(args[i])); - if (this.has(args[i])) { dt[args[i]] = value; } } - return dt; } - return deserialize(storage.getItem(key)); }, clear: function clear() { @@ -148,56 +124,44 @@ Store.prototype = { var key = storage.key(i); callback(key, this.get(key)); } - return this; }, search: function search(str) { var arr = this.keys(), - dt = {}; - + dt = {}; for (var i = 0, len = arr.length; i < len; i++) { if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]); } - return dt; } }; var _Store = null; - function store(key, data) { var argm = arguments; var dt = null; if (!_Store) _Store = Store(); if (argm.length === 0) return _Store.get(); - if (argm.length === 1) { if (typeof key === "string") return _Store.get(key); if (isJSON(key)) return _Store.set(key); } - if (argm.length === 2 && typeof key === "string") { if (!data) return _Store.remove(key); if (data && typeof data === "string") return _Store.set(key, data); - if (data && isFunction(data)) { dt = null; dt = data(key, _Store.get(key)); store.set(key, dt); } } - if (argm.length === 2 && isArray(key) && isFunction(data)) { for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } } - return store; } - -for (var a in Store.prototype) { - store[a] = Store.prototype[a]; -} +for (var a in Store.prototype) store[a] = Store.prototype[a]; module.exports = store; diff --git a/dist/store.esm.js b/dist/store.esm.js index 6b17ba7..de853b4 100644 --- a/dist/store.esm.js +++ b/dist/store.esm.js @@ -1,61 +1,50 @@ /**! - * storejs v2.0.0 + * storejs v2.0.1 * Local storage localstorage package provides a simple API * - * Copyright (c) 2021 kenny wang - * https://github.com/jaywcjlove/store.js + * Copyright (c) 2023 kenny wang + * https://jaywcjlove.github.io/store.js/ * * Licensed under the MIT license. */ var storage = window.localStorage; - function isJSON(obj) { obj = JSON.stringify(obj); - if (!/^\{[\s\S]*\}$/.test(obj)) { return false; } - return true; } - function stringify(val) { return val === undefined || typeof val === "function" ? val + '' : JSON.stringify(val); } - function deserialize(value) { if (typeof value !== 'string') { return undefined; } - try { return JSON.parse(value); } catch (e) { return value; } } - function isFunction(value) { return {}.toString.call(value) === "[object Function]"; } - function isArray(value) { return Object.prototype.toString.call(value) === "[object Array]"; -} // https://github.com/jaywcjlove/store.js/pull/8 +} +// https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError - - function dealIncognito(storage) { var _KEY = '_Is_Incognit', - _VALUE = 'yes'; - + _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); } catch (e) { if (e.name === 'QuotaExceededError') { var _nothing = function _nothing() {}; - storage.__proto__ = { setItem: _nothing, getItem: _nothing, @@ -66,29 +55,23 @@ function dealIncognito(storage) { } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } - return storage; -} // deal QuotaExceededError if user use incognito mode in browser - +} +// deal QuotaExceededError if user use incognito mode in browser storage = dealIncognito(storage); - function Store() { if (!(this instanceof Store)) { return new Store(); } } - Store.prototype = { set: function set(key, val) { if (key && !isJSON(key)) { storage.setItem(key, stringify(val)); } else if (isJSON(key)) { - for (var a in key) { - this.set(a, key[a]); - } + for (var a in key) this.set(a, key[a]); } - return this; }, get: function get(key) { @@ -99,27 +82,20 @@ Store.prototype = { }); return ret; } - if (key.charAt(0) === '?') { return this.has(key.substr(1)); } - var args = arguments; - if (args.length > 1) { var dt = {}; - for (var i = 0, len = args.length; i < len; i++) { var value = deserialize(storage.getItem(args[i])); - if (this.has(args[i])) { dt[args[i]] = value; } } - return dt; } - return deserialize(storage.getItem(key)); }, clear: function clear() { @@ -146,56 +122,44 @@ Store.prototype = { var key = storage.key(i); callback(key, this.get(key)); } - return this; }, search: function search(str) { var arr = this.keys(), - dt = {}; - + dt = {}; for (var i = 0, len = arr.length; i < len; i++) { if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]); } - return dt; } }; var _Store = null; - function store(key, data) { var argm = arguments; var dt = null; if (!_Store) _Store = Store(); if (argm.length === 0) return _Store.get(); - if (argm.length === 1) { if (typeof key === "string") return _Store.get(key); if (isJSON(key)) return _Store.set(key); } - if (argm.length === 2 && typeof key === "string") { if (!data) return _Store.remove(key); if (data && typeof data === "string") return _Store.set(key, data); - if (data && isFunction(data)) { dt = null; dt = data(key, _Store.get(key)); store.set(key, dt); } } - if (argm.length === 2 && isArray(key) && isFunction(data)) { for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } } - return store; } - -for (var a in Store.prototype) { - store[a] = Store.prototype[a]; -} +for (var a in Store.prototype) store[a] = Store.prototype[a]; export { store as default }; diff --git a/dist/store.js b/dist/store.js index 9eba977..6cf37be 100644 --- a/dist/store.js +++ b/dist/store.js @@ -1,9 +1,9 @@ /**! - * storejs v2.0.0 + * storejs v2.0.1 * Local storage localstorage package provides a simple API * - * Copyright (c) 2021 kenny wang - * https://github.com/jaywcjlove/store.js + * Copyright (c) 2023 kenny wang + * https://jaywcjlove.github.io/store.js/ * * Licensed under the MIT license. */ @@ -12,56 +12,45 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.store = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var storage = window.localStorage; - function isJSON(obj) { obj = JSON.stringify(obj); - if (!/^\{[\s\S]*\}$/.test(obj)) { return false; } - return true; } - function stringify(val) { return val === undefined || typeof val === "function" ? val + '' : JSON.stringify(val); } - function deserialize(value) { if (typeof value !== 'string') { return undefined; } - try { return JSON.parse(value); } catch (e) { return value; } } - function isFunction(value) { return {}.toString.call(value) === "[object Function]"; } - function isArray(value) { return Object.prototype.toString.call(value) === "[object Array]"; - } // https://github.com/jaywcjlove/store.js/pull/8 + } + // https://github.com/jaywcjlove/store.js/pull/8 // Error: QuotaExceededError - - function dealIncognito(storage) { var _KEY = '_Is_Incognit', - _VALUE = 'yes'; - + _VALUE = 'yes'; try { storage.setItem(_KEY, _VALUE); } catch (e) { if (e.name === 'QuotaExceededError') { var _nothing = function _nothing() {}; - storage.__proto__ = { setItem: _nothing, getItem: _nothing, @@ -72,29 +61,23 @@ } finally { if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY); } - return storage; - } // deal QuotaExceededError if user use incognito mode in browser - + } + // deal QuotaExceededError if user use incognito mode in browser storage = dealIncognito(storage); - function Store() { if (!(this instanceof Store)) { return new Store(); } } - Store.prototype = { set: function set(key, val) { if (key && !isJSON(key)) { storage.setItem(key, stringify(val)); } else if (isJSON(key)) { - for (var a in key) { - this.set(a, key[a]); - } + for (var a in key) this.set(a, key[a]); } - return this; }, get: function get(key) { @@ -105,27 +88,20 @@ }); return ret; } - if (key.charAt(0) === '?') { return this.has(key.substr(1)); } - var args = arguments; - if (args.length > 1) { var dt = {}; - for (var i = 0, len = args.length; i < len; i++) { var value = deserialize(storage.getItem(args[i])); - if (this.has(args[i])) { dt[args[i]] = value; } } - return dt; } - return deserialize(storage.getItem(key)); }, clear: function clear() { @@ -152,58 +128,46 @@ var key = storage.key(i); callback(key, this.get(key)); } - return this; }, search: function search(str) { var arr = this.keys(), - dt = {}; - + dt = {}; for (var i = 0, len = arr.length; i < len; i++) { if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]); } - return dt; } }; var _Store = null; - function store(key, data) { var argm = arguments; var dt = null; if (!_Store) _Store = Store(); if (argm.length === 0) return _Store.get(); - if (argm.length === 1) { if (typeof key === "string") return _Store.get(key); if (isJSON(key)) return _Store.set(key); } - if (argm.length === 2 && typeof key === "string") { if (!data) return _Store.remove(key); if (data && typeof data === "string") return _Store.set(key, data); - if (data && isFunction(data)) { dt = null; dt = data(key, _Store.get(key)); store.set(key, dt); } } - if (argm.length === 2 && isArray(key) && isFunction(data)) { for (var i = 0, len = key.length; i < len; i++) { dt = data(key[i], _Store.get(key[i])); store.set(key[i], dt); } } - return store; } - - for (var a in Store.prototype) { - store[a] = Store.prototype[a]; - } + for (var a in Store.prototype) store[a] = Store.prototype[a]; return store; -}))); +})); diff --git a/dist/store.min.js b/dist/store.min.js index f5033c0..41301f6 100644 --- a/dist/store.min.js +++ b/dist/store.min.js @@ -1,2 +1,2 @@ -/*! storejs v2.0.0 | MIT (c) 2021 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="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(t){return"[object Array]"===Object.prototype.toString.call(t)}function o(){if(!(this instanceof o))return new o}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),o.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 f=null;function u(t,r){var s=arguments,c=null;if(f||(f=o()),0===s.length)return f.get();if(1===s.length){if("string"==typeof t)return f.get(t);if(e(t))return f.set(t)}if(2===s.length&&"string"==typeof t){if(!r)return f.remove(t);if(r&&"string"==typeof r)return f.set(t,r);r&&n(r)&&(c=null,c=r(t,f.get(t)),u.set(t,c))}if(2===s.length&&i(t)&&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";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