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

@libre/atom

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libre/atom - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

12

dist/index.esm.js

@@ -41,5 +41,5 @@ let nextAtomUid = 0;

/** @ignore */
function _runChangeHandlers(atom) {
function _runChangeHandlers(atom, previous, current) {
Object.keys(changeHandlersByAtomId[atom["$$id"]]).forEach(k => {
changeHandlersByAtomId[atom["$$id"]][k](_getState(atom));
changeHandlersByAtomId[atom["$$id"]][k]({ previous, current });
});

@@ -216,4 +216,5 @@ }

else {
const prevState = deref(atom);
_setState(atom, nextState);
_runChangeHandlers(atom);
_runChangeHandlers(atom, prevState, nextState);
}

@@ -279,3 +280,4 @@ }

_throwIfNotAtom(atom);
const nextState = updateFn(_getState(atom));
const prevState = _getState(atom);
const nextState = updateFn(prevState);
const validator = _getValidator(atom);

@@ -291,3 +293,3 @@ const didValidate = validator(nextState);

_setState(atom, nextState);
_runChangeHandlers(atom);
_runChangeHandlers(atom, prevState, nextState);
}

@@ -294,0 +296,0 @@ }

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n["@libre/atom"]={})}(this,function(n){"use strict";var i=0,e=Object.create(null),r=Object.create(null),a={};function d(n){return e[n.$$id]}function u(n,t){e[n.$$id]=t}function f(n){return r[n.$$id]}function c(n,t){r[n.$$id]=t}function s(t){Object.keys(a[t.$$id]).forEach(function(n){a[t.$$id][n](d(t))})}var t="Expected an Atom instances, but got:";function l(n){return JSON.stringify(n,null," ")}function v(n){if(!(n instanceof o))throw TypeError(t+"\n\n"+l(n))}var o=function(){function e(n,t){var e=(void 0===t?{}:t).validator;if((e=e||function(){return!0})(n))return Object.defineProperty(this,"$$id",{value:i++}),u(this,n),c(this,e),a[this.$$id]={},this;var r="Atom initialized with invalid state:\n\n"+l(n)+"\n\naccording to validator function:\n"+e+"\n\n",o=Error(r);throw o.name="AtomInvalidStateError",o}return e.of=function(n,t){return new e(n,t)},e.prototype.toString=function(){return"Atom<"+l(d(this))+">"},e.prototype.inspect=function(){return this.toString()},e}();n.addChangeHandler=function(n,t,e){!function(n,t,e){if("function"==typeof a[n.$$id][t])throw new Error('Change handler already registered for key "'+t+'" on '+n+".\nRemove the existing handler before registering a new one.");a[n.$$id][t]=e}(n,t,e)},n.removeChangeHandler=function(n,t){var e;e=t,delete a[n.$$id][e]},n.Atom=o,n.deref=function(n){return v(n),d(n)},n.getValidator=function(n){return v(n),f(n)},n.set=function(n,t){v(n);var e=f(n);if(!e(t)){var r="Attempted to set the state of\n\n"+n+"\n\nwith:\n\n"+l(t)+"\n\nbut it did not pass validator:\n"+e+"\n\n",o=Error(r);throw o.name="AtomInvalidStateError",o}u(n,t),s(n)},n.setValidator=function(n,t){if(v(n),!t(d(n))){var e=Error("Could not set validator on\n\n"+n+"\n\nbecause current state would be invalid according to new validator:\n"+t+"\n\n");throw e.name="AtomInvalidStateError",e}c(n,t)},n.swap=function(n,t){v(n);var e=t(d(n)),r=f(n);if(!r(e)){var o="swap updateFn\n"+t+"\n\nattempted to swap the state of\n\n"+n+"\n\nwith:\n\n"+l(e)+"\n\nbut it did not pass validator:\n"+r+"\n\n",i=Error(o);throw i.name="AtomInvalidStateError",i}u(n,e),s(n)},Object.defineProperty(n,"__esModule",{value:!0})});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n["@libre/atom"]={})}(this,function(n){"use strict";var i=0,e=Object.create(null),r=Object.create(null),a={};function d(n){return e[n.$$id]}function u(n,t){e[n.$$id]=t}function f(n){return r[n.$$id]}function c(n,t){r[n.$$id]=t}function s(t,e,r){Object.keys(a[t.$$id]).forEach(function(n){a[t.$$id][n]({previous:e,current:r})})}var t="Expected an Atom instances, but got:";function l(n){return JSON.stringify(n,null," ")}function v(n){if(!(n instanceof o))throw TypeError(t+"\n\n"+l(n))}var o=function(){function e(n,t){var e=(void 0===t?{}:t).validator;if((e=e||function(){return!0})(n))return Object.defineProperty(this,"$$id",{value:i++}),u(this,n),c(this,e),a[this.$$id]={},this;var r="Atom initialized with invalid state:\n\n"+l(n)+"\n\naccording to validator function:\n"+e+"\n\n",o=Error(r);throw o.name="AtomInvalidStateError",o}return e.of=function(n,t){return new e(n,t)},e.prototype.toString=function(){return"Atom<"+l(d(this))+">"},e.prototype.inspect=function(){return this.toString()},e}();function h(n){return v(n),d(n)}n.addChangeHandler=function(n,t,e){!function(n,t,e){if("function"==typeof a[n.$$id][t])throw new Error('Change handler already registered for key "'+t+'" on '+n+".\nRemove the existing handler before registering a new one.");a[n.$$id][t]=e}(n,t,e)},n.removeChangeHandler=function(n,t){var e;e=t,delete a[n.$$id][e]},n.Atom=o,n.deref=h,n.getValidator=function(n){return v(n),f(n)},n.set=function(n,t){v(n);var e=f(n);if(!e(t)){var r="Attempted to set the state of\n\n"+n+"\n\nwith:\n\n"+l(t)+"\n\nbut it did not pass validator:\n"+e+"\n\n",o=Error(r);throw o.name="AtomInvalidStateError",o}var i=h(n);u(n,t),s(n,i,t)},n.setValidator=function(n,t){if(v(n),!t(d(n))){var e=Error("Could not set validator on\n\n"+n+"\n\nbecause current state would be invalid according to new validator:\n"+t+"\n\n");throw e.name="AtomInvalidStateError",e}c(n,t)},n.swap=function(n,t){v(n);var e=d(n),r=t(e),o=f(n);if(!o(r)){var i="swap updateFn\n"+t+"\n\nattempted to swap the state of\n\n"+n+"\n\nwith:\n\n"+l(r)+"\n\nbut it did not pass validator:\n"+o+"\n\n",a=Error(i);throw a.name="AtomInvalidStateError",a}u(n,r),s(n,e,r)},Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=index.umd.js.map

@@ -21,3 +21,6 @@ import { Atom } from "./atom";

*/
export declare function addChangeHandler<S>(atom: Atom<S>, key: string, handler: (state: S) => void): void;
export declare function addChangeHandler<S>(atom: Atom<S>, key: string, handler: (states: {
previous: S;
current: S;
}) => void): void;
/**

@@ -24,0 +27,0 @@ * Deletes the `key` and the handler associated with `key` so that it not longer runs

@@ -16,6 +16,9 @@ import { Atom } from "./atom";

/** @ignore */
export declare function _addChangeHandler<S>(atom: Atom<S>, key: string, handler: (state: S) => void): void;
export declare function _addChangeHandler<S>(atom: Atom<S>, key: string, handler: (states: {
previous: S;
current: S;
}) => void): void;
/** @ignore */
export declare function _removeChangeHandler<S>(atom: Atom<S>, key: string): void;
/** @ignore */
export declare function _runChangeHandlers<S>(atom: Atom<S>): void;
export declare function _runChangeHandlers<S>(atom: Atom<S>, previous: S, current: S): void;

@@ -92,3 +92,3 @@ {

"unpkg": "https://unpkg.com/@libre/atom",
"version": "1.2.0"
"version": "1.2.1"
}

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc