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.6.0 to 2.7.0

11

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

@@ -147,6 +147,7 @@ * Copyright (c) Savr Goryaev aka hindmost

this.lastState = state;
// as we already catched the 1st effective state change, we don't need this listener and lastStore anymore,
// so we unsubscribe the former and reset the latter in order to release the related resources
unsubscribe();
lastStore = null;
// unsubscribe this listener and reset the lastStore in order to release the related resources
setTimeout(() => {
unsubscribe();
lastStore = null;
}, this.buffLife);
});

@@ -153,0 +154,0 @@ return lastStore.dispatch(action);

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

@@ -169,6 +169,7 @@ * Copyright (c) Savr Goryaev aka hindmost

this$1$1.lastState = state;
// as we already catched the 1st effective state change, we don't need this listener and lastStore anymore,
// so we unsubscribe the former and reset the latter in order to release the related resources
unsubscribe();
lastStore = null;
// unsubscribe this listener and reset the lastStore in order to release the related resources
setTimeout(function () {
unsubscribe();
lastStore = null;
}, this$1$1.buffLife);
});

@@ -175,0 +176,0 @@ return lastStore.dispatch(action);

/**
* @license
* ReduxedChromeStorage v2.6.0
* ReduxedChromeStorage v2.7.0
* 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(t){return null==t||"object"!=typeof t?t:JSON.parse(JSON.stringify(t))}function e(t,r){if(t===r)return!0;if(null==t||"object"!=typeof t||null==r||"object"!=typeof r||Array.isArray(t)!==Array.isArray(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.getState=this.getState.bind(this),this.dispatch=this.dispatch.bind(this),this.subscribe=this.subscribe.bind(this),this[Symbol.observable]=this[Symbol.observable].bind(this),this.replaceReducer=this.replaceReducer.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._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={createStore:e,storage:y,bufferLife:l,reducer:t,initialState:r,enhancer:n};return"function"==typeof s?(y.subscribe((function(t,e){var r=new i(o);s(r.initFrom(t),e)})),new Promise((function(t){t(e((function(t){return t})))}))):new i(o).init()}}}));
!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(t){return null==t||"object"!=typeof t?t:JSON.parse(JSON.stringify(t))}function e(t,r){if(t===r)return!0;if(null==t||"object"!=typeof t||null==r||"object"!=typeof r||Array.isArray(t)!==Array.isArray(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.getState=this.getState.bind(this),this.dispatch=this.dispatch.bind(this),this.subscribe=this.subscribe.bind(this),this[Symbol.observable]=this[Symbol.observable].bind(this),this.replaceReducer=this.replaceReducer.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._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,setTimeout((function(){i(),n=null}),r.buffLife))}));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={createStore:e,storage:y,bufferLife:l,reducer:t,initialState:r,enhancer:n};return"function"==typeof s?(y.subscribe((function(t,e){var r=new i(o);s(r.initFrom(t),e)})),new Promise((function(t){t(e((function(t){return t})))}))):new i(o).init()}}}));
{
"name": "reduxed-chrome-storage",
"version": "2.6.0",
"version": "2.7.0",
"description": "Redux 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