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

derivable

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

derivable - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.12.1
- Removed stray const declarations (thanks, @liron00)
## 0.12.0

@@ -2,0 +6,0 @@

4

dist/derivable.js

@@ -508,4 +508,4 @@ // UMD loader

return D.derivation(function () {
const deriver = f.get();
const thing = that.get();
var deriver = f.get();
var thing = that.get();
switch (typeof deriver) {

@@ -512,0 +512,0 @@ case 'function':

!function(t,n){"use strict";t&&"function"==typeof t.define&&t.define.amd?t.define(["exports"],n):n("undefined"!=typeof exports?exports:t.Derivable={})}(this,function(t){"use strict";function n(t){for(var n=1;n<arguments.length;n++)for(var e=arguments[n],r=nt(e),i=r.length;i--;){var a=r[i];t[a]=e[a]}return t}function e(t,n){return t===n?0!==t||1/t===1/n:t!==t&&n!==n}function r(t,n){return e(t,n)||t&&"function"==typeof t.equals&&t.equals(n)}function i(t,n){var e=t.indexOf(n);0>e&&t.push(n)}function a(t,n){var e=t.indexOf(n);e>=0&&t.splice(e,1)}function u(t,n){return t.indexOf(n)>=0}function o(){return et++}function c(t,n){return Array.prototype.slice.call(t,n)}function s(t){return null!==t&&void 0!==t}function f(t){it=!!t}function l(t,n){return t._equals=n,t}function h(t,n){if(t._type===dt){if(t.reacting)throw new Error("Cycle detected! Don't do this!");n.push(t)}else for(var e=t._children.length;e--;){var r=t._children[e];r._state!==st&&(r._state=st,h(r,n))}}function p(t){var n;switch(t._state){case ut:case ot:for(n=t._children.length;n--;){var e=t._children[n];p(e),e._state!==ft&&t._children.splice(n,1)}t._state=ft;break;case st:if(t._type===dt)t._state=ft;else{var r=[];for(n=t._parents.length;n--;){var i=t._parents[n];if(i._state!==ot){t._state=ct;break}r.push([i,i._value])}t._state!==ct&&(t._state=lt,t._parents=r)}break;case ft:case ct:case lt:break;default:throw new Error("can't sweep state "+t._state)}}function _(t){var n=!1;switch(t._type){case pt:t._state=ft,n=!0;break;case _t:case vt:t._state=at,t._value=rt,n=!0;break;case dt:t._state=ft,n=!1}if(n){for(var e=t._children.length;e--;)_(t._children[e]);t._children=[]}}function v(t){var n=ht.length;ht.push([]);try{return t(),ht[n]}finally{ht.pop()}}function d(t){ht.length>0&&i(ht[ht.length-1],t)}function g(){throw mt}function y(){return{currentTxn:null}}function w(t){return null!==t.currentTxn}function m(t){return t.currentTxn}function k(t,n){n._parent=t.currentTxn,n._state=gt,t.currentTxn=n}function b(t,n){var e=t.currentTxn;if(t.currentTxn=e._parent,e._state!==gt)throw new Error("unexpected state: "+e._state);
n(e)}function E(t){b(t,function(t){t._state=yt,t.onCommit&&t.onCommit()})}function x(t){b(t,function(t){t._state=wt,t.onAbort&&t.onAbort()})}function T(t,n,e){k(t,n);try{e(g)}catch(r){if(x(t),r!==mt)throw r;return}E(t)}function q(t,n){k(t,n());var e=!1;return{tick:function(){if(e)throw new Error("can't tick disposed ticker");E(t),k(t,n())},stop:function(){if(e)throw new Error("ticker already disposed");E(t)}}}function A(t,n){var e={control:n,parent:t,parentReactor:null,dependentReactors:[],_state:ft,active:!1,_type:dt,uid:o(),reacting:!1,yielding:!1};return it&&(e.stack=Error().stack),e}function O(t){t.active&&(a(t.parent._children,t),t.parentReactor&&R(t),t.active=!1,t.control.onStop&&t.control.onStop())}function D(t){if(!t.active){i(t.parent._children,t),t.active=!0,t.parent._get();var n=bt.length;n>0&&(t.parentReactor=bt[n-1]),t.control.onStart&&t.control.onStart()}}function R(t){t.parentReactor&&(t.parentReactor=null)}function V(t,n){n.parentReactor=t}function j(t){if(t.yielding)throw Error(kt);if(t.active&&t._state===st){if(null!==t.parentReactor)try{t.yielding=!0,j(t.parentReactor)}finally{t.yielding=!1}if(t.active){var n=t.parent,e=n._state;if((e===st||e===ct||e===lt||e===at)&&n._get(),e=n._state,e===ot)t._state=ft;else{if(e!==ut)throw new Error("invalid parent state: "+e);C(t)}}}}function C(t){if(!t.control.react)throw new Error("No reactor function available.");t._state=ft;try{if(t.reacting=!0,bt.push(t),it)try{t.control.react(t.parent._get())}catch(n){throw console.error(t.stack),n}else t.control.react(t.parent._get())}finally{bt.pop(),t.reacting=!1}}function S(){this._type=dt}function N(t,n){if(t._base)throw new Error("This reactor has already been initialized");return t._base=A(n,t),t}function F(t){this._type=dt,this.react=t}function G(t){return n(new S,t)}function z(t,n){var e={derive:function(n,e,r,i,a){var u=this;switch(arguments.length){case 0:return u;case 1:switch(typeof n){case"function":return t.derivation(function(){return n(u.get())});case"string":case"number":return t.derivation(function(){return u.get()[t.unpack(n)];
});default:if(n instanceof Array)return n.map(function(t){return u.derive(t)});if(n instanceof RegExp)return t.derivation(function(){return u.get().match(n)});if(t.isDerivable(n))return t.derivation(function(){const e=n.get(),r=u.get();switch(typeof e){case"function":return e(r);case"string":case"number":return r[e];default:if(e instanceof RegExp)return r.match(e);throw Error("type error")}return u.get()[t.unpack(n)]});throw Error("type error")}break;case 2:return t.derivation(function(){return n(u.get(),t.unpack(e))});case 3:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r))});case 4:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r),t.unpack(i))});case 5:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r),t.unpack(i),t.unpack(a))});default:var o=[u].concat(c(arguments,1));return t.derivation(function(){return n.apply(null,o.map(t.unpack))})}},reactor:function(t){if("function"==typeof t)return N(new F(t),this);if(t instanceof S)return N(t,this);if(t&&t.react)return N(G(t),this);throw new Error("Unrecognized type for reactor "+t)},react:function(n,e){function r(n,e){if(!t.isDerivable(n))if("function"==typeof n)n=t.derivation(n);else{if("boolean"!=typeof n)throw Error("react "+e+" condition must be derivable");n=t.atom(n)}return n.derive(function(t){return!!t})}if("function"!=typeof n)throw Error("the first argument to .react must be a function");e=Object.assign({once:!1,from:!0,until:!1,when:!0,skipFirst:!1},e);var i=this.reactor({react:function(t){e.skipFirst?e.skipFirst=!1:(n(t),e.once&&(this.stop(),a.stop()))},onStart:e.onStart,onStop:e.onStop}),a=t.struct({until:r(e.until,"until"),when:r(e.when,"when")}).reactor(function(t){t.until?(i.stop(),this.stop()):t.when?i.isActive()||i.start().force():i.isActive()&&i.stop()});r(e.from,"from").reactor(function(t){t&&(a.start().force(),this.stop())}).start().force()},get:function(){return d(this),this._get()},is:function(e){return t.lift(n.equals)(this,e)},and:function(n){return this.derive(function(e){return e&&t.unpack(n);
});default:if(n instanceof Array)return n.map(function(t){return u.derive(t)});if(n instanceof RegExp)return t.derivation(function(){return u.get().match(n)});if(t.isDerivable(n))return t.derivation(function(){var e=n.get(),r=u.get();switch(typeof e){case"function":return e(r);case"string":case"number":return r[e];default:if(e instanceof RegExp)return r.match(e);throw Error("type error")}return u.get()[t.unpack(n)]});throw Error("type error")}break;case 2:return t.derivation(function(){return n(u.get(),t.unpack(e))});case 3:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r))});case 4:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r),t.unpack(i))});case 5:return t.derivation(function(){return n(u.get(),t.unpack(e),t.unpack(r),t.unpack(i),t.unpack(a))});default:var o=[u].concat(c(arguments,1));return t.derivation(function(){return n.apply(null,o.map(t.unpack))})}},reactor:function(t){if("function"==typeof t)return N(new F(t),this);if(t instanceof S)return N(t,this);if(t&&t.react)return N(G(t),this);throw new Error("Unrecognized type for reactor "+t)},react:function(n,e){function r(n,e){if(!t.isDerivable(n))if("function"==typeof n)n=t.derivation(n);else{if("boolean"!=typeof n)throw Error("react "+e+" condition must be derivable");n=t.atom(n)}return n.derive(function(t){return!!t})}if("function"!=typeof n)throw Error("the first argument to .react must be a function");e=Object.assign({once:!1,from:!0,until:!1,when:!0,skipFirst:!1},e);var i=this.reactor({react:function(t){e.skipFirst?e.skipFirst=!1:(n(t),e.once&&(this.stop(),a.stop()))},onStart:e.onStart,onStop:e.onStop}),a=t.struct({until:r(e.until,"until"),when:r(e.when,"when")}).reactor(function(t){t.until?(i.stop(),this.stop()):t.when?i.isActive()||i.start().force():i.isActive()&&i.stop()});r(e.from,"from").reactor(function(t){t&&(a.start().force(),this.stop())}).start().force()},get:function(){return d(this),this._get()},is:function(e){return t.lift(n.equals)(this,e)},and:function(n){return this.derive(function(e){return e&&t.unpack(n);
})},or:function(n){return this.derive(function(e){return e||t.unpack(n)})},then:function(n,e){return this.derive(function(r){return t.unpack(r?n:e)})},mThen:function(n,e){return this.derive(function(r){return t.unpack(s(r)?n:e)})},mOr:function(t){return this.mThen(this,t)},mDerive:function(t){if(1===arguments.length&&t instanceof Array){var n=this;return t.map(function(t){return n.mDerive(t)})}return this.mThen(this.derive.apply(this,arguments))},mAnd:function(t){return this.mThen(t,this)},not:function(){return this.derive(function(t){return!t})},withEquality:function(t){if(t){if("function"!=typeof t)throw new Error("equals must be function")}else t=null;return l(this._clone(),t)}};return e["switch"]=function(){var e=arguments;return this.derive(function(r){var i;for(i=0;e.length-1>i;i+=2)if(n.equals(r,t.unpack(e[i])))return t.unpack(e[i+1]);return i===e.length-1?t.unpack(e[i]):void 0})},e}function I(t,n){return{_clone:function(){return l(t.derivation(this._deriver),this._equals)},_forceGet:function(){var t,e=this,r=v(function(){var t;if(it)try{t=e._deriver()}catch(r){throw console.error(e._stack),r}else t=e._deriver();var i=e._equals||n.equals;e._state=i(t,e._value)?ot:ut,e._value=t});for(t=this._parents.length;t--;){var o=this._parents[t];u(r,o)||a(o._children,this)}for(this._parents=r,t=r.length;t--;)i(r[t]._children,this)},_get:function(){var t,e;t:switch(this._state){case at:case ct:this._forceGet();break;case st:for(t=0;this._parents.length>t;t++){e=this._parents[t];var r=e._state;if((r===st||r===ct||r===lt)&&e._get(),r=e._state,r===ut){this._forceGet();break t}if(r!==ft&&r!==ot)throw new Error("invalid parent mode: "+r)}this._state=ot;break;case lt:var a=[];for(t=0;this._parents.length>t;t++){var u=this._parents[t],o=u[1];if(e=u[0],!n.equals(e._get(),o)){this._parents=[],this._forceGet();break t}a.push(e)}for(t=a.length;t--;)i(a[t]._children,this);this._parents=a,this._state=ot}return this._value}}}function Q(t,n){return t._children=[],t._parents=[],t._deriver=n,t._state=at,t._type=_t,t._value=rt,t._equals=null,

@@ -5,0 +5,0 @@ it&&(t._stack=Error().stack),t}function L(t,n){return{swap:function(t){var n=c(arguments,0);return n[0]=this.get(),this.set(t.apply(null,n))},lens:function(n){var e=this;return t.lens({get:function(){return n.get(e.get())},set:function(t){e.set(n.set(e.get(),t))}})}}}function M(t,n){return{_clone:function(){return l(t.lens(this._lensDescriptor),this._equals)},set:function(n){var e=this;return t.atomically(function(){e._lensDescriptor.set(n)}),this}}}function U(t,n){return t._lensDescriptor=n,t._type=vt,t}function B(t){for(var n=t.length;n--;)j(t[n])}function H(){return w(Et)}function J(){this.inTxnValues={},this.reactorQueue=[]}function K(t,n){var e=t.inTxnValues[n._uid];return e?e[1]:n._value}function P(t,n,e){t.inTxnValues[n._uid]=[n,e],h(n,t.reactorQueue)}function W(t,n){return{_clone:function(){return l(t.atom(this._value),this._equals)},withValidator:function(t){if(null===t)return this._clone();if("function"==typeof t){var n=this._clone(),e=this._validator;return n._validator=e?function(n){return t(n)&&e(n)}:t,n}throw new Error(".withValidator expects function or null")},validate:function(){this._validate(this.get())},_validate:function(t){var n=this._validator&&this._validator(t);if(this._validator&&n!==!0)throw new Error("Failed validation with value: '"+t+"'. Validator returned '"+n+"' ")},set:function(t){this._validate(t);var e=this._equals||n.equals;if(!e(t,this._value))if(this._state=ut,H())P(m(Et),this,t);else{this._value=t;var r=[];h(this,r),B(r),p(this)}return this},_get:function(){return H()?K(m(Et),this):this._value}}}function X(t,n){return t._uid=o(),t._children=[],t._state=ft,t._value=n,t._type=pt,t._equals=null,t}function Y(t){T(Et,new J,t)}function Z(t){return function(){var n,e=c(arguments,0),r=this;return Y(function(){n=t.apply(r,e)}),n}}function $(){Tt?Tt.refCount++:(Tt=q(Et,function(){return new J}),Tt.refCount=1);var t=!1;return{tick:function(){if(t)throw new Error("tyring to use ticker after release");Tt.tick()},release:function(){if(t)throw new Error("ticker already released");0===--Tt.refCount&&(Tt.stop(),

{
"name": "derivable",
"version": "0.12.0",
"version": "0.12.1",
"description": "Functional Reactive State for JavaScript & TypeScript",

@@ -5,0 +5,0 @@ "author": "David Sheldrick",

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