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-preview.6 to 2.0.0-preview.7

6

CHANGELOG.md
# @effection/core
## 2.0.0-preview.7
### Minor Changes
- 2bad074: Run destructors in reverse order and in series
## 2.0.0-preview.6

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

90

dist/core.cjs.development.js

@@ -120,2 +120,44 @@ 'use strict';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
it = o[Symbol.iterator]();
return it.next.bind(it);
}
var SuspendController = /*#__PURE__*/function () {

@@ -520,7 +562,3 @@ function SuspendController(controls) {

_this.children.forEach(function (c) {
if (!c.options.blockParent) {
c.halt();
}
});
_this.haltChildren(false);

@@ -536,5 +574,3 @@ _this.resume();

_this.children.forEach(function (c) {
return c.halt();
});
_this.haltChildren(true);

@@ -546,5 +582,3 @@ _this.resume();

_this.children.forEach(function (c) {
return c.halt();
});
_this.haltChildren(true);

@@ -573,2 +607,22 @@ _this.resume();

_proto.haltChildren = function haltChildren(force) {
var _this2 = this;
for (var _iterator = _createForOfIteratorHelperLoose(Array.from(this.children).reverse()), _step; !(_step = _iterator()).done;) {
var child = _step.value;
if (force || !child.options.blockParent) {
// Continue halting once the first found child has been fully halted.
// The child will always have been removed from the Set when this runs.
child.addTrapper({
trap: function trap() {
return _this2.haltChildren(force);
}
});
child.halt();
return;
}
}
};
_proto.start = function start() {

@@ -580,3 +634,3 @@ this.stateMachine.start();

_proto.resume = function resume() {
var _this2 = this;
var _this3 = this;

@@ -589,4 +643,6 @@ if (this.stateMachine.isFinishing && this.children.size === 0) {

this.trappers.forEach(function (trapper) {
return trapper.trap(_this2);
return trapper.trap(_this3);
});
this.ensureHandlers.clear();
this.trappers.clear();

@@ -678,7 +734,7 @@ if (this.state === 'completed') {

try {
var _this4 = this;
var _this5 = this;
_this4.controller.halt();
_this5.controller.halt();
return Promise.resolve(_this4["catch"](function () {// TODO: should this catch all errors, or only halt errors?
return Promise.resolve(_this5["catch"](function () {// TODO: should this catch all errors, or only halt errors?
// see https://github.com/jnicklas/mini-effection/issues/23

@@ -706,3 +762,3 @@ })).then(function () {});

var version = "2.0.0-preview.6";
var version = "2.0.0-preview.7";

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

2

dist/core.cjs.production.min.js

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

"use strict";var t=require("events");function r(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r)}function i(t){return(i=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 s(){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 c(t,r,e){return(c=s()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var i=new(Function.bind.apply(t,n));return e&&o(i,e.prototype),i}).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,e)}function e(){return c(t,arguments,i(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)})(t)}var u=function(){function t(t){this.controls=t}var r=t.prototype;return r.start=function(){},r.halt=function(){this.controls.halted()},t}();function h(){var t=function(){},r=function(){},e=new Promise((function(e,n){t=e,r=n}));return{resolve:t,reject:r,promise:e}}var l=Symbol("halt"),f=function(){function t(t,r){this.controls=t,this.promise=r,this.haltSignal=h()}var r=t.prototype;return r.start=function(){var t=this;Promise.race([this.promise,this.haltSignal.promise]).then((function(r){r===l?t.controls.halted():t.controls.resolve(r)}),(function(r){t.controls.reject(r)}))},r.halt=function(){this.haltSignal.resolve(l)},t}();function p(t){return t&&"function"==typeof t.then}var d=function(t){function r(){return t.call(this,"halted")||this}return n(r,t),e(r,[{key:"__isEffectionHaltError",get:function(){return!0}}]),r}(a(Error));function v(t){var r;if(!(r=t)||!r.__isEffectionHaltError)throw t}var m=function(){function t(t,r){this.controls=t,this.iterator=r,this.didHalt=!1,this.didEnter=!1,this.continuations=[]}var r=t.prototype;return r.start=function(){try{var t=this;return t.resume((function(){return t.iterator.next()})),Promise.resolve()}catch(t){return Promise.reject(t)}},r.resume=function(t){if(this.continuations.push(t),!this.didEnter){var r;for(this.didEnter=!0;r=this.continuations.shift();)this.step(r);this.didEnter=!1}},r.step=function(t){var r;try{r=t()}catch(t){return void this.controls.reject(t)}r.done?this.didHalt?this.controls.halted():this.controls.resolve(r.value):(this.subTask=new j(r.value),this.subTask.addTrapper(this),this.subTask.start())},r.trap=function(t){var r=this;"completed"===t.state&&this.resume((function(){return r.iterator.next(t.result)})),"errored"===t.state&&this.resume((function(){return r.iterator.throw(t.error)})),"halted"===t.state&&this.resume((function(){return r.iterator.throw(new d)}))},r.halt=function(){var t=this;this.didHalt||(this.didHalt=!0,this.subTask&&(this.subTask.removeTrapper(this),this.subTask.halt()),this.resume((function(){return t.iterator.return(void 0)})))},t}(),g=function(){function t(t,r){this.controls=t,this.resolution=r}var r=t.prototype;return r.start=function(){try{this.resolution(this.controls.resolve,this.controls.reject)}catch(t){this.controls.reject(t)}},r.halt=function(){this.controls.halted()},t}(),y=function(){function t(t,r){this.controls=t,this.operation=r}var r=t.prototype;return r.start=function(t){var r,e;try{r=this.operation(t)}catch(t){return void this.controls.reject(t)}e=p(r)?new f(this.controls,r):"function"==typeof r?new g(this.controls,r):new m(this.controls,r),this.controller=e,e.start()},r.halt=function(){try{if(!this.controller)throw new Error("INTERNAL ERROR: halt called before start, this should never happen");return this.controller.halt(),Promise.resolve()}catch(t){return Promise.reject(t)}},t}();function w(t){return JSON.stringify(t)}var b=function(){function t(t){this.emitter=t,this.current="pending"}var r=t.prototype;return r.transition=function(t,r){var e=this.current,n=r[e];if(!n){var i=Object.keys(r).map(w).join(", ");throw new Error("INTERNAL ERROR: state transition "+w(t)+" is not valid in current state "+w(e)+", should be one of "+i)}this.current=n,this.emitter.emit("state",{from:e,to:n})},r.start=function(){this.transition("start",{pending:"running"})},r.resolve=function(){this.transition("resolve",{running:"completing",completing:"completing",erroring:"erroring",halting:"halting"})},r.reject=function(){this.transition("reject",{running:"erroring",completing:"erroring",halting:"erroring",erroring:"erroring"})},r.halt=function(){this.transition("halt",{running:"halting",completing:"halting",halting:"halting",erroring:"erroring",halted:"halted",completed:"completed",errored:"errored"})},r.finish=function(){this.transition("finish",{completing:"completed",erroring:"errored",halting:"halted"})},e(t,[{key:"isFinishing",get:function(){return["completing","halting","erroring"].includes(this.current)}}]),t}(),E=0,j=function(t){function r(r,e){var n;if(void 0===e&&(e={}),(n=t.call(this)||this).operation=r,n.options=e,n.id=++E,n.children=new Set,n.trappers=new Set,n.ensureHandlers=new Set,n.deferred=h(),n.stateMachine=new b(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)),n.controls={resolve:function(t){n.stateMachine.resolve(),n.result=t,n.children.forEach((function(t){t.options.blockParent||t.halt()})),n.resume()},reject:function(t){n.stateMachine.reject(),n.result=void 0,n.error=t,n.children.forEach((function(t){return t.halt()})),n.resume()},halted:function(){n.stateMachine.halt(),n.children.forEach((function(t){return t.halt()})),n.resume()}},r)if(p(r))n.controller=new f(n.controls,r);else{if("function"!=typeof r)throw new Error("unkown type of operation: "+r);n.controller=new y(n.controls,r)}else n.controller=new u(n.controls);return n.deferred.promise.catch((function(){})),n}n(r,t);var i=r.prototype;return i.start=function(){this.stateMachine.start(),this.controller.start(this)},i.resume=function(){var t=this;this.stateMachine.isFinishing&&0===this.children.size&&(this.stateMachine.finish(),this.ensureHandlers.forEach((function(t){return t()})),this.trappers.forEach((function(r){return r.trap(t)})),"completed"===this.state?this.deferred.resolve(this.result):"halted"===this.state?this.deferred.reject(new d):"errored"===this.state&&this.deferred.reject(this.error))},i.then=function(t,r){return this.deferred.promise.then(t,r)},i.catch=function(t){return this.deferred.promise.catch(t)},i.catchHalt=function(){return this.deferred.promise.catch(v)},i.finally=function(t){return this.deferred.promise.finally(t)},i.spawn=function(t,e){if("running"!==this.state)throw new Error("cannot spawn a child on a task which is not running");var n=new r(t,e);return this.link(n),n.start(),n},i.link=function(t){this.children.has(t)||(t.addTrapper(this),this.children.add(t),this.emit("link",t))},i.unlink=function(t){this.children.has(t)&&(t.removeTrapper(this),this.children.delete(t),this.emit("unlink",t))},i.trap=function(t){this.children.has(t)&&("errored"!==t.state||this.options.ignoreChildErrors||this.controls.reject(t.error),this.unlink(t)),this.resume()},i.ensure=function(t){this.ensureHandlers.add(t)},i.addTrapper=function(t){this.trappers.add(t)},i.removeTrapper=function(t){this.trappers.delete(t)},i.halt=function(){try{return this.controller.halt(),Promise.resolve(this.catch((function(){}))).then((function(){}))}catch(t){return Promise.reject(t)}},e(r,[{key:"state",get:function(){return this.stateMachine.current}},{key:Symbol.toStringTag,get:function(){return"[Task "+this.id+"]"}}]),r}(t.EventEmitter),k="__effectionV"+"2.0.0-preview.6".split(".")[0];function T(){var t=new j(void 0,{ignoreChildErrors:!0});return t.start(),t}function P(){return globalThis[k]||(globalThis[k]={root:T()}),globalThis[k]}var O={get root(){return P().root},set root(t){P().root=t},reset:function(){try{return Promise.resolve(O.root.halt()).then((function(){O.root=T()}))}catch(t){return Promise.reject(t)}},halt:function(){try{return Promise.resolve(O.root.halt()).then((function(){}))}catch(t){return Promise.reject(t)}}};exports.Deferred=h,exports.Effection=O,exports.Task=j,exports.deprecated=function(t,r){return function(){try{throw new Error("trace")}catch(r){var e=r.stack.split("\n").slice(3,4),n=e[0];console.warn(t,"\n"+n)}for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];return r.call.apply(r,[this].concat(o))}},exports.run=function(t,r){return O.root.spawn(t,r)},exports.sleep=function(t){return function(r){return function(e){var n=setTimeout(e,t);r.ensure((function(){return clearTimeout(n)}))}}};
"use strict";var t=require("events");function r(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r)}function i(t){return(i=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 s(){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 c(t,r,e){return(c=s()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var i=new(Function.bind.apply(t,n));return e&&o(i,e.prototype),i}).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,e)}function e(){return c(t,arguments,i(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)})(t)}function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var h=function(){function t(t){this.controls=t}var r=t.prototype;return r.start=function(){},r.halt=function(){this.controls.halted()},t}();function l(){var t=function(){},r=function(){},e=new Promise((function(e,n){t=e,r=n}));return{resolve:t,reject:r,promise:e}}var f=Symbol("halt"),p=function(){function t(t,r){this.controls=t,this.promise=r,this.haltSignal=l()}var r=t.prototype;return r.start=function(){var t=this;Promise.race([this.promise,this.haltSignal.promise]).then((function(r){r===f?t.controls.halted():t.controls.resolve(r)}),(function(r){t.controls.reject(r)}))},r.halt=function(){this.haltSignal.resolve(f)},t}();function d(t){return t&&"function"==typeof t.then}var v=function(t){function r(){return t.call(this,"halted")||this}return n(r,t),e(r,[{key:"__isEffectionHaltError",get:function(){return!0}}]),r}(a(Error));function m(t){var r;if(!(r=t)||!r.__isEffectionHaltError)throw t}var y=function(){function t(t,r){this.controls=t,this.iterator=r,this.didHalt=!1,this.didEnter=!1,this.continuations=[]}var r=t.prototype;return r.start=function(){try{var t=this;return t.resume((function(){return t.iterator.next()})),Promise.resolve()}catch(t){return Promise.reject(t)}},r.resume=function(t){if(this.continuations.push(t),!this.didEnter){var r;for(this.didEnter=!0;r=this.continuations.shift();)this.step(r);this.didEnter=!1}},r.step=function(t){var r;try{r=t()}catch(t){return void this.controls.reject(t)}r.done?this.didHalt?this.controls.halted():this.controls.resolve(r.value):(this.subTask=new T(r.value),this.subTask.addTrapper(this),this.subTask.start())},r.trap=function(t){var r=this;"completed"===t.state&&this.resume((function(){return r.iterator.next(t.result)})),"errored"===t.state&&this.resume((function(){return r.iterator.throw(t.error)})),"halted"===t.state&&this.resume((function(){return r.iterator.throw(new v)}))},r.halt=function(){var t=this;this.didHalt||(this.didHalt=!0,this.subTask&&(this.subTask.removeTrapper(this),this.subTask.halt()),this.resume((function(){return t.iterator.return(void 0)})))},t}(),g=function(){function t(t,r){this.controls=t,this.resolution=r}var r=t.prototype;return r.start=function(){try{this.resolution(this.controls.resolve,this.controls.reject)}catch(t){this.controls.reject(t)}},r.halt=function(){this.controls.halted()},t}(),w=function(){function t(t,r){this.controls=t,this.operation=r}var r=t.prototype;return r.start=function(t){var r,e;try{r=this.operation(t)}catch(t){return void this.controls.reject(t)}e=d(r)?new p(this.controls,r):"function"==typeof r?new g(this.controls,r):new y(this.controls,r),this.controller=e,e.start()},r.halt=function(){try{if(!this.controller)throw new Error("INTERNAL ERROR: halt called before start, this should never happen");return this.controller.halt(),Promise.resolve()}catch(t){return Promise.reject(t)}},t}();function b(t){return JSON.stringify(t)}var j=function(){function t(t){this.emitter=t,this.current="pending"}var r=t.prototype;return r.transition=function(t,r){var e=this.current,n=r[e];if(!n){var i=Object.keys(r).map(b).join(", ");throw new Error("INTERNAL ERROR: state transition "+b(t)+" is not valid in current state "+b(e)+", should be one of "+i)}this.current=n,this.emitter.emit("state",{from:e,to:n})},r.start=function(){this.transition("start",{pending:"running"})},r.resolve=function(){this.transition("resolve",{running:"completing",completing:"completing",erroring:"erroring",halting:"halting"})},r.reject=function(){this.transition("reject",{running:"erroring",completing:"erroring",halting:"erroring",erroring:"erroring"})},r.halt=function(){this.transition("halt",{running:"halting",completing:"halting",halting:"halting",erroring:"erroring",halted:"halted",completed:"completed",errored:"errored"})},r.finish=function(){this.transition("finish",{completing:"completed",erroring:"errored",halting:"halted"})},e(t,[{key:"isFinishing",get:function(){return["completing","halting","erroring"].includes(this.current)}}]),t}(),E=0,T=function(t){function r(r,e){var n;if(void 0===e&&(e={}),(n=t.call(this)||this).operation=r,n.options=e,n.id=++E,n.children=new Set,n.trappers=new Set,n.ensureHandlers=new Set,n.deferred=l(),n.stateMachine=new j(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)),n.controls={resolve:function(t){n.stateMachine.resolve(),n.result=t,n.haltChildren(!1),n.resume()},reject:function(t){n.stateMachine.reject(),n.result=void 0,n.error=t,n.haltChildren(!0),n.resume()},halted:function(){n.stateMachine.halt(),n.haltChildren(!0),n.resume()}},r)if(d(r))n.controller=new p(n.controls,r);else{if("function"!=typeof r)throw new Error("unkown type of operation: "+r);n.controller=new w(n.controls,r)}else n.controller=new h(n.controls);return n.deferred.promise.catch((function(){})),n}n(r,t);var i=r.prototype;return i.haltChildren=function(t){for(var r,e=this,n=function(t,r){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return u(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,void 0):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}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(e=t[Symbol.iterator]()).next.bind(e)}(Array.from(this.children).reverse());!(r=n()).done;){var i=r.value;if(t||!i.options.blockParent)return i.addTrapper({trap:function(){return e.haltChildren(t)}}),void i.halt()}},i.start=function(){this.stateMachine.start(),this.controller.start(this)},i.resume=function(){var t=this;this.stateMachine.isFinishing&&0===this.children.size&&(this.stateMachine.finish(),this.ensureHandlers.forEach((function(t){return t()})),this.trappers.forEach((function(r){return r.trap(t)})),this.ensureHandlers.clear(),this.trappers.clear(),"completed"===this.state?this.deferred.resolve(this.result):"halted"===this.state?this.deferred.reject(new v):"errored"===this.state&&this.deferred.reject(this.error))},i.then=function(t,r){return this.deferred.promise.then(t,r)},i.catch=function(t){return this.deferred.promise.catch(t)},i.catchHalt=function(){return this.deferred.promise.catch(m)},i.finally=function(t){return this.deferred.promise.finally(t)},i.spawn=function(t,e){if("running"!==this.state)throw new Error("cannot spawn a child on a task which is not running");var n=new r(t,e);return this.link(n),n.start(),n},i.link=function(t){this.children.has(t)||(t.addTrapper(this),this.children.add(t),this.emit("link",t))},i.unlink=function(t){this.children.has(t)&&(t.removeTrapper(this),this.children.delete(t),this.emit("unlink",t))},i.trap=function(t){this.children.has(t)&&("errored"!==t.state||this.options.ignoreChildErrors||this.controls.reject(t.error),this.unlink(t)),this.resume()},i.ensure=function(t){this.ensureHandlers.add(t)},i.addTrapper=function(t){this.trappers.add(t)},i.removeTrapper=function(t){this.trappers.delete(t)},i.halt=function(){try{return this.controller.halt(),Promise.resolve(this.catch((function(){}))).then((function(){}))}catch(t){return Promise.reject(t)}},e(r,[{key:"state",get:function(){return this.stateMachine.current}},{key:Symbol.toStringTag,get:function(){return"[Task "+this.id+"]"}}]),r}(t.EventEmitter),k="__effectionV"+"2.0.0-preview.7".split(".")[0];function O(){var t=new T(void 0,{ignoreChildErrors:!0});return t.start(),t}function P(){return globalThis[k]||(globalThis[k]={root:O()}),globalThis[k]}var S={get root(){return P().root},set root(t){P().root=t},reset:function(){try{return Promise.resolve(S.root.halt()).then((function(){S.root=O()}))}catch(t){return Promise.reject(t)}},halt:function(){try{return Promise.resolve(S.root.halt()).then((function(){}))}catch(t){return Promise.reject(t)}}};exports.Deferred=l,exports.Effection=S,exports.Task=T,exports.deprecated=function(t,r){return function(){try{throw new Error("trace")}catch(r){var e=r.stack.split("\n").slice(3,4),n=e[0];console.warn(t,"\n"+n)}for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];return r.call.apply(r,[this].concat(o))}},exports.run=function(t,r){return S.root.spawn(t,r)},exports.sleep=function(t){return function(r){return function(e){var n=setTimeout(e,t);r.ensure((function(){return clearTimeout(n)}))}}};
//# sourceMappingURL=core.cjs.production.min.js.map

@@ -118,2 +118,44 @@ import { EventEmitter } from 'events';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
it = o[Symbol.iterator]();
return it.next.bind(it);
}
var SuspendController = /*#__PURE__*/function () {

@@ -518,7 +560,3 @@ function SuspendController(controls) {

_this.children.forEach(function (c) {
if (!c.options.blockParent) {
c.halt();
}
});
_this.haltChildren(false);

@@ -534,5 +572,3 @@ _this.resume();

_this.children.forEach(function (c) {
return c.halt();
});
_this.haltChildren(true);

@@ -544,5 +580,3 @@ _this.resume();

_this.children.forEach(function (c) {
return c.halt();
});
_this.haltChildren(true);

@@ -571,2 +605,22 @@ _this.resume();

_proto.haltChildren = function haltChildren(force) {
var _this2 = this;
for (var _iterator = _createForOfIteratorHelperLoose(Array.from(this.children).reverse()), _step; !(_step = _iterator()).done;) {
var child = _step.value;
if (force || !child.options.blockParent) {
// Continue halting once the first found child has been fully halted.
// The child will always have been removed from the Set when this runs.
child.addTrapper({
trap: function trap() {
return _this2.haltChildren(force);
}
});
child.halt();
return;
}
}
};
_proto.start = function start() {

@@ -578,3 +632,3 @@ this.stateMachine.start();

_proto.resume = function resume() {
var _this2 = this;
var _this3 = this;

@@ -587,4 +641,6 @@ if (this.stateMachine.isFinishing && this.children.size === 0) {

this.trappers.forEach(function (trapper) {
return trapper.trap(_this2);
return trapper.trap(_this3);
});
this.ensureHandlers.clear();
this.trappers.clear();

@@ -676,7 +732,7 @@ if (this.state === 'completed') {

try {
var _this4 = this;
var _this5 = this;
_this4.controller.halt();
_this5.controller.halt();
return Promise.resolve(_this4["catch"](function () {// TODO: should this catch all errors, or only halt errors?
return Promise.resolve(_this5["catch"](function () {// TODO: should this catch all errors, or only halt errors?
// see https://github.com/jnicklas/mini-effection/issues/23

@@ -704,3 +760,3 @@ })).then(function () {});

var version = "2.0.0-preview.6";
var version = "2.0.0-preview.7";

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

@@ -29,2 +29,3 @@ /// <reference types="node" />

private controls;
private haltChildren;
get state(): State;

@@ -31,0 +32,0 @@ constructor(operation: Operation<TOut>, options?: TaskOptions);

{
"name": "@effection/core",
"version": "2.0.0-preview.6",
"version": "2.0.0-preview.7",
"main": "dist/index.js",

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

@@ -48,7 +48,3 @@ import { SuspendController } from './controller/suspend-controller';

this.result = result;
this.children.forEach((c) => {
if(!c.options.blockParent) {
c.halt()
}
});
this.haltChildren(false);
this.resume();

@@ -61,3 +57,3 @@ },

this.error = error;
this.children.forEach((c) => c.halt());
this.haltChildren(true);
this.resume();

@@ -68,3 +64,3 @@ },

this.stateMachine.halt();
this.children.forEach((c) => c.halt());
this.haltChildren(true);
this.resume();

@@ -74,2 +70,14 @@ },

private haltChildren(force: boolean) {
for(let child of Array.from(this.children).reverse()) {
if(force || !child.options.blockParent) {
// Continue halting once the first found child has been fully halted.
// The child will always have been removed from the Set when this runs.
child.addTrapper({ trap: () => this.haltChildren(force) });
child.halt()
return;
}
}
}
get state(): State {

@@ -107,2 +115,5 @@ return this.stateMachine.current;

this.ensureHandlers.clear();
this.trappers.clear();
if(this.state === 'completed') {

@@ -109,0 +120,0 @@ // TODO: model state as a union so we do not need this non-null assertion

Sorry, the diff of this file is not supported yet

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