Socket
Socket
Sign inDemoInstall

@effection/core

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effection/core - npm Package Compare versions

Comparing version 2.0.0-beta.0 to 2.0.0-beta.1

6

CHANGELOG.md
# @effection/core
## 2.0.0-beta.1
### Patch Changes
- 0c6e263: release 2.0.0-beta
## 2.0.0-preview.12

@@ -4,0 +10,0 @@

2

dist/core.cjs.development.js

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

var version = "2.0.0-beta.0";
var version = "2.0.0-beta.1";

@@ -964,0 +964,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

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

"use strict";var t=require("events");function r(){return(r=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r)}function e(t){return(e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,r){return(o=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function i(t,r,n){return(i=u()?Reflect.construct:function(t,r,n){var e=[null];e.push.apply(e,r);var u=new(Function.bind.apply(t,e));return n&&o(u,n.prototype),u}).apply(null,arguments)}function a(t){var r="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,n)}function n(){return i(t,arguments,e(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)})(t)}function c(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function f(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return c(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0;return function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var l=function(t){function r(){return t.call(this,"halted")||this}var e;return n(r,t),(e=[{key:"__isEffectionHaltError",get:function(){return!0}}])&&function(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}(r.prototype,e),r}(a(Error));function s(t){var r;if(!(r=t)||!r.__isEffectionHaltError)throw t}function p(){var t=!1,r=[];return{run:function(n){if(r.push(n),!t){t=!0;try{for(;;){var e=r.shift();if(!e)break;try{e()}catch(t){console.error("Caught error in run loop:"),console.error(t)}}}finally{t=!1}}}}}function h(){var t,r,n,e=p(),o=[];function u(t){o.push(t),e.run(i)}function i(){if(r)for(;;){var t=o.shift();if(!t)break;t(r)}}function a(){return n||(n=new Promise((function(t,r){u((function(n){"completed"===n.state?t(n.value):"errored"===n.state?r(n.error):"halted"===n.state&&r(new l)}))})))}return{resolve:function(t){r||(r=t,e.run(i))},future:(t={get state(){var t;return(null===(t=r)||void 0===t?void 0:t.state)||"pending"},consume:u,then:function(){var t;return(t=a()).then.apply(t,arguments)},catch:function(){var t;return(t=a()).catch.apply(t,arguments)},finally:function(){var t;return(t=a()).finally.apply(t,arguments)}},t[Symbol.toStringTag]="[continuation]",t)}}var v=Symbol.for("effection/v2/iterator-controller/claimed");function y(t,r,n){void 0===n&&(n={});var e,o=!1,u=h(),i=u.resolve,a=u.future,c=p();function f(r){c.run((function(){var u;try{u=r()}catch(t){return void i({state:"errored",error:t})}u.done?i(o?{state:"halted"}:{state:"completed",value:u.value}):((e=w(u.value,{resourceScope:n.resourceScope||t,ignoreError:!0})).consume(l),e.start())}))}function l(t){e=void 0,"completed"===t.state&&f((function(){return r.next(t.value)})),"errored"===t.state&&f((function(){return r.throw(t.error)})),"halted"===t.state&&f((function(){return r.return(void 0)}))}return{start:function(){if(r[v]){var t=new Error("An operation iterator can only be run once in a single task, but it looks like has been either yielded to, or run multiple times");t.name="DoubleEvalError",i({state:"errored",error:t})}else r[v]=!0,f((function(){return r.next()}))},halt:function(){o||(o=!0,e?e.halt():f((function(){return r.return(void 0)})))},future:a,type:"generator"}}function d(t){return JSON.stringify(t)}var m=function(){function t(t){this.emitter=t,this.current="pending"}var r=t.prototype;return r.transition=function(t,r){var n=this.current,e=r[n];if(!e){var o=Object.keys(r).map(d).join(", ");throw new Error("INTERNAL ERROR: state transition "+d(t)+" is not valid in current state "+d(n)+", should be one of "+o)}this.current=e,this.emitter.emit("state",{from:n,to:e})},r.start=function(){this.transition("start",{pending:"running"})},r.completing=function(){this.transition("completing",{running:"completing"})},r.erroring=function(){this.transition("erroring",{running:"erroring",completing:"erroring",halting:"erroring",erroring:"erroring"})},r.halting=function(){this.transition("halting",{running:"halting",completing:"halting",halting:"halting"})},r.finish=function(){this.transition("finish",{completing:"completed",erroring:"errored",halting:"halted"})},t}();function g(t,r){var n={id:r.id,type:r.type,labels:r.labels},e=Object.getOwnPropertyDescriptors(t);return e.effectionTrace={value:[].concat(t.effectionTrace||[],[n]),enumerable:!0},Object.create(Object.getPrototypeOf(t),e)}var b=0;function w(n,e){var o;void 0===e&&(e={});var u,i,a=++b,c=new Set,f=new t.EventEmitter,l=new m(f),v=h(),d=v.resolve,E=v.future,O=p(),j=r({},null==n?void 0:n.labels,e.labels);!j.name&&null!=n&&n.name&&(j.name=null==n?void 0:n.name);var x=((o={id:a,options:e,future:E,get labels(){return j},get state(){return l.current},get type(){return i.type},get children(){return Array.from(c)},catchHalt:function(){return E.catch(s)},setLabels:function(t){j=r({},j,t),f.emit("labels",j)},spawn:function(t,n){if(void 0===n&&(n={}),"running"!==l.current)throw new Error("cannot spawn a child on a task which is not running");var e=w(t,r({resourceScope:x},n));return S(e),e.start(),e},start:function(){"pending"===l.current&&(l.start(),i.start())},halt:function(){try{return"running"!==l.current&&"completing"!==l.current||(l.halting(),u={state:"halted"},P(!0)),Promise.resolve(E.catch((function(){}))).then((function(){}))}catch(t){return Promise.reject(t)}},on:function(){return f.on.apply(f,arguments)},off:function(){return f.off.apply(f,arguments)},then:function(){return E.then.apply(E,arguments)},catch:function(){return E.catch.apply(E,arguments)},finally:function(){return E.finally.apply(E,arguments)},consume:function(){return E.consume.apply(E,arguments)}})[Symbol.toStringTag]="[Task "+a+"]",o);function S(t){c.has(t)||(t.consume((function(r){"errored"!==r.state||t.options.ignoreError||e.ignoreChildErrors||(l.erroring(),u={state:"errored",error:g(r.error,x)},P(!0)),c.has(t)&&(c.delete(t),f.emit("unlink",t)),k()})),c.add(t),f.emit("link",t))}function P(t){i.halt(),i.future.consume((function(){var r;!function n(){O.run((function(){(r=Array.from(c).reverse().find((function(n){return n!==r&&(t||!n.options.blockParent)})))&&(r.consume(n),r.halt())}))}()}))}function k(){O.run((function(){0===Array.from(c).length&&"pending"!==i.future.state&&"pending"===E.state&&(l.finish(),d(u))}))}return(i=function t(r,n){if("function"==typeof n)return function(t,r){var n,e=h(),o=e.resolve;return{get type(){return n?"promise"===n.type?"async function":n.type+" function":"function"},future:e.future,start:function(){try{n=r()}catch(t){return void o({state:"errored",error:t})}n.future.consume((function(t){o(t)})),n.start()},halt:function(){var t;null===(t=n)||void 0===t||t.halt()}}}(0,(function(){return t(r,n(r))}));if(!n)return o=h(),u=o.resolve,{start:function(){},halt:function(){u({state:"halted"})},future:o.future,type:"suspend"};if("object"==typeof(e=n)&&"function"==typeof e.init)return function(t,r){var n,e=t.options.resourceScope,o=h(),u=o.resolve;return{start:function(){if(!e)throw new Error("cannot spawn resource in task which has no resource scope");var o;try{o=r.init(e,t)}catch(t){return void u({state:"errored",error:t})}(n=y(t,o,{resourceScope:e})).future.consume((function(t){u(t)})),n.start()},halt:function(){n.halt()},future:o.future,type:"resource"}}(r,n);if(function(t){return t&&"function"==typeof t.consume}(n))return function(t,r){var n=h(),e=n.resolve;return{start:function(){r.consume(e)},halt:function(){e({state:"halted"})},future:n.future,type:"future"}}(0,n);if(function(t){return t&&"function"==typeof t.perform}(n))return function(t,r){var n=h(),e=n.resolve;return{start:function(){try{var n=r.perform((function(t){return e({state:"completed",value:t})}),(function(t){return e({state:"errored",error:t})}));n&&t.consume(n)}catch(t){e({state:"errored",error:t})}},halt:function(){e({state:"halted"})},future:n.future,type:"resolution"}}(r,n);if(function(t){return t&&"function"==typeof t.then}(n))return function(t,r){var n=h(),e=n.resolve,o=n.future;return{start:function(){Promise.race([r,o]).then((function(t){e({state:"completed",value:t})}),(function(t){e({state:"errored",error:t})}))},halt:function(){e({state:"halted"})},future:o,type:"promise"}}(0,n);if(function(t){return t&&"function"==typeof t.next}(n))return y(r,n);var e,o,u;throw new Error("unkown type of operation: "+n)}(x,n)).future.consume((function(t){"completed"===t.state?(l.completing(),u||(u={state:"completed",value:t.value}),P(!1)):"errored"===t.state&&(l.erroring(),u={state:"errored",error:g(t.error,x)},P(!0)),k()})),x}var E="__effectionV"+"2.0.0-beta.0".split(".")[0];function O(){var t=w(void 0,{ignoreChildErrors:!0});return t.start(),t}function j(){return globalThis[E]||(globalThis[E]={root:O()}),globalThis[E]}var x={get root(){return j().root},set root(t){j().root=t},reset:function(){try{return Promise.resolve(x.root.halt()).then((function(){x.root=O()}))}catch(t){return Promise.reject(t)}},halt:function(){try{return Promise.resolve(x.root.halt()).then((function(){}))}catch(t){return Promise.reject(t)}}};function S(t,n){return t&&(t.labels=r({},t.labels||{},n)),t}function P(t){return{labels:{name:"sleep",duration:null!=t?t:"forever"},perform:function(r){if(null!=t){var n=setTimeout(r,t);return function(){return clearTimeout(n)}}}}}var k=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).name="TimeoutError",r}return n(r,t),r}(a(Error));function T(t){return S((function*(){throw yield P(t),new k("timed out after "+t+"ms")}),{name:"timeout",duration:t})}exports.Effection=x,exports.all=function(t){return S((function*(r){for(var n,e=[],o=[],u=f(t);!(n=u()).done;)"running"===r.state&&e.push(r.spawn(n.value));for(var i=0,a=e;i<a.length;i++){var c=a[i];o.push(yield c)}return o}),{name:"all",count:t.length})},exports.createFuture=h,exports.createTask=w,exports.deprecated=function(t,r){return function(){try{throw new Error("trace")}catch(r){var n=r.stack.split("\n").slice(3,4),e=n[0];console.warn(t,"\n"+e)}for(var o=arguments.length,u=new Array(o),i=0;i<o;i++)u[i]=arguments[i];return r.call.apply(r,[this].concat(u))}},exports.ensure=function(t){return{name:"ensure",init:function*(r){r.spawn((function*(){try{yield}finally{var r=t();r&&(yield r)}}),{labels:{name:"ensureHandler"}})}}},exports.label=function(t){return{name:"label",init:function*(r){r.setLabels(t)}}},exports.race=function(t){return S((function(r){return{perform:function(n,e){for(var o,u=function(){var t=o.value;"running"===r.state&&r.spawn((function*(){try{n(yield t)}catch(t){e(t)}}))},i=f(t);!(o=i()).done;)u()}}}),{name:"race",count:t.length})},exports.run=function(t,r){return x.root.spawn(t,r)},exports.sleep=P,exports.spawn=function(t,r){function*n(n){return n.spawn(t,r)}return{init:n,within:function(t){return{init:function(){return n(t)}}},name:"spawn"}},exports.timeout=T,exports.withLabels=S,exports.withTimeout=function(t,r){return S((function*(n){return n.spawn(T(t)),yield r}),{name:"withTimeout",duration:t})};
"use strict";var t=require("events");function r(){return(r=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r)}function e(t){return(e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,r){return(o=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function i(t,r,n){return(i=u()?Reflect.construct:function(t,r,n){var e=[null];e.push.apply(e,r);var u=new(Function.bind.apply(t,e));return n&&o(u,n.prototype),u}).apply(null,arguments)}function a(t){var r="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,n)}function n(){return i(t,arguments,e(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)})(t)}function c(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function f(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return c(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0;return function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var l=function(t){function r(){return t.call(this,"halted")||this}var e;return n(r,t),(e=[{key:"__isEffectionHaltError",get:function(){return!0}}])&&function(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}(r.prototype,e),r}(a(Error));function s(t){var r;if(!(r=t)||!r.__isEffectionHaltError)throw t}function p(){var t=!1,r=[];return{run:function(n){if(r.push(n),!t){t=!0;try{for(;;){var e=r.shift();if(!e)break;try{e()}catch(t){console.error("Caught error in run loop:"),console.error(t)}}}finally{t=!1}}}}}function h(){var t,r,n,e=p(),o=[];function u(t){o.push(t),e.run(i)}function i(){if(r)for(;;){var t=o.shift();if(!t)break;t(r)}}function a(){return n||(n=new Promise((function(t,r){u((function(n){"completed"===n.state?t(n.value):"errored"===n.state?r(n.error):"halted"===n.state&&r(new l)}))})))}return{resolve:function(t){r||(r=t,e.run(i))},future:(t={get state(){var t;return(null===(t=r)||void 0===t?void 0:t.state)||"pending"},consume:u,then:function(){var t;return(t=a()).then.apply(t,arguments)},catch:function(){var t;return(t=a()).catch.apply(t,arguments)},finally:function(){var t;return(t=a()).finally.apply(t,arguments)}},t[Symbol.toStringTag]="[continuation]",t)}}var v=Symbol.for("effection/v2/iterator-controller/claimed");function y(t,r,n){void 0===n&&(n={});var e,o=!1,u=h(),i=u.resolve,a=u.future,c=p();function f(r){c.run((function(){var u;try{u=r()}catch(t){return void i({state:"errored",error:t})}u.done?i(o?{state:"halted"}:{state:"completed",value:u.value}):((e=w(u.value,{resourceScope:n.resourceScope||t,ignoreError:!0})).consume(l),e.start())}))}function l(t){e=void 0,"completed"===t.state&&f((function(){return r.next(t.value)})),"errored"===t.state&&f((function(){return r.throw(t.error)})),"halted"===t.state&&f((function(){return r.return(void 0)}))}return{start:function(){if(r[v]){var t=new Error("An operation iterator can only be run once in a single task, but it looks like has been either yielded to, or run multiple times");t.name="DoubleEvalError",i({state:"errored",error:t})}else r[v]=!0,f((function(){return r.next()}))},halt:function(){o||(o=!0,e?e.halt():f((function(){return r.return(void 0)})))},future:a,type:"generator"}}function d(t){return JSON.stringify(t)}var m=function(){function t(t){this.emitter=t,this.current="pending"}var r=t.prototype;return r.transition=function(t,r){var n=this.current,e=r[n];if(!e){var o=Object.keys(r).map(d).join(", ");throw new Error("INTERNAL ERROR: state transition "+d(t)+" is not valid in current state "+d(n)+", should be one of "+o)}this.current=e,this.emitter.emit("state",{from:n,to:e})},r.start=function(){this.transition("start",{pending:"running"})},r.completing=function(){this.transition("completing",{running:"completing"})},r.erroring=function(){this.transition("erroring",{running:"erroring",completing:"erroring",halting:"erroring",erroring:"erroring"})},r.halting=function(){this.transition("halting",{running:"halting",completing:"halting",halting:"halting"})},r.finish=function(){this.transition("finish",{completing:"completed",erroring:"errored",halting:"halted"})},t}();function g(t,r){var n={id:r.id,type:r.type,labels:r.labels},e=Object.getOwnPropertyDescriptors(t);return e.effectionTrace={value:[].concat(t.effectionTrace||[],[n]),enumerable:!0},Object.create(Object.getPrototypeOf(t),e)}var b=0;function w(n,e){var o;void 0===e&&(e={});var u,i,a=++b,c=new Set,f=new t.EventEmitter,l=new m(f),v=h(),d=v.resolve,E=v.future,O=p(),j=r({},null==n?void 0:n.labels,e.labels);!j.name&&null!=n&&n.name&&(j.name=null==n?void 0:n.name);var x=((o={id:a,options:e,future:E,get labels(){return j},get state(){return l.current},get type(){return i.type},get children(){return Array.from(c)},catchHalt:function(){return E.catch(s)},setLabels:function(t){j=r({},j,t),f.emit("labels",j)},spawn:function(t,n){if(void 0===n&&(n={}),"running"!==l.current)throw new Error("cannot spawn a child on a task which is not running");var e=w(t,r({resourceScope:x},n));return S(e),e.start(),e},start:function(){"pending"===l.current&&(l.start(),i.start())},halt:function(){try{return"running"!==l.current&&"completing"!==l.current||(l.halting(),u={state:"halted"},P(!0)),Promise.resolve(E.catch((function(){}))).then((function(){}))}catch(t){return Promise.reject(t)}},on:function(){return f.on.apply(f,arguments)},off:function(){return f.off.apply(f,arguments)},then:function(){return E.then.apply(E,arguments)},catch:function(){return E.catch.apply(E,arguments)},finally:function(){return E.finally.apply(E,arguments)},consume:function(){return E.consume.apply(E,arguments)}})[Symbol.toStringTag]="[Task "+a+"]",o);function S(t){c.has(t)||(t.consume((function(r){"errored"!==r.state||t.options.ignoreError||e.ignoreChildErrors||(l.erroring(),u={state:"errored",error:g(r.error,x)},P(!0)),c.has(t)&&(c.delete(t),f.emit("unlink",t)),k()})),c.add(t),f.emit("link",t))}function P(t){i.halt(),i.future.consume((function(){var r;!function n(){O.run((function(){(r=Array.from(c).reverse().find((function(n){return n!==r&&(t||!n.options.blockParent)})))&&(r.consume(n),r.halt())}))}()}))}function k(){O.run((function(){0===Array.from(c).length&&"pending"!==i.future.state&&"pending"===E.state&&(l.finish(),d(u))}))}return(i=function t(r,n){if("function"==typeof n)return function(t,r){var n,e=h(),o=e.resolve;return{get type(){return n?"promise"===n.type?"async function":n.type+" function":"function"},future:e.future,start:function(){try{n=r()}catch(t){return void o({state:"errored",error:t})}n.future.consume((function(t){o(t)})),n.start()},halt:function(){var t;null===(t=n)||void 0===t||t.halt()}}}(0,(function(){return t(r,n(r))}));if(!n)return o=h(),u=o.resolve,{start:function(){},halt:function(){u({state:"halted"})},future:o.future,type:"suspend"};if("object"==typeof(e=n)&&"function"==typeof e.init)return function(t,r){var n,e=t.options.resourceScope,o=h(),u=o.resolve;return{start:function(){if(!e)throw new Error("cannot spawn resource in task which has no resource scope");var o;try{o=r.init(e,t)}catch(t){return void u({state:"errored",error:t})}(n=y(t,o,{resourceScope:e})).future.consume((function(t){u(t)})),n.start()},halt:function(){n.halt()},future:o.future,type:"resource"}}(r,n);if(function(t){return t&&"function"==typeof t.consume}(n))return function(t,r){var n=h(),e=n.resolve;return{start:function(){r.consume(e)},halt:function(){e({state:"halted"})},future:n.future,type:"future"}}(0,n);if(function(t){return t&&"function"==typeof t.perform}(n))return function(t,r){var n=h(),e=n.resolve;return{start:function(){try{var n=r.perform((function(t){return e({state:"completed",value:t})}),(function(t){return e({state:"errored",error:t})}));n&&t.consume(n)}catch(t){e({state:"errored",error:t})}},halt:function(){e({state:"halted"})},future:n.future,type:"resolution"}}(r,n);if(function(t){return t&&"function"==typeof t.then}(n))return function(t,r){var n=h(),e=n.resolve,o=n.future;return{start:function(){Promise.race([r,o]).then((function(t){e({state:"completed",value:t})}),(function(t){e({state:"errored",error:t})}))},halt:function(){e({state:"halted"})},future:o,type:"promise"}}(0,n);if(function(t){return t&&"function"==typeof t.next}(n))return y(r,n);var e,o,u;throw new Error("unkown type of operation: "+n)}(x,n)).future.consume((function(t){"completed"===t.state?(l.completing(),u||(u={state:"completed",value:t.value}),P(!1)):"errored"===t.state&&(l.erroring(),u={state:"errored",error:g(t.error,x)},P(!0)),k()})),x}var E="__effectionV"+"2.0.0-beta.1".split(".")[0];function O(){var t=w(void 0,{ignoreChildErrors:!0});return t.start(),t}function j(){return globalThis[E]||(globalThis[E]={root:O()}),globalThis[E]}var x={get root(){return j().root},set root(t){j().root=t},reset:function(){try{return Promise.resolve(x.root.halt()).then((function(){x.root=O()}))}catch(t){return Promise.reject(t)}},halt:function(){try{return Promise.resolve(x.root.halt()).then((function(){}))}catch(t){return Promise.reject(t)}}};function S(t,n){return t&&(t.labels=r({},t.labels||{},n)),t}function P(t){return{labels:{name:"sleep",duration:null!=t?t:"forever"},perform:function(r){if(null!=t){var n=setTimeout(r,t);return function(){return clearTimeout(n)}}}}}var k=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).name="TimeoutError",r}return n(r,t),r}(a(Error));function T(t){return S((function*(){throw yield P(t),new k("timed out after "+t+"ms")}),{name:"timeout",duration:t})}exports.Effection=x,exports.all=function(t){return S((function*(r){for(var n,e=[],o=[],u=f(t);!(n=u()).done;)"running"===r.state&&e.push(r.spawn(n.value));for(var i=0,a=e;i<a.length;i++){var c=a[i];o.push(yield c)}return o}),{name:"all",count:t.length})},exports.createFuture=h,exports.createTask=w,exports.deprecated=function(t,r){return function(){try{throw new Error("trace")}catch(r){var n=r.stack.split("\n").slice(3,4),e=n[0];console.warn(t,"\n"+e)}for(var o=arguments.length,u=new Array(o),i=0;i<o;i++)u[i]=arguments[i];return r.call.apply(r,[this].concat(u))}},exports.ensure=function(t){return{name:"ensure",init:function*(r){r.spawn((function*(){try{yield}finally{var r=t();r&&(yield r)}}),{labels:{name:"ensureHandler"}})}}},exports.label=function(t){return{name:"label",init:function*(r){r.setLabels(t)}}},exports.race=function(t){return S((function(r){return{perform:function(n,e){for(var o,u=function(){var t=o.value;"running"===r.state&&r.spawn((function*(){try{n(yield t)}catch(t){e(t)}}))},i=f(t);!(o=i()).done;)u()}}}),{name:"race",count:t.length})},exports.run=function(t,r){return x.root.spawn(t,r)},exports.sleep=P,exports.spawn=function(t,r){function*n(n){return n.spawn(t,r)}return{init:n,within:function(t){return{init:function(){return n(t)}}},name:"spawn"}},exports.timeout=T,exports.withLabels=S,exports.withTimeout=function(t,r){return S((function*(n){return n.spawn(T(t)),yield r}),{name:"withTimeout",duration:t})};
//# sourceMappingURL=core.cjs.production.min.js.map

@@ -959,3 +959,3 @@ import { EventEmitter } from 'events';

var version = "2.0.0-beta.0";
var version = "2.0.0-beta.1";

@@ -962,0 +962,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

{
"name": "@effection/core",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

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