Socket
Socket
Sign inDemoInstall

reusable

Package Overview
Dependencies
38
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha.13 to 1.0.0-alpha.14

CHANGELOG.md

2

dist/index.js

@@ -1,2 +0,2 @@

var t=require("react"),e=function(t){this.fn=t,this.name="Store",this.subscribers=[],this.cachedValue=null};e.prototype.getValue=function(){return this.cachedValue},e.prototype.run=function(){return this.cachedValue=this.fn(),this.cachedValue},e.prototype.subscribe=function(t){var e=this;return this.subscribers=this.subscribers.concat([t]),function(){e.subscribers=e.subscribers.filter(function(e){return e!==t})}},e.prototype.notify=function(){var t=this;this.subscribers.forEach(function(e){return e(t.cachedValue)})};var r=function(){this.stores=new Map,this.subscribers=[]};r.prototype.onStoresChanged=function(t){var e=this;return this.subscribers=this.subscribers.concat([t]),function(){e.subscribers=e.subscribers.filter(function(e){return e!==t})}},r.prototype.createStore=function(t){if(this.stores.has(t))throw new Error("Store already exist");var r=new e(t);this.stores.set(t,r),this.notifyStoresChanged()},r.prototype.getStore=function(t){if(!this.stores.has(t))throw new Error("Store doesn't exist");return this.stores.get(t)},r.prototype.notifyStoresChanged=function(){this.subscribers.forEach(function(t){return t()})},r.prototype.getStoresArray=function(){var t=[];return this.stores.forEach(function(e){t.push(e)}),t};var n=new r,o=function(){return n},u=Object.prototype.hasOwnProperty;function s(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function i(t,e){if(s(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!u.call(e,r[o])||!s(t[r[o]],e[r[o]]))return!1;return!0}var c=t.createContext(null),a=function(){var e=t.useContext(c);if(null===e)throw new Error("Are you trying to use Reusable without a ReusableProvider?");return e},f=function(){var e=a(),r=t.useState(function(){return e.getStoresArray()}),n=r[0],o=r[1];return t.useEffect(function(){return e.onStoresChanged(function(){o(e.getStoresArray())})},[]),t.createElement(t.Fragment,null,n.map(function(e,r){var n,o=(n=function(e){var r=e.store;return r.run(),t.useDebugValue(r.name),t.useEffect(function(){return r.notify()},[r.cachedValue]),null},Object.defineProperty(n,"name",{value:e.name}),n);return t.createElement(o,{key:r,store:e})}))},h=function(t){return t};exports.Store=e,exports.Container=r,exports.createContainer=function(){return new r},exports.getContainer=o,exports.replaceContainer=function(t){return n=t},exports.ReusableProvider=function(e){var r=e.children;return t.createElement(c.Provider,{value:o()},t.createElement(t.Fragment,null,t.createElement(f,null),r))},exports.createStore=function(e){return o().createStore(e),function(r,n){return function(e,r,n){void 0===r&&(r=h),void 0===n&&(n=i);var o=a().getStore(e),u=t.useState(function(){return r(o.getValue())}),s=u[0],c=u[1];return t.useEffect(function(){return o.subscribe(function(t){var e=r(t);n(e,s)||c(function(){return e})})},[o,s,r,n]),s}(e,r,n)}};
var e=require("react"),t=function(e){this.fn=e,this.name="Store",this.subscribers=[],this.cachedValue=null};t.prototype.getValue=function(){return this.cachedValue},t.prototype.run=function(){return this.cachedValue=this.fn(),this.cachedValue},t.prototype.subscribe=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},t.prototype.notify=function(){var e=this;this.subscribers.forEach(function(t){return t(e.cachedValue)})};var r=function(){this.stores=new Map,this.subscribers=[]};r.prototype.onStoresChanged=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},r.prototype.createStore=function(e){if(this.stores.has(e))throw new Error("Store already exist");var r=new t(e);this.stores.set(e,r),this.notifyStoresChanged()},r.prototype.getStore=function(e){if(!this.stores.has(e))throw new Error("Store doesn't exist");return this.stores.get(e)},r.prototype.notifyStoresChanged=function(){this.subscribers.forEach(function(e){return e()})},r.prototype.getStoresArray=function(){var e=[];return this.stores.forEach(function(t){e.push(t)}),e};var n=new r,o=function(){return n},u=Object.prototype.hasOwnProperty;function s(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function i(e,t){if(s(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!u.call(t,r[o])||!s(e[r[o]],t[r[o]]))return!1;return!0}var c=e.createContext(null),a=function(t){var r=t.children;return e.createElement(c.Provider,{value:o()},e.createElement(e.Fragment,null,e.createElement(l,null),r))};Object.defineProperty(a,"displayName",{value:"ReusableProvider"});var f=function(){var t=e.useContext(c);if(null===t)throw new Error("Are you trying to use Reusable without a ReusableProvider?");return t},l=function(){var t=f(),r=e.useState(function(){return t.getStoresArray()}),n=r[0],o=r[1];return e.useEffect(function(){return t.onStoresChanged(function(){o(t.getStoresArray())})},[]),e.createElement(e.Fragment,null,n.map(function(t,r){var n,o=(n=function(t){var r=t.store;return r.run(),e.useDebugValue(r.name),e.useEffect(function(){return r.notify()},[r.cachedValue]),null},Object.defineProperty(n,"name",{value:t.name}),n);return e.createElement(o,{key:r,store:t})}))};Object.defineProperty(l,"displayName",{value:"Stores"});var h=function(e){return e};exports.Store=t,exports.Container=r,exports.createContainer=function(){return new r},exports.getContainer=o,exports.replaceContainer=function(e){return n=e},exports.ReusableProvider=a,exports.createStore=function(t){return o().createStore(t),function(r,n){return function(t,r,n){void 0===r&&(r=h),void 0===n&&(n=i);var o=f().getStore(t),u=e.useState(function(){return r(o.getValue())}),s=u[0],c=u[1];return e.useEffect(function(){return o.subscribe(function(e){var t=r(e);n(t,s)||c(function(){return t})})},[o,s,r,n]),s}(t,r,n)}};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.reusable={},e.react)}(this,function(e,t){var r=function(e){this.fn=e,this.name="Store",this.subscribers=[],this.cachedValue=null};r.prototype.getValue=function(){return this.cachedValue},r.prototype.run=function(){return this.cachedValue=this.fn(),this.cachedValue},r.prototype.subscribe=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},r.prototype.notify=function(){var e=this;this.subscribers.forEach(function(t){return t(e.cachedValue)})};var n=function(){this.stores=new Map,this.subscribers=[]};n.prototype.onStoresChanged=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},n.prototype.createStore=function(e){if(this.stores.has(e))throw new Error("Store already exist");var t=new r(e);this.stores.set(e,t),this.notifyStoresChanged()},n.prototype.getStore=function(e){if(!this.stores.has(e))throw new Error("Store doesn't exist");return this.stores.get(e)},n.prototype.notifyStoresChanged=function(){this.subscribers.forEach(function(e){return e()})},n.prototype.getStoresArray=function(){var e=[];return this.stores.forEach(function(t){e.push(t)}),e};var o=new n,u=function(){return o},i=Object.prototype.hasOwnProperty;function s(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function c(e,t){if(s(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!i.call(t,r[o])||!s(e[r[o]],t[r[o]]))return!1;return!0}var a=t.createContext(null),f=function(){var e=t.useContext(a);if(null===e)throw new Error("Are you trying to use Reusable without a ReusableProvider?");return e},h=function(){var e=f(),r=t.useState(function(){return e.getStoresArray()}),n=r[0],o=r[1];return t.useEffect(function(){return e.onStoresChanged(function(){o(e.getStoresArray())})},[]),t.createElement(t.Fragment,null,n.map(function(e,r){var n,o=(n=function(e){var r=e.store;return r.run(),t.useDebugValue(r.name),t.useEffect(function(){return r.notify()},[r.cachedValue]),null},Object.defineProperty(n,"name",{value:e.name}),n);return t.createElement(o,{key:r,store:e})}))},l=function(e){return e};e.Store=r,e.Container=n,e.createContainer=function(){return new n},e.getContainer=u,e.replaceContainer=function(e){return o=e},e.ReusableProvider=function(e){var r=e.children;return t.createElement(a.Provider,{value:u()},t.createElement(t.Fragment,null,t.createElement(h,null),r))},e.createStore=function(e){return u().createStore(e),function(r,n){return function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=c);var o=f().getStore(e),u=t.useState(function(){return r(o.getValue())}),i=u[0],s=u[1];return t.useEffect(function(){return o.subscribe(function(e){var t=r(e);n(t,i)||s(function(){return t})})},[o,i,r,n]),i}(e,r,n)}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.reusable={},e.react)}(this,function(e,t){var r=function(e){this.fn=e,this.name="Store",this.subscribers=[],this.cachedValue=null};r.prototype.getValue=function(){return this.cachedValue},r.prototype.run=function(){return this.cachedValue=this.fn(),this.cachedValue},r.prototype.subscribe=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},r.prototype.notify=function(){var e=this;this.subscribers.forEach(function(t){return t(e.cachedValue)})};var n=function(){this.stores=new Map,this.subscribers=[]};n.prototype.onStoresChanged=function(e){var t=this;return this.subscribers=this.subscribers.concat([e]),function(){t.subscribers=t.subscribers.filter(function(t){return t!==e})}},n.prototype.createStore=function(e){if(this.stores.has(e))throw new Error("Store already exist");var t=new r(e);this.stores.set(e,t),this.notifyStoresChanged()},n.prototype.getStore=function(e){if(!this.stores.has(e))throw new Error("Store doesn't exist");return this.stores.get(e)},n.prototype.notifyStoresChanged=function(){this.subscribers.forEach(function(e){return e()})},n.prototype.getStoresArray=function(){var e=[];return this.stores.forEach(function(t){e.push(t)}),e};var o=new n,u=function(){return o},i=Object.prototype.hasOwnProperty;function s(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function c(e,t){if(s(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!i.call(t,r[o])||!s(e[r[o]],t[r[o]]))return!1;return!0}var a=t.createContext(null),f=function(e){var r=e.children;return t.createElement(a.Provider,{value:u()},t.createElement(t.Fragment,null,t.createElement(h,null),r))};Object.defineProperty(f,"displayName",{value:"ReusableProvider"});var l=function(){var e=t.useContext(a);if(null===e)throw new Error("Are you trying to use Reusable without a ReusableProvider?");return e},h=function(){var e=l(),r=t.useState(function(){return e.getStoresArray()}),n=r[0],o=r[1];return t.useEffect(function(){return e.onStoresChanged(function(){o(e.getStoresArray())})},[]),t.createElement(t.Fragment,null,n.map(function(e,r){var n,o=(n=function(e){var r=e.store;return r.run(),t.useDebugValue(r.name),t.useEffect(function(){return r.notify()},[r.cachedValue]),null},Object.defineProperty(n,"name",{value:e.name}),n);return t.createElement(o,{key:r,store:e})}))};Object.defineProperty(h,"displayName",{value:"Stores"});var b=function(e){return e};e.Store=r,e.Container=n,e.createContainer=function(){return new n},e.getContainer=u,e.replaceContainer=function(e){return o=e},e.ReusableProvider=f,e.createStore=function(e){return u().createStore(e),function(r,n){return function(e,r,n){void 0===r&&(r=b),void 0===n&&(n=c);var o=l().getStore(e),u=t.useState(function(){return r(o.getValue())}),i=u[0],s=u[1];return t.useEffect(function(){return o.subscribe(function(e){var t=r(e);n(t,i)||s(function(){return t})})},[o,i,r,n]),i}(e,r,n)}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "reusable",
"version": "1.0.0-alpha.13",
"version": "1.0.0-alpha.14",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc