Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amos

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amos - npm Package Compare versions

Comparing version 0.2.11 to 0.2.12

2

dist/amos.cjs.js

@@ -662,3 +662,3 @@ 'use strict';

*/
var VERSION = '0.2.11';
var VERSION = '0.2.12';

@@ -665,0 +665,0 @@ exports.Box = Box;

@@ -654,5 +654,5 @@ import { __spread, __assign, __values, __read } from 'tslib';

*/
var VERSION = '0.2.11';
var VERSION = '0.2.12';
export { Box, Consumer, Provider, VERSION, action, arrayEqual, createStore, hoistMethod, identity, isAmosObject, selector, shallowEqual, signal, useDispatch, useSelector, useStore };
//# sourceMappingURL=amos.es.js.map

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

!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).Amos={},r.React)}(this,(function(r,e){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n=t(e),o=function(){function r(r,e,t){this.key=r,this.initialState=e,this.preload=t,this.listeners={}}return r.prototype.subscribe=function(r,e){this.listeners["string"==typeof r?r:r.type]=e},r.prototype.mutation=function(r,e){var t=this;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"mutation",type:e,box:t,args:n,result:n[0],mutator:r}}},r}(),u=function(r){return r};var i="function"==typeof Symbol?Symbol("AMOS_OBJECT"):"Symbol(AMOS_OBJECT)";function s(r,e){return e.hasOwnProperty(i)||Object.defineProperty(e,i,{value:r}),e}function a(r,e){return!!e&&e[i]===r}function c(r,e){return r===e}function f(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}var l=Array.isArray;function p(r){return Object.assign(this,{options:r})}var y=function(){return(y=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function d(r){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,u=t.call(r),i=[];try{for(;(void 0===e||e-- >0)&&!(n=u.next()).done;)i.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=u.return)&&t.call(u)}finally{if(o)throw o.error}}return i}function h(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(v(arguments[e]));return r}var g=e.createContext(null);function b(){var r=e.useContext(g);if(!r)throw new Error("[Amos] you are using hooks without <Provider />.");return r.store}var O={selectors:[],deps:[],snapshots:[],results:[]};function m(r,e){for(var t in r)if(r.hasOwnProperty(t)&&e.hasOwnProperty(t))return!0;return!1}function w(r,e,t,n){var o,u;if(!(null===(u=r.factory)||void 0===u?void 0:u.deps)||!t[n])return!0;var i=(o=r.factory).deps.apply(o,h([e.select],r.args)),s=f(t[n]||[],i);return t[n]=i,!s}function j(r,e,t){return r.factory?r.factory.compare(e,t):c(e,t)}function P(r,e,t,n,o){var u,i;if(!(r&&"function"==typeof r&&t&&r.args&&e.args))return!0;if(!(r===e||e.factory&&e.factory===r.factory))return!0;if(void 0===(null===(i=e.factory)||void 0===i?void 0:i.deps))return!f(r.args,e.args);var s=(u=e.factory).deps.apply(u,h([n.select],e.args));return!f(o||[],s)&&s}r.Box=o,r.Consumer=function(r){var e=r.children;return n.default.createElement(g.Consumer,null,(function(r){if(!r)throw new Error("[Amos] <Consumer /> should use inside <Provider />.");return e(r.store)}))},r.Provider=function(r){var t=r.store,o=r.children,u=v(e.useState({store:t}),2),i=u[0],s=u[1];return e.useEffect((function(){i.store!==t&&s({store:t})}),[t]),n.default.createElement(g.Provider,{value:i},o)},r.VERSION="0.2.11",r.action=function(r,e){var t=Object.assign((function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"action",type:e,args:n,actor:r,options:t.options}}),{type:e,options:{},config:p});return t},r.arrayEqual=f,r.createStore=function(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n,o={},u=[],i=[],a=function(e){if(!o.hasOwnProperty(e.key)){var t=e.initialState;(null==r?void 0:r.hasOwnProperty(e.key))&&(t=e.preload(r[e.key],t)),o[e.key]=t,u.push(e)}},c=0,f={},p=function(r,e){(e!==o[r]||f.hasOwnProperty(r))&&(f[r]=e,o[r]=e)},v=function(r){var e,t;switch(r.object){case"action":return r.actor.apply(r,h([g.dispatch,g.select],r.args));case"mutation":return a(r.box),p(r.box.key,r.mutator.apply(r,h([o[r.box.key]],r.args))),r.result;case"signal":try{for(var n=d(u),i=n.next();!i.done;i=n.next()){var s=i.value,c=s.listeners[r.type];c&&p(s.key,c(o[s.key],r.data))}}catch(r){e={error:r}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r.data}},g={snapshot:function(){return o},subscribe:function(r){return i.push(r),function(){var e=i.indexOf(r);e>-1&&i.splice(e,1)}},dispatch:s("store.dispatch",(function(r){1==++c&&(f={});try{return l(r)?r.map(v):v(r)}finally{if(0==--c&&Object.keys(f).length>0){var e=y({},f);h(i).forEach((function(r){return r(e)}))}}})),select:s("store.select",(function(r,e){if("function"!=typeof r)return a(r),n&&(n[r.key]=o[r.key]),o[r.key];if(!e)return r(g.select);if(n)throw new Error("[Amos] recursive snapshot collection is not supported.");n=e;try{return r(g.select)}finally{n=void 0}}))};return g=e.reduce((function(r,e){return e(r)}),g),"object"==typeof process&&"development"===process.env.NODE_ENV&&Object.freeze(g),g},r.hoistMethod=function(r,e){var t,n=function(t){e.hasOwnProperty(t)||Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))};return Object.getOwnPropertyNames(r).forEach(n),null===(t=Object.getOwnPropertySymbols)||void 0===t||t.call(Object,r).forEach(n),e},r.identity=u,r.isAmosObject=a,r.selector=function(r,e,t,n){void 0===t&&(t=c);var o=Object.assign((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0];if(a("store.select",n))return r.apply(void 0,h(e));var u=function(t){return r.apply(void 0,h([t],e))};return u.factory=o,u.args=e,u}),{deps:e,compare:t,type:n});return o},r.shallowEqual=function(r,e){if(r===e)return!0;var t=Object.keys(r);if(t.length!==Object.keys(e).length)return!1;for(var n=0;n<t.length;n++)if(!e.hasOwnProperty(t[n])||r[t[n]]!==e[t[n]])return!1;return!0},r.signal=function(r,e){return void 0===e&&(e=u),Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"signal",type:r,data:e.apply(void 0,h(t))}}),{type:r})},r.useDispatch=function(){return b().dispatch},r.useSelector=function(){for(var r,t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var u,i=v(e.useReducer((function(r){return r+1}),0),2),s=i[1],a=b(),c=e.useRef(O),f=e.useRef();if((null===(r=f.current)||void 0===r?void 0:r.store)!==a&&(c.current=O,null===(t=f.current)||void 0===t||t.disposer(),f.current={store:a,updated:!1,error:void 0,disposer:a.subscribe((function(r){var e,t=0,n=c.current,o=n.selectors,u=n.snapshots,i=n.results,l=n.deps,p=o.length;try{for(;t<p;t++){var y=o[t],d=u[t];if("function"==typeof y){if((!d||m(d,r))&&w(y,a,l,t)){var v={},h=a.select(y,v);(e=f.current).updated||(e.updated=!j(y,i[t],h)),u[t]=v,i[t]=h}}else if(r.hasOwnProperty(y.key)){var g=a.select(y);f.current.updated=g!==i[t],i[t]=g}}f.current.updated&&s()}catch(r){u.length=i.length=t,f.current.error="object"==typeof r&&r?Object.assign(r,{message:"[Amos] selector throws error: "+r.message}):new Error("[Amos] selector throws falsy error: "+r),s()}}))}),e.useEffect((function(){return function(){var r;return null===(r=f.current)||void 0===r?void 0:r.disposer()}}),[]),f.current.error){var l=f.current.error;throw f.current.error=void 0,l}if(f.current.updated)f.current.updated=!1,u=c.current.results;else{c.current===O&&(c.current={selectors:[],deps:[],snapshots:[],results:[]});for(var p=c.current,y=p.selectors,d=p.deps,h=p.snapshots,g=p.results,E=0;E<n.length;E++){var k=y[E],S=n[E];if("object"==typeof S)g[E]=a.select(S),y[E]=S;else{var x=P(k,S,h[E],a,d[E]);if(x){h[E]=void 0;var A={};g[E]=a.select(S,A),d[E]=!0===x?void 0:x,h[E]=A,y[E]=S}}}g.length=n.length,u=g}return e.useDebugValue(u,(function(r){return r.reduce((function(r,e,t){var o,u,i,s=n[t],a="function"==typeof s?null!==(i=null!==(o=s.type)&&void 0!==o?o:null===(u=s.factory)||void 0===u?void 0:u.type)&&void 0!==i?i:s.name:s.key;return a||(a="anonymous"),r.hasOwnProperty(a)&&(a=a+"_"+t),r[a]=e,r}),{})})),u},r.useStore=b,Object.defineProperty(r,"__esModule",{value:!0})}));
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).Amos={},r.React)}(this,(function(r,e){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n=t(e),o=function(){function r(r,e,t){this.key=r,this.initialState=e,this.preload=t,this.listeners={}}return r.prototype.subscribe=function(r,e){this.listeners["string"==typeof r?r:r.type]=e},r.prototype.mutation=function(r,e){var t=this;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"mutation",type:e,box:t,args:n,result:n[0],mutator:r}}},r}(),u=function(r){return r};var i="function"==typeof Symbol?Symbol("AMOS_OBJECT"):"Symbol(AMOS_OBJECT)";function s(r,e){return e.hasOwnProperty(i)||Object.defineProperty(e,i,{value:r}),e}function a(r,e){return!!e&&e[i]===r}function c(r,e){return r===e}function f(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}var l=Array.isArray;function p(r){return Object.assign(this,{options:r})}var y=function(){return(y=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function d(r){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,u=t.call(r),i=[];try{for(;(void 0===e||e-- >0)&&!(n=u.next()).done;)i.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=u.return)&&t.call(u)}finally{if(o)throw o.error}}return i}function h(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(v(arguments[e]));return r}var g=e.createContext(null);function b(){var r=e.useContext(g);if(!r)throw new Error("[Amos] you are using hooks without <Provider />.");return r.store}var O={selectors:[],deps:[],snapshots:[],results:[]};function m(r,e){for(var t in r)if(r.hasOwnProperty(t)&&e.hasOwnProperty(t))return!0;return!1}function w(r,e,t,n){var o,u;if(!(null===(u=r.factory)||void 0===u?void 0:u.deps)||!t[n])return!0;var i=(o=r.factory).deps.apply(o,h([e.select],r.args)),s=f(t[n]||[],i);return t[n]=i,!s}function j(r,e,t){return r.factory?r.factory.compare(e,t):c(e,t)}function P(r,e,t,n,o){var u,i;if(!(r&&"function"==typeof r&&t&&r.args&&e.args))return!0;if(!(r===e||e.factory&&e.factory===r.factory))return!0;if(void 0===(null===(i=e.factory)||void 0===i?void 0:i.deps))return!f(r.args,e.args);var s=(u=e.factory).deps.apply(u,h([n.select],e.args));return!f(o||[],s)&&s}r.Box=o,r.Consumer=function(r){var e=r.children;return n.default.createElement(g.Consumer,null,(function(r){if(!r)throw new Error("[Amos] <Consumer /> should use inside <Provider />.");return e(r.store)}))},r.Provider=function(r){var t=r.store,o=r.children,u=v(e.useState({store:t}),2),i=u[0],s=u[1];return e.useEffect((function(){i.store!==t&&s({store:t})}),[t]),n.default.createElement(g.Provider,{value:i},o)},r.VERSION="0.2.12",r.action=function(r,e){var t=Object.assign((function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"action",type:e,args:n,actor:r,options:t.options}}),{type:e,options:{},config:p});return t},r.arrayEqual=f,r.createStore=function(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n,o={},u=[],i=[],a=function(e){if(!o.hasOwnProperty(e.key)){var t=e.initialState;(null==r?void 0:r.hasOwnProperty(e.key))&&(t=e.preload(r[e.key],t)),o[e.key]=t,u.push(e)}},c=0,f={},p=function(r,e){(e!==o[r]||f.hasOwnProperty(r))&&(f[r]=e,o[r]=e)},v=function(r){var e,t;switch(r.object){case"action":return r.actor.apply(r,h([g.dispatch,g.select],r.args));case"mutation":return a(r.box),p(r.box.key,r.mutator.apply(r,h([o[r.box.key]],r.args))),r.result;case"signal":try{for(var n=d(u),i=n.next();!i.done;i=n.next()){var s=i.value,c=s.listeners[r.type];c&&p(s.key,c(o[s.key],r.data))}}catch(r){e={error:r}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r.data}},g={snapshot:function(){return o},subscribe:function(r){return i.push(r),function(){var e=i.indexOf(r);e>-1&&i.splice(e,1)}},dispatch:s("store.dispatch",(function(r){1==++c&&(f={});try{return l(r)?r.map(v):v(r)}finally{if(0==--c&&Object.keys(f).length>0){var e=y({},f);h(i).forEach((function(r){return r(e)}))}}})),select:s("store.select",(function(r,e){if("function"!=typeof r)return a(r),n&&(n[r.key]=o[r.key]),o[r.key];if(!e)return r(g.select);if(n)throw new Error("[Amos] recursive snapshot collection is not supported.");n=e;try{return r(g.select)}finally{n=void 0}}))};return g=e.reduce((function(r,e){return e(r)}),g),"object"==typeof process&&"development"===process.env.NODE_ENV&&Object.freeze(g),g},r.hoistMethod=function(r,e){var t,n=function(t){e.hasOwnProperty(t)||Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))};return Object.getOwnPropertyNames(r).forEach(n),null===(t=Object.getOwnPropertySymbols)||void 0===t||t.call(Object,r).forEach(n),e},r.identity=u,r.isAmosObject=a,r.selector=function(r,e,t,n){void 0===t&&(t=c);var o=Object.assign((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[0];if(a("store.select",n))return r.apply(void 0,h(e));var u=function(t){return r.apply(void 0,h([t],e))};return u.factory=o,u.args=e,u}),{deps:e,compare:t,type:n});return o},r.shallowEqual=function(r,e){if(r===e)return!0;var t=Object.keys(r);if(t.length!==Object.keys(e).length)return!1;for(var n=0;n<t.length;n++)if(!e.hasOwnProperty(t[n])||r[t[n]]!==e[t[n]])return!1;return!0},r.signal=function(r,e){return void 0===e&&(e=u),Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"signal",type:r,data:e.apply(void 0,h(t))}}),{type:r})},r.useDispatch=function(){return b().dispatch},r.useSelector=function(){for(var r,t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var u,i=v(e.useReducer((function(r){return r+1}),0),2),s=i[1],a=b(),c=e.useRef(O),f=e.useRef();if((null===(r=f.current)||void 0===r?void 0:r.store)!==a&&(c.current=O,null===(t=f.current)||void 0===t||t.disposer(),f.current={store:a,updated:!1,error:void 0,disposer:a.subscribe((function(r){var e,t=0,n=c.current,o=n.selectors,u=n.snapshots,i=n.results,l=n.deps,p=o.length;try{for(;t<p;t++){var y=o[t],d=u[t];if("function"==typeof y){if((!d||m(d,r))&&w(y,a,l,t)){var v={},h=a.select(y,v);(e=f.current).updated||(e.updated=!j(y,i[t],h)),u[t]=v,i[t]=h}}else if(r.hasOwnProperty(y.key)){var g=a.select(y);f.current.updated=g!==i[t],i[t]=g}}f.current.updated&&s()}catch(r){u.length=i.length=t,f.current.error="object"==typeof r&&r?Object.assign(r,{message:"[Amos] selector throws error: "+r.message}):new Error("[Amos] selector throws falsy error: "+r),s()}}))}),e.useEffect((function(){return function(){var r;return null===(r=f.current)||void 0===r?void 0:r.disposer()}}),[]),f.current.error){var l=f.current.error;throw f.current.error=void 0,l}if(f.current.updated)f.current.updated=!1,u=c.current.results;else{c.current===O&&(c.current={selectors:[],deps:[],snapshots:[],results:[]});for(var p=c.current,y=p.selectors,d=p.deps,h=p.snapshots,g=p.results,E=0;E<n.length;E++){var k=y[E],S=n[E];if("object"==typeof S)g[E]=a.select(S),y[E]=S;else{var x=P(k,S,h[E],a,d[E]);if(x){h[E]=void 0;var A={};g[E]=a.select(S,A),d[E]=!0===x?void 0:x,h[E]=A,y[E]=S}}}g.length=n.length,u=g}return e.useDebugValue(u,(function(r){return r.reduce((function(r,e,t){var o,u,i,s=n[t],a="function"==typeof s?null!==(i=null!==(o=s.type)&&void 0!==o?o:null===(u=s.factory)||void 0===u?void 0:u.type)&&void 0!==i?i:s.name:s.key;return a||(a="anonymous"),r.hasOwnProperty(a)&&(a=a+"_"+t),r[a]=e,r}),{})})),u},r.useStore=b,Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=amos.umd.js.map
{
"name": "amos",
"version": "0.2.11",
"version": "0.2.12",
"description": "A decentralized state manager for react",

@@ -120,3 +120,4 @@ "keywords": [

"endOfLine": "lf"
}
},
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
}
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