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

callbag-state

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

callbag-state - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

2

dist/bundles/callbag-state.es5.min.js

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

var callbagState=function(t){"use strict";function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t){return!t||!t.subs}function u(t,e,r){n(r).forEach((function(n){r.indexOf(n)>=0&&n(t,e)}))}function a(t){return null==t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t||t instanceof Date}function i(t,e){if(t!==e){if(!a(t)&&!a(e)){var n={subs:{}},r=new Set,o=!1;for(var u in t){r.add(u);var f=i(t[u],e[u]);f&&(n.subs[u]=f,o=!0)}for(var c in e)r.has(c)||(n.subs[c]=i(t[c],e[c]),o=!0);return o?n:void 0}return t instanceof Date&&e instanceof Date&&+t!=+e||t!==e?{from:t,to:e}:void 0}}function f(t){if(o(t.trace)&&t.trace){var e=i(t.trace.from,t.trace.to);if(e)return{value:t.value,trace:e}}return t}function c(t,n,r){var a=[],i=t,s=void 0;n(0,(function(t,e){if(0===t)s=e;else if(1===t){var n=f(e);n.value!==i&&(i=n.value),u(1,n,a)}else 2===t&&l(e)}));var l=function(t){u(2,t,a),a.length=0,s&&(s(2,t),s=void 0)},v=function(t,e){if(0===t){var n=e;a.push(n),n(0,(function(t){if(2===t){var e=a.indexOf(n);e>=0&&a.splice(e,1)}}))}},d=function(t,e){if(0===t){var n=e;v(0,(function(t,e){0===t?(n(0,e),n(1,i)):1===t?n(1,e.value):2===t&&n(2,e)}))}else 1===t?r(1,{value:e,trace:{from:i,to:e}}):2===t&&(r(2,e),l(e))};return d.get=function(){return i},d.set=function(t){return d(1,t)},d.clear=function(){return d(2)},d.downstream=function(){return v},d.upstream=function(){return r},d.sub=function(t){var n,u,a,f=c(i?i[t]:void 0,(n=v,u=t,a=function(){return f.get()},function(t,e){0===t&&n(0,(function(t,n){var r;if(1===t){var i=n,f=i.value?i.value[u]:void 0;(o(i.trace)&&f!==a()||!o(i.trace)&&u in(null===(r=i.trace)||void 0===r?void 0:r.subs))&&e(1,{value:f,trace:o(i.trace)?void 0:i.trace.subs[u]})}else e(t,n)}))}),function(t,n,r){return function(o,u){if(1===o){var a=u;r&&(r[n]=a.value),t(1,{value:r,trace:{subs:e({},n,a.trace)}})}else 2===o&&u&&t(2,u)}}(r,t,i));return f},d}function s(t){var e,n=(e=void 0,function(t,n){0===t?e||(e=n)(0,(function(t){2===t&&(e=void 0)})):e&&(e(t,n),2===t&&(e=void 0))});return c(t,n,n)}return t._Data=1,t._End=2,t._Start=0,t.broadcast=u,t.change=function(t,e){var n=i(t,e);if(n)return{value:e,trace:n}},t.default=s,t.isLeaf=o,t.isState=function(t){return t&&"function"==typeof t&&2===t.length&&t.get&&"function"==typeof t.get&&0===t.get.length&&t.set&&"function"==typeof t.set&&1===t.set.length&&t.clear&&"function"==typeof t.clear&&0===t.clear.length&&t.downstream&&"function"==typeof t.downstream&&0===t.downstream.length&&t.upstream&&"function"==typeof t.upstream&&0===t.upstream.length&&t.sub&&"function"==typeof t.sub&&1===t.sub.length},t.makeState=c,t.postTrace=f,t.state=s,t.trace=i,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
var callbagState=function(t){"use strict";function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t){return!t||!t.subs}function u(t,e,r){n(r).forEach((function(n){r.indexOf(n)>=0&&n(t,e)}))}function a(t){return null==t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t||t instanceof Date}function i(t,e){if(t!==e){if(!a(t)&&!a(e)){var n={subs:{}},r=new Set,o=!1;for(var u in t){r.add(u);var f=i(t[u],e[u]);f&&(n.subs[u]=f,o=!0)}for(var c in e)r.has(c)||(n.subs[c]=i(t[c],e[c]),o=!0);return o?n:void 0}return t instanceof Date&&e instanceof Date&&+t!=+e||t!==e?{from:t,to:e}:void 0}}function f(t){if(o(t.trace)&&t.trace){var e=i(t.trace.from,t.trace.to);if(e)return{value:t.value,trace:e}}return t}function c(t,n,r){var a=[],i=t,s=void 0,l=function(t){u(2,t,a),a.length=0,s&&(s(2,t),s=void 0)},v=function(t,e){if(0===t){var r=e;a.push(r),r(0,(function(t){if(2===t){var e=a.indexOf(r);e>=0&&a.splice(e,1),0===a.length&&l()}})),1===a.length&&n(0,(function(t,e){if(0===t)s=e;else if(1===t){var n=f(e);n.value!==i&&(i=n.value),u(1,n,a)}else 2===t&&l(e)}))}},d=function(t,e){if(0===t){var n=e;v(0,(function(t,e){0===t?(n(0,e),n(1,i)):1===t?n(1,e.value):2===t&&n(2,e)}))}else 1===t?r(1,{value:e,trace:{from:i,to:e}}):2===t&&(r(2,e),l(e))};return d.get=function(){return i},d.set=function(t){return d(1,t)},d.clear=function(){return d(2)},d.downstream=function(){return v},d.upstream=function(){return r},d.sub=function(t){var n,u,a,f=c(i?i[t]:void 0,(n=v,u=t,a=function(){return f.get()},function(t,e){0===t&&n(0,(function(t,n){var r;if(1===t){var i=n,f=i.value?i.value[u]:void 0;(o(i.trace)&&f!==a()||!o(i.trace)&&u in(null===(r=i.trace)||void 0===r?void 0:r.subs))&&e(1,{value:f,trace:o(i.trace)?void 0:i.trace.subs[u]})}else e(t,n)}))}),function(t,n,r){return function(o,u){if(1===o){var a=u;r&&(r[n]=a.value),t(1,{value:r,trace:{subs:e({},n,a.trace)}})}else 2===o&&u&&t(2,u)}}(r,t,i));return f},d}function s(t){var e,n=(e=void 0,function(t,n){0===t?e||(e=n)(0,(function(t){2===t&&(e=void 0)})):e&&(e(t,n),2===t&&(e=void 0))});return c(t,n,n)}return t._Data=1,t._End=2,t._Start=0,t.broadcast=u,t.change=function(t,e){var n=i(t,e);if(n)return{value:e,trace:n}},t.default=s,t.isLeaf=o,t.isState=function(t){return t&&"function"==typeof t&&2===t.length&&t.get&&"function"==typeof t.get&&0===t.get.length&&t.set&&"function"==typeof t.set&&1===t.set.length&&t.clear&&"function"==typeof t.clear&&0===t.clear.length&&t.downstream&&"function"==typeof t.downstream&&0===t.downstream.length&&t.upstream&&"function"==typeof t.upstream&&0===t.upstream.length&&t.sub&&"function"==typeof t.sub&&1===t.sub.length},t.makeState=c,t.postTrace=f,t.state=s,t.trace=i,Object.defineProperty(t,"__esModule",{value:!0}),t}({});

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

var callbagState=function(t){"use strict";function e(t){return!t||!t.subs}function n(t,e,n){[...n].forEach((o=>{n.indexOf(o)>=0&&o(t,e)}))}function o(t){return null==t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t||t instanceof Date}function r(t,e){if(t!==e){if(!o(t)&&!o(e)){const n={subs:{}},o=new Set;let a=!1;for(const u in t){o.add(u);const c=r(t[u],e[u]);c&&(n.subs[u]=c,a=!0)}for(const u in e)o.has(u)||(n.subs[u]=r(t[u],e[u]),a=!0);return a?n:void 0}return t instanceof Date&&e instanceof Date&&+t!=+e||t!==e?{from:t,to:e}:void 0}}function a(t){if(e(t.trace)&&t.trace){const e=r(t.trace.from,t.trace.to);if(e)return{value:t.value,trace:e}}return t}function u(t,o,r){const c=[];let s=t,i=void 0;o(0,((t,e)=>{if(0===t)i=e;else if(1===t){const t=a(e);t.value!==s&&(s=t.value),n(1,t,c)}else 2===t&&f(e)}));const f=t=>{n(2,t,c),c.length=0,i&&(i(2,t),i=void 0)},l=(t,e)=>{if(0===t){const t=e;c.push(t),t(0,(e=>{if(2===e){const e=c.indexOf(t);e>=0&&c.splice(e,1)}}))}},v=(t,e)=>{if(0===t){const t=e;l(0,((e,n)=>{0===e?(t(0,n),t(1,s)):1===e?t(1,n.value):2===e&&t(2,n)}))}else 1===t?r(1,{value:e,trace:{from:s,to:e}}):2===t&&(r(2,e),f(e))};return v.get=()=>s,v.set=t=>v(1,t),v.clear=()=>v(2),v.downstream=()=>l,v.upstream=()=>r,v.sub=t=>{const n=u(s?s[t]:void 0,(o=l,a=t,c=()=>n.get(),(t,n)=>{0===t&&o(0,((t,o)=>{var r;if(1===t){const t=o,u=t.value?t.value[a]:void 0;(e(t.trace)&&u!==c()||!e(t.trace)&&a in(null===(r=t.trace)||void 0===r?void 0:r.subs))&&n(1,{value:u,trace:e(t.trace)?void 0:t.trace.subs[a]})}else n(t,o)}))}),function(t,e,n){return(o,r)=>{if(1===o){const o=r;n&&(n[e]=o.value),t(1,{value:n,trace:{subs:{[e]:o.trace}}})}else 2===o&&r&&t(2,r)}}(r,t,s));var o,a,c;return n},v}function c(t){const e=function(){let t=void 0;return(e,n)=>{0===e?t||(t=n,t(0,(e=>{2===e&&(t=void 0)}))):t&&(t(e,n),2===e&&(t=void 0))}}();return u(t,e,e)}return t._Data=1,t._End=2,t._Start=0,t.broadcast=n,t.change=function(t,e){const n=r(t,e);if(n)return{value:e,trace:n}},t.default=c,t.isLeaf=e,t.isState=function(t){return t&&"function"==typeof t&&2===t.length&&t.get&&"function"==typeof t.get&&0===t.get.length&&t.set&&"function"==typeof t.set&&1===t.set.length&&t.clear&&"function"==typeof t.clear&&0===t.clear.length&&t.downstream&&"function"==typeof t.downstream&&0===t.downstream.length&&t.upstream&&"function"==typeof t.upstream&&0===t.upstream.length&&t.sub&&"function"==typeof t.sub&&1===t.sub.length},t.makeState=u,t.postTrace=a,t.state=c,t.trace=r,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
var callbagState=function(t){"use strict";function e(t){return!t||!t.subs}function n(t,e,n){[...n].forEach((o=>{n.indexOf(o)>=0&&o(t,e)}))}function o(t){return null==t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t||t instanceof Date}function r(t,e){if(t!==e){if(!o(t)&&!o(e)){const n={subs:{}},o=new Set;let a=!1;for(const u in t){o.add(u);const c=r(t[u],e[u]);c&&(n.subs[u]=c,a=!0)}for(const u in e)o.has(u)||(n.subs[u]=r(t[u],e[u]),a=!0);return a?n:void 0}return t instanceof Date&&e instanceof Date&&+t!=+e||t!==e?{from:t,to:e}:void 0}}function a(t){if(e(t.trace)&&t.trace){const e=r(t.trace.from,t.trace.to);if(e)return{value:t.value,trace:e}}return t}function u(t,o,r){const c=[];let s=t,i=void 0;const f=t=>{n(2,t,c),c.length=0,i&&(i(2,t),i=void 0)},l=(t,e)=>{if(0===t){const t=e;c.push(t),t(0,(e=>{if(2===e){const e=c.indexOf(t);e>=0&&c.splice(e,1),0===c.length&&f()}})),1===c.length&&o(0,((t,e)=>{if(0===t)i=e;else if(1===t){const t=a(e);t.value!==s&&(s=t.value),n(1,t,c)}else 2===t&&f(e)}))}},v=(t,e)=>{if(0===t){const t=e;l(0,((e,n)=>{0===e?(t(0,n),t(1,s)):1===e?t(1,n.value):2===e&&t(2,n)}))}else 1===t?r(1,{value:e,trace:{from:s,to:e}}):2===t&&(r(2,e),f(e))};return v.get=()=>s,v.set=t=>v(1,t),v.clear=()=>v(2),v.downstream=()=>l,v.upstream=()=>r,v.sub=t=>{const n=u(s?s[t]:void 0,(o=l,a=t,c=()=>n.get(),(t,n)=>{0===t&&o(0,((t,o)=>{var r;if(1===t){const t=o,u=t.value?t.value[a]:void 0;(e(t.trace)&&u!==c()||!e(t.trace)&&a in(null===(r=t.trace)||void 0===r?void 0:r.subs))&&n(1,{value:u,trace:e(t.trace)?void 0:t.trace.subs[a]})}else n(t,o)}))}),function(t,e,n){return(o,r)=>{if(1===o){const o=r;n&&(n[e]=o.value),t(1,{value:n,trace:{subs:{[e]:o.trace}}})}else 2===o&&r&&t(2,r)}}(r,t,s));var o,a,c;return n},v}function c(t){const e=function(){let t=void 0;return(e,n)=>{0===e?t||(t=n,t(0,(e=>{2===e&&(t=void 0)}))):t&&(t(e,n),2===e&&(t=void 0))}}();return u(t,e,e)}return t._Data=1,t._End=2,t._Start=0,t.broadcast=n,t.change=function(t,e){const n=r(t,e);if(n)return{value:e,trace:n}},t.default=c,t.isLeaf=e,t.isState=function(t){return t&&"function"==typeof t&&2===t.length&&t.get&&"function"==typeof t.get&&0===t.get.length&&t.set&&"function"==typeof t.set&&1===t.set.length&&t.clear&&"function"==typeof t.clear&&0===t.clear.length&&t.downstream&&"function"==typeof t.downstream&&0===t.downstream.length&&t.upstream&&"function"==typeof t.upstream&&0===t.upstream.length&&t.sub&&"function"==typeof t.sub&&1===t.sub.length},t.makeState=u,t.postTrace=a,t.state=c,t.trace=r,Object.defineProperty(t,"__esModule",{value:!0}),t}({});

@@ -12,17 +12,2 @@ "use strict";

var talkback = undefined;
downstream(types_1._Start, function (t, _m) {
if (t === types_1._Start) {
talkback = _m;
}
else if (t === types_1._Data) {
var change = trace_1.postTrace(_m);
if (change.value !== value) {
value = change.value;
}
broadcast_1.broadcast(types_1._Data, change, sinks);
}
else if (t === types_1._End) {
terminate(_m);
}
});
var terminate = function (err) {

@@ -46,4 +31,24 @@ broadcast_1.broadcast(types_1._End, err, sinks);

}
if (sinks.length === 0) {
terminate();
}
}
});
if (sinks.length === 1) {
downstream(types_1._Start, function (t, _m) {
if (t === types_1._Start) {
talkback = _m;
}
else if (t === types_1._Data) {
var change = trace_1.postTrace(_m);
if (change.value !== value) {
value = change.value;
}
broadcast_1.broadcast(types_1._Data, change, sinks);
}
else if (t === types_1._End) {
terminate(_m);
}
});
}
}

@@ -50,0 +55,0 @@ };

@@ -9,17 +9,2 @@ import { subDownstream, subUpstream } from './substream';

let talkback = undefined;
downstream(_Start, (t, _m) => {
if (t === _Start) {
talkback = _m;
}
else if (t === _Data) {
const change = postTrace(_m);
if (change.value !== value) {
value = change.value;
}
broadcast(_Data, change, sinks);
}
else if (t === _End) {
terminate(_m);
}
});
const terminate = (err) => {

@@ -43,4 +28,24 @@ broadcast(_End, err, sinks);

}
if (sinks.length === 0) {
terminate();
}
}
});
if (sinks.length === 1) {
downstream(_Start, (t, _m) => {
if (t === _Start) {
talkback = _m;
}
else if (t === _Data) {
const change = postTrace(_m);
if (change.value !== value) {
value = change.value;
}
broadcast(_Data, change, sinks);
}
else if (t === _End) {
terminate(_m);
}
});
}
}

@@ -47,0 +52,0 @@ };

{
"name": "callbag-state",
"version": "0.1.7",
"version": "0.1.8",
"description": "Callbag-based State Management",

@@ -13,2 +13,3 @@ "main": "dist/es5/index.js",

"pack": "rollup -c conf/rollup/es6.js && rollup -c conf/rollup/es5.js",
"cov:gen": "nyc npm run test",
"cov:view": "nyc npm run test && npm run cov:clean",

@@ -15,0 +16,0 @@ "cov:travis": "nyc npm run test && npx codecov",

# callbag-state
[![tests](https://img.shields.io/github/workflow/status/loreanvictor/callbag-state/Test%20and%20Report%20Coverage?label=tests&logo=mocha&logoColor=green&style=flat-square)](https://github.com/loreanvictor/callbag-state/actions?query=workflow%3A%22Test+and+Report+Coverage%22)
[![coverage](https://img.shields.io/codecov/c/github/loreanvictor/callbag-state?logo=codecov&style=flat-square)](https://codecov.io/gh/loreanvictor/callbag-state)
[![version](https://img.shields.io/npm/v/callbag-state?logo=npm&style=flat-square)](https://www.npmjs.com/package/callbag-state)
Callbag-based state management.

@@ -134,16 +138,14 @@ ```bash

⚠️⚠️ Don't forget to clear out states and sub-states by calling `.clear()` on them. A reference to
sub-states will remain inside states until they are cleared out, which can lead to memory leaks.
⚠️⚠️ States and sub-states don't track values unless they (or one of their sub-states) are subscribed to.
```ts
const s = state([1, 2, 3, 4]);
const one = state.sub(0); // --> pun intended
const s = state(42);
console.log(s.get()); // > 42
// ...
s.set(43);
console.log(s.get()); // > 42 !! --> not subscribed to
one.clear(); // --> when you are done with `one`
// ...
s.clear(); // --> when you are done with `s`
subscribe(() => ...)(s);
s.set(43);
console.log(s.get()); // > 43
```

@@ -150,0 +152,0 @@

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