Socket
Socket
Sign inDemoInstall

reduxed-chrome-storage

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reduxed-chrome-storage - npm Package Compare versions

Comparing version 2.4.7 to 2.4.8

10

dist/index.esm.js
/**
* @license
* ReduxedChromeStorage v2.4.7
* ReduxedChromeStorage v2.4.8
* https://github.com/hindmost/reduxed-chrome-storage

@@ -23,3 +23,4 @@ * Copyright (c) Savr Goryaev aka hindmost

return true;
if (a == null || typeof a !== 'object' || b == null || typeof b !== 'object')
if (a == null || typeof a !== 'object' ||
b == null || typeof b !== 'object')
return false;

@@ -38,5 +39,6 @@ const keysA = Object.keys(a), keysB = Object.keys(b);

return cloneDeep(b);
if (typeof a !== 'object' || Array.isArray(a) || typeof b !== 'object')
if (a == null || typeof a !== 'object' || Array.isArray(a) ||
b == null || typeof b !== 'object')
return typeof b !== 'undefined' ? b : a;
return Object.keys(a).concat(Object.keys(b).filter(key => !a[key])).reduce((acc, key) => {
return Object.keys(a).concat(Object.keys(b).filter(key => !(key in a))).reduce((acc, key) => {
return acc[key] = mergeOrReplace(a[key], b[key]), acc;

@@ -43,0 +45,0 @@ }, {});

/**
* @license
* ReduxedChromeStorage v2.4.7
* ReduxedChromeStorage v2.4.8
* https://github.com/hindmost/reduxed-chrome-storage

@@ -29,3 +29,4 @@ * Copyright (c) Savr Goryaev aka hindmost

{ return true; }
if (a == null || typeof a !== 'object' || b == null || typeof b !== 'object')
if (a == null || typeof a !== 'object' ||
b == null || typeof b !== 'object')
{ return false; }

@@ -46,5 +47,6 @@ var keysA = Object.keys(a), keysB = Object.keys(b);

{ return cloneDeep(b); }
if (typeof a !== 'object' || Array.isArray(a) || typeof b !== 'object')
if (a == null || typeof a !== 'object' || Array.isArray(a) ||
b == null || typeof b !== 'object')
{ return typeof b !== 'undefined' ? b : a; }
return Object.keys(a).concat(Object.keys(b).filter(function (key) { return !a[key]; })).reduce(function (acc, key) {
return Object.keys(a).concat(Object.keys(b).filter(function (key) { return !(key in a); })).reduce(function (acc, key) {
return acc[key] = mergeOrReplace(a[key], b[key]), acc;

@@ -51,0 +53,0 @@ }, {});

4

dist/index.min.js
/**
* @license
* ReduxedChromeStorage v2.4.7
* ReduxedChromeStorage v2.4.8
* https://github.com/hindmost/reduxed-chrome-storage

@@ -11,2 +11,2 @@ * Copyright (c) Savr Goryaev aka hindmost

!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).reduxedChromeStorage=e()}(this,(function(){"use strict";function t(e){return null==e||"object"!=typeof e?e:Array.isArray(e)?e.map((function(e){return t(e)})):Object.keys(e).reduce((function(r,n){return r[n]=t(e[n]),r}),{})}function e(t,r){if(t===r)return!0;if(null==t||"object"!=typeof t||null==r||"object"!=typeof r)return!1;var n=Object.keys(t),i=Object.keys(r);if(n.length!==i.length)return!1;for(var o=0,s=n;s.length>o;o+=1){var a=s[o];if(-1>=i.indexOf(a)||!e(t[a],r[a]))return!1}return!0}function r(e,n){return Array.isArray(n)?t(n):"object"!=typeof e||Array.isArray(e)||"object"!=typeof n?void 0!==n?n:e:Object.keys(e).concat(Object.keys(n).filter((function(t){return!e[t]}))).reduce((function(t,i){return t[i]=r(e[i],n[i]),t}),{})}var n,i=function(t){var e=t.reducer,r=t.storage,n=t.bufferLife,i=t.initialState,o=t.enhancer;this.createStore=t.createStore,this.storage=r,this.reducer=e,this.enhancer=o,this.buffLife=n?Math.min(Math.max(n,0),2e3):100,this.state0=i,this.state=null,this.buffStore=null,this.lastState=null,this.listeners=[],this.inited=!1,this.dispatch=this.dispatch.bind(this),this.subscribe=this.subscribe.bind(this)};i.prototype.init=function(){var t=this;if(this.inited)return new Promise((function(e){e(t)}));var n=this._createStore().getState();return this.storage.subscribe((function(r,n){if(!e(r,t.state)){t._setState(r);for(var i=0,o=t.listeners;o.length>i;i+=1){(0,o[i])(n)}}})),this.inited=!0,new Promise((function(i){t.storage.load((function(o){var s=o?r(n,o):n;t.state0&&(s=r(s,t.state0)),t._setState(s),e(s,o)||t._send2Storage(s),i(t)}))}))},i.prototype.initFrom=function(t){return this._setState(t),this.inited=!0,this},i.prototype.uninit=function(){var t=this;return new Promise((function(e){e(t)}))},i.prototype._createStore=function(t){return this.createStore(this.reducer,t,this.enhancer)},i.prototype._send2Storage=function(t){this.storage.save(t)},i.prototype._setState=function(e){e&&(this.state=t(e))},i.prototype.getState=function(){return this.state},i.prototype.subscribe=function(t){var e=this;return"function"==typeof t&&this.listeners.push(t),function(){"function"==typeof t&&(e.listeners=e.listeners.filter((function(e){return e!==t})))}},i.prototype.dispatch=function(t){var r=this;this.buffStore||(this.buffStore=this._createStore(this.state),this.lastState=this.buffStore.getState(),setTimeout((function(){r.buffStore=null}),this.buffLife));var n=this.buffStore,i=n.subscribe((function(){var t=r.buffStore||n,o=t&&t.getState();e(o,r.lastState)||(r._send2Storage(o),r.lastState=o,i(),n=null)}));return n.dispatch(t)},i.prototype.replaceReducer=function(t){return"function"==typeof t&&(this.reducer=t),this},i.prototype[Symbol.observable]=function(){var t,e=this.getState,r=this.subscribe;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new TypeError("Expected the observer to be an object.");function n(){t.next&&t.next(e())}return n(),{unsubscribe:r(n)}}})[Symbol.observable]=function(){return this},t},function(t){t.local="local",t.sync="sync"}(n||(n={}));var o=function(t){return(new TextEncoder).encode(Object.entries(t).map((function(t){return t[0]+JSON.stringify(t[1])})).join("")).length},s=function(t){var e=t.area,r=t.key;this.ns=t.namespace,this.areaName=e===n.sync?n.sync:n.local,this.key=r||"reduxed",this.listeners=[],this.errorListeners=[]};s.prototype.init=function(){var t=this;this.ns.storage.onChanged.addListener((function(e,r){if(r===t.areaName&&t.key in e){var n=e[t.key],i=n.newValue,o=n.oldValue;if(i)for(var s=0,a=t.listeners;a.length>s;s+=1){(0,a[s])(i,o)}}}))},s.prototype.subscribe=function(t){"function"==typeof t&&this.listeners.push(t)},s.prototype.subscribeForError=function(t){"function"==typeof t&&this.errorListeners.push(t)},s.prototype.fireErrorListeners=function(t,e){for(var r=0,n=this.errorListeners;n.length>r;r+=1){(0,n[r])(t,e)}},s.prototype.callbackOnLoad=function(t,e,r){e(!this.ns.runtime.lastError&&(r?t:t&&t[this.key]))},s.prototype.callbackOnSave=function(t,e){var r,i=this;if(this.ns.runtime.lastError){var s=this.ns.runtime.lastError.message;if(s&&t&&e)this.areaName===n.sync&&e.QUOTA_BYTES_PER_ITEM&&o(((r={})[this.key]=t,r))>e.QUOTA_BYTES_PER_ITEM?this.fireErrorListeners(s,!0):this.load((function(r){var n,a="object"==typeof r&&e.QUOTA_BYTES>0&&o(Object.assign(Object.assign({},r),((n={})[i.key]=t,n)))>e.QUOTA_BYTES;i.fireErrorListeners(s,a)}),!0);else this.fireErrorListeners(s||"",!1)}};var a,c=function(t){function e(e){t.call(this,{namespace:e.namespace,area:e.area,key:e.key}),this.areaApi=this.ns.storage[this.areaName]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.load=function(t,e){var r=this;"function"==typeof t&&this.areaApi.get(e?null:this.key,(function(n){r.callbackOnLoad(n,t,e)}))},e.prototype.save=function(t){var e,r=this;this.areaApi.set(((e={})[this.key]=t,e),(function(){r.callbackOnSave(t,r.areaApi)}))},e}(s),u=function(t){function e(e){t.call(this,{namespace:e.namespace,area:e.area,key:e.key}),this.areaApi=this.ns.storage[this.areaName]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.load=function(t,e){var r=this;"function"==typeof t&&this.areaApi.get(e?null:this.key).then((function(e){r.callbackOnLoad(e,t)}))},e.prototype.save=function(t){var e,r=this;this.areaApi.set((e={},e[this.key]=t,e)).then((function(){r.callbackOnSave(t,r.areaApi)}))},e}(s);return function(t){t.chrome="chrome",t.browser="browser"}(a||(a={})),function(t){var e=t.createStore,r=t.namespace,n=t.chromeNs,o=t.browserNs,s=t.changeListener,f=t.errorListener,h=t.storageArea,p=t.storageKey,l=t.bufferLife;if("function"!=typeof e)throw Error("Missing 'createStore' property/option");var y=o||r===a.browser?new u({namespace:o||browser,area:h,key:p}):new c({namespace:n||chrome,area:h,key:p});return y.init(),"function"==typeof f&&y.subscribeForError(f),function(t,r,n){if("function"!=typeof t)throw Error("Missing 'reducer' parameter");if("function"==typeof r&&"function"==typeof n)throw Error("Multiple 'enhancer' parameters unallowed");"function"==typeof r&&void 0===n&&(n=r,r=void 0);var o=new i({createStore:e,storage:y,bufferLife:l,reducer:t,initialState:r,enhancer:n});return"function"!=typeof s?o.init():(y.subscribe((function(t,e){s(o.initFrom(t),e)})),o.uninit())}}}));
!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).reduxedChromeStorage=e()}(this,(function(){"use strict";function t(e){return null==e||"object"!=typeof e?e:Array.isArray(e)?e.map((function(e){return t(e)})):Object.keys(e).reduce((function(r,n){return r[n]=t(e[n]),r}),{})}function e(t,r){if(t===r)return!0;if(null==t||"object"!=typeof t||null==r||"object"!=typeof r)return!1;var n=Object.keys(t),i=Object.keys(r);if(n.length!==i.length)return!1;for(var o=0,s=n;s.length>o;o+=1){var a=s[o];if(-1>=i.indexOf(a)||!e(t[a],r[a]))return!1}return!0}function r(e,n){return Array.isArray(n)?t(n):null==e||"object"!=typeof e||Array.isArray(e)||null==n||"object"!=typeof n?void 0!==n?n:e:Object.keys(e).concat(Object.keys(n).filter((function(t){return!(t in e)}))).reduce((function(t,i){return t[i]=r(e[i],n[i]),t}),{})}var n,i=function(t){var e=t.reducer,r=t.storage,n=t.bufferLife,i=t.initialState,o=t.enhancer;this.createStore=t.createStore,this.storage=r,this.reducer=e,this.enhancer=o,this.buffLife=n?Math.min(Math.max(n,0),2e3):100,this.state0=i,this.state=null,this.buffStore=null,this.lastState=null,this.listeners=[],this.inited=!1,this.dispatch=this.dispatch.bind(this),this.subscribe=this.subscribe.bind(this)};i.prototype.init=function(){var t=this;if(this.inited)return new Promise((function(e){e(t)}));var n=this._createStore().getState();return this.storage.subscribe((function(r,n){if(!e(r,t.state)){t._setState(r);for(var i=0,o=t.listeners;o.length>i;i+=1){(0,o[i])(n)}}})),this.inited=!0,new Promise((function(i){t.storage.load((function(o){var s=o?r(n,o):n;t.state0&&(s=r(s,t.state0)),t._setState(s),e(s,o)||t._send2Storage(s),i(t)}))}))},i.prototype.initFrom=function(t){return this._setState(t),this.inited=!0,this},i.prototype.uninit=function(){var t=this;return new Promise((function(e){e(t)}))},i.prototype._createStore=function(t){return this.createStore(this.reducer,t,this.enhancer)},i.prototype._send2Storage=function(t){this.storage.save(t)},i.prototype._setState=function(e){e&&(this.state=t(e))},i.prototype.getState=function(){return this.state},i.prototype.subscribe=function(t){var e=this;return"function"==typeof t&&this.listeners.push(t),function(){"function"==typeof t&&(e.listeners=e.listeners.filter((function(e){return e!==t})))}},i.prototype.dispatch=function(t){var r=this;this.buffStore||(this.buffStore=this._createStore(this.state),this.lastState=this.buffStore.getState(),setTimeout((function(){r.buffStore=null}),this.buffLife));var n=this.buffStore,i=n.subscribe((function(){var t=r.buffStore||n,o=t&&t.getState();e(o,r.lastState)||(r._send2Storage(o),r.lastState=o,i(),n=null)}));return n.dispatch(t)},i.prototype.replaceReducer=function(t){return"function"==typeof t&&(this.reducer=t),this},i.prototype[Symbol.observable]=function(){var t,e=this.getState,r=this.subscribe;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new TypeError("Expected the observer to be an object.");function n(){t.next&&t.next(e())}return n(),{unsubscribe:r(n)}}})[Symbol.observable]=function(){return this},t},function(t){t.local="local",t.sync="sync"}(n||(n={}));var o=function(t){return(new TextEncoder).encode(Object.entries(t).map((function(t){return t[0]+JSON.stringify(t[1])})).join("")).length},s=function(t){var e=t.area,r=t.key;this.ns=t.namespace,this.areaName=e===n.sync?n.sync:n.local,this.key=r||"reduxed",this.listeners=[],this.errorListeners=[]};s.prototype.init=function(){var t=this;this.ns.storage.onChanged.addListener((function(e,r){if(r===t.areaName&&t.key in e){var n=e[t.key],i=n.newValue,o=n.oldValue;if(i)for(var s=0,a=t.listeners;a.length>s;s+=1){(0,a[s])(i,o)}}}))},s.prototype.subscribe=function(t){"function"==typeof t&&this.listeners.push(t)},s.prototype.subscribeForError=function(t){"function"==typeof t&&this.errorListeners.push(t)},s.prototype.fireErrorListeners=function(t,e){for(var r=0,n=this.errorListeners;n.length>r;r+=1){(0,n[r])(t,e)}},s.prototype.callbackOnLoad=function(t,e,r){e(!this.ns.runtime.lastError&&(r?t:t&&t[this.key]))},s.prototype.callbackOnSave=function(t,e){var r,i=this;if(this.ns.runtime.lastError){var s=this.ns.runtime.lastError.message;if(s&&t&&e)this.areaName===n.sync&&e.QUOTA_BYTES_PER_ITEM&&o(((r={})[this.key]=t,r))>e.QUOTA_BYTES_PER_ITEM?this.fireErrorListeners(s,!0):this.load((function(r){var n,a="object"==typeof r&&e.QUOTA_BYTES>0&&o(Object.assign(Object.assign({},r),((n={})[i.key]=t,n)))>e.QUOTA_BYTES;i.fireErrorListeners(s,a)}),!0);else this.fireErrorListeners(s||"",!1)}};var a,c=function(t){function e(e){t.call(this,{namespace:e.namespace,area:e.area,key:e.key}),this.areaApi=this.ns.storage[this.areaName]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.load=function(t,e){var r=this;"function"==typeof t&&this.areaApi.get(e?null:this.key,(function(n){r.callbackOnLoad(n,t,e)}))},e.prototype.save=function(t){var e,r=this;this.areaApi.set(((e={})[this.key]=t,e),(function(){r.callbackOnSave(t,r.areaApi)}))},e}(s),u=function(t){function e(e){t.call(this,{namespace:e.namespace,area:e.area,key:e.key}),this.areaApi=this.ns.storage[this.areaName]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.load=function(t,e){var r=this;"function"==typeof t&&this.areaApi.get(e?null:this.key).then((function(e){r.callbackOnLoad(e,t)}))},e.prototype.save=function(t){var e,r=this;this.areaApi.set((e={},e[this.key]=t,e)).then((function(){r.callbackOnSave(t,r.areaApi)}))},e}(s);return function(t){t.chrome="chrome",t.browser="browser"}(a||(a={})),function(t){var e=t.createStore,r=t.namespace,n=t.chromeNs,o=t.browserNs,s=t.changeListener,f=t.errorListener,h=t.storageArea,p=t.storageKey,l=t.bufferLife;if("function"!=typeof e)throw Error("Missing 'createStore' property/option");var y=o||r===a.browser?new u({namespace:o||browser,area:h,key:p}):new c({namespace:n||chrome,area:h,key:p});return y.init(),"function"==typeof f&&y.subscribeForError(f),function(t,r,n){if("function"!=typeof t)throw Error("Missing 'reducer' parameter");if("function"==typeof r&&"function"==typeof n)throw Error("Multiple 'enhancer' parameters unallowed");"function"==typeof r&&void 0===n&&(n=r,r=void 0);var o=new i({createStore:e,storage:y,bufferLife:l,reducer:t,initialState:r,enhancer:n});return"function"!=typeof s?o.init():(y.subscribe((function(t,e){s(o.initFrom(t),e)})),o.uninit())}}}));
{
"name": "reduxed-chrome-storage",
"version": "2.4.7",
"version": "2.4.8",
"description": "Redux-compatible interface to chrome.storage. Unified way to use Redux in all modern browser extensions. The only way to get Redux working in Manifest V3 Chrome extensions",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc