Socket
Socket
Sign inDemoInstall

futoin-asyncsteps

Package Overview
Dependencies
1
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.2 to 2.3.3

4

CHANGELOG.txt

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

=== 2.3.3 (2019-01-11) ===
CHANGED: dependency maintenance
=== 2.3.2 (2018-08-11) ===

@@ -2,0 +6,0 @@ CHANGED: dependency maintenance

2

dist/futoin-asyncsteps-lite.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["futoin-asyncsteps"]=t():e.$as=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};["ConnectError","CommError","UnknownInterface","NotSupportedVersion","NotImplemented","Unauthorized","InternalError","InvokerError","InvalidRequest","DefenseRejected","PleaseReauth","SecurityError","Timeout","LoopBreak","LoopCont"].forEach(function(e){return Object.defineProperty(r,e,{enumerable:!0,value:e})}),e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,c=e[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&c.return&&c.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var o=n(0),u=(o.InternalError,o.LoopCont),c=o.LoopBreak,s="undefined"==typeof Symbol?function(e){return e}:function(e){return Symbol(e)},a=s("_loop_term_label"),l=function(e,t,n,r,i){i&&i()||e.add(function(e){var o=e.state,s=t._exec_stack,l=s.length,h=[n,function(t,n){!function(e,t,n,r,i){if(t===u){var o=r[a];o&&o!==i||(r.last_exception=null,e._root._handle_success())}else if(t===c){var s=r[a];s&&s!==i||(r.last_exception=null,n._queue.length=0,e._root._handle_success())}}(t,n,e,o,r)}],f=[function(e){i&&i()||(s.length=l,_())},null],_=function(){e._queue=[h,f]};_()})},h=function(e,t,n,r,i){var o=0,u=n;l(e,t,function(e){r(e,o++)},i,function(){return o>=u})},f=[];Object.freeze(f);var _=function(){};e.exports=t={noop:_,makeSym:s,loop:l,repeat:h,forEach:function(e,t,n,r,o){if(Array.isArray(n)){var u=n;h(e,t,u.length,function(e,t){r(e,t,u[t])},o)}else if("undefined"!=typeof Map&&n instanceof Map){var c=n.entries();l(e,t,function(e){var t=c.next();t.done&&e.break();var n=i(t.value,2),o=n[0],u=n[1];r(e,o,u)},o)}else{var s=n,a=Object.keys(s);h(e,t,a.length,function(e,t){r(e,a[t],s[a[t]])},o)}},LOOP_TERM_LABEL:a,as_await:function(e,t,n,r){var i=void 0,o=void 0;n.then(function(e){i?i.state&&t._burst_success([e]):o=function(){t._handle_success([e])}},function(e){i?function(e,t,n){var r=e.state;if(r)if(e._on_cancel=null,n instanceof Error)r.last_exception=n,r.error_info=void 0,t._handle_error("PromiseReject");else{var i=n||"PromiseReject";r.last_exception=new Error(i),r.error_info=void 0,t._handle_error(i)}}(i,t,e):(i=null,o=e instanceof Error?function(){throw e}:function(t){t.error(e||"PromiseReject")})}),e.add(function(e){o?o(e):(i=e,e._on_cancel=function(){if(i){i=null;try{n.cancel()}catch(e){}}})},r)},EMPTY_ARRAY:f,prev_queue:function(e){var t=e._stack,n=t.length;return n>1?t[n-2]._queue:e._queue}},t.isProduction=!0,t.checkFunc=_,t.checkOnError=_;var v=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"push",value:function(){}},{key:"length",get:function(){return 0},set:function(e){}}]),e}());Object.freeze(v),t.newExecStack=function(){return v}},function(e,t,n){"use strict";if(t=e.exports={},"undefined"==typeof setImmediate){t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){return clearTimeout(e)},window._FutoInEventLoopQueue=window._FutoInEventLoopQueue||[];var r=window._FutoInEventLoopQueue,i=window.performance,o=null,u=function(){o&&clearTimeout(o),o=setTimeout(c,0)},c=function(){o=null;for(var e=i.now()+10;r.length;){var t=r.shift();try{t()}catch(e){throw u(),e}if(i.now()>=e){u();break}}};t.callImmediate=function(e){r.length||u();var t=function(){e()};return r.push(t),t},t.cancelImmediate=function(e){var t=r.indexOf(e);t>=0&&r.splice(t,1)}}else t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){clearTimeout(e)},t.callImmediate=function(e){return setImmediate(e)},t.cancelImmediate=function(e){clearImmediate(e)}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(1),o=i.checkFunc,u=i.checkOnError,c=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this._as=n,this._queue=[],this._psteps=[],this._complete_count=0}return r(e,[{key:"add",value:function(e,t){return o(this,e),u(this,t),this._queue.push([e,t]),this}},{key:"_complete",value:function(){this._complete_count+=1,this._complete_count===this._psteps.length&&(this._as._root._handle_success(),this._cleanup())}},{key:"_error",value:function(e,t){try{this._as.error(e,t)}catch(e){}}},{key:"executeParallel",value:function(t){var n=this,r=this._queue,i=this._root;if(i!==t._root){var o=new e(t._root,t);return o._queue.push.apply(o._queue,r),void o.executeParallel(t)}if(this._as=t,r.length){t._on_cancel=function(){n.cancel()};var u=this._psteps,c=function(e){n._complete()},s=function(e,t){n._error(t,e.state.error_info)},a=i.constructor;r.forEach(function(e){var n=new a(t.state,i._async_tool);n._queue.push([function(t){t._queue=[[e[0],e[1]]]},s],[c,void 0]),u.push(n)}),u.forEach(function(e){e.execute()})}else this._complete()}},{key:"cancel",value:function(){this._psteps.forEach(function(e){e.cancel()}),this._cleanup()}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this._as=null,this._psteps=null}}]),e}();e.exports=c},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(2),o=n(0).InternalError,u=n(9),c=n(3),s=n(1),a=s.isProduction,l=s.checkFunc,h=s.checkOnError,f=s.noop,_=s.loop,v=s.repeat,p=s.forEach,y=s.as_await,d=s.EMPTY_ARRAY,m=s.newExecStack,x=a?f:function(e){e._stack.length>0&&e.error(o,"Top level add in execution")},k=a?f:function(e,t,n){x(e),l(e,t),h(e,n)},g=100,w=g,E=null,b=function(e){e._post_exec=f,e._execute()},q=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),null===n&&(n=function(){return this.state}),this.state=n,this._queue=[],this._stack=[],this._exec_stack=m(),this._in_exec=!1,this._post_exec=f,this._exec_event=null,this._next_args=d,this._async_tool=r;var o=r.callImmediate,u=function(){w=g,E=t,t._exec_event=null,t._execute()};this._scheduleExecute=function(){--w<=0||!t._in_exec||E!==t?t._exec_event=o(u):t._in_exec&&(t._post_exec=b)}}return r(e,[{key:"add",value:function(e,t){return k(this,e,t),this._queue.push([e,t]),this}},{key:"parallel",value:function(e){x(this),h(this,e);var t=new c(this,this);return this._queue.push([function(e){t.executeParallel(e)},e]),t}},{key:"sync",value:function(e,t,n){return k(this,t,n),e.sync(this,t,n),this}},{key:"error",value:function(e,t){this.state.error_info=t;var n=new Error(e);throw this._in_exec||(this.state.last_exception=n,this._handle_error(e)),n}},{key:"copyFrom",value:function(e){this._queue.push.apply(this._queue,e._queue);var t=e.state,n=this.state;for(var r in t)r in n||(n[r]=t[r]);return this}},{key:"_handle_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,t=this._stack;t.length||this.error(o,"Invalid success completion"),this._next_args=e;for(var n=t[t.length-1];;){var r=n._limit_event;if(r&&(this._async_tool.cancelCall(r),n._limit_event=null),n._cleanup(),t.pop(),!t.length)break;if((n=t[t.length-1])._queue.length)break}(t.length||this._queue.length)&&this._scheduleExecute()}},{key:"_handle_error",value:function(e){if(this._exec_event)this.cancel();else{this._next_args=d;var t=this._stack,n=this._exec_stack;this.state.async_stack=n;for(var r=this._in_exec,i=!0;t.length;){var o=t[t.length-1],u=o._limit_event,c=o._on_cancel,s=o._on_error;if(u&&(this._async_tool.cancelCall(u),o._limit_event=null),c&&(c.call(null,o),o._on_cancel=null),s){var a=t.length;o._queue=null,o._on_error=null,n.push(s);try{if(this._in_exec=!0,s.call(null,o,e),a!==t.length){i=!1;break}if(null!==o._queue){i=!1,this._scheduleExecute();break}}catch(t){this.state.last_exception=t,e=t.message}finally{this._in_exec=r}}o._cleanup(),t.pop()}i?this._queue=[]:r||this._post_exec(this)}}},{key:"cancel",value:function(){this._next_args=d;var e=this._exec_event;e&&(this._async_tool.cancelImmediate(e),this._exec_event=null);for(var t=this._stack,n=this._async_tool;t.length;){var r=t.pop(),i=r._limit_event,o=r._on_cancel;i&&(n.cancelCall(i),r._limit_event=null),o&&(o.call(null,r),r._on_cancel=null),r._cleanup()}return this._queue=[],this}},{key:"execute",value:function(){var e=E;return E=this,this._execute(),E=e,this}},{key:"_execute",value:function(){var e=this._stack,t=void 0;if((t=e.length?e[e.length-1]._queue:this._queue).length){var n=t.shift(),r=n[0];this._exec_stack.push(r);var i=this._next_args,o=i.length,c=new u(this,n[1],i);e.push(c);try{var s=e.length;this._in_exec=!0,o?(this._next_args=d,r.apply(void 0,[c].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(i)))):r(c),s===e.length&&(null!==c._queue?this._scheduleExecute():c._on_cancel||c._limit_event||this._handle_success(this._next_args))}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}}},{key:"_burst_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;try{this._in_exec=!0,E=this,this._handle_success(e)}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}},{key:"loop",value:function(e,t){return k(this,e),_(this,this,e,t),this}},{key:"repeat",value:function(e,t,n){return k(this,t),v(this,this,e,t,n),this}},{key:"forEach",value:function(e,t,n){return k(this,t),p(this,this,e,t,n),this}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];x(this);var i=this._queue;return i.length>0?i.push([function(){e._handle_success(n)},void 0]):this._next_args=n,this}},{key:"await",value:function(e,t){return x(this),y(this,this,e,t),this}},{key:"promise",value:function(){var e=this;return x(this),new Promise(function(t,n){var r=e._queue;e._queue=[[function(e){e._queue=r},function(e,t){n(new Error(t))}],[function(e,n){t(n)},void 0]],E=e,e._execute()})}},{key:"isAsyncSteps",value:function(){return!0}}]),e}();e.exports=q},,function(e,t,n){"use strict";var r=n(2),i=n(7),o=n(0),u=n(4),c=n(1).isProduction;(t=e.exports=function(){return new u(null,t.ActiveAsyncTool)}).ActiveAsyncTool=r,t.AsyncTool=r,t.AsyncToolTest=i,t.FutoInError=o,t.Errors=o,t.AsyncSteps=u,t.isProduction=c,t.installAsyncToolTest=function(e){t.ActiveAsyncTool=!1===e?r:i},t.assertAS=function(e){try{if(e.isAsyncSteps())return}catch(e){}throw new Error("Not an instance of AsyncSteps: "+e)}},function(e,t,n){"use strict";var r=n(8),i=[];(t=e.exports={}).callLater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=1e3*r();t&&(n+=t);for(var o={f:e,t:n},u=0;u<i.length;++u)if(i[u].t>n)return void i.splice(u,0,o);return i.push(o),o},t.cancelCall=function(e){var t=i.indexOf(e);t>=0&&i.splice(t,1)},t.nextEvent=function(){i.shift().f()},t.hasEvents=function(){return i.length>0},t.getEvents=function(){return i},t.resetEvents=function(){i.splice(0,i.length)},t.run=function(){for(;this.hasEvents();)this.nextEvent()},t.callImmediate=t.callLater,t.cancelImmediate=t.cancelCall},function(e,t){(function(){var t,n,r,i,o,u;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,i=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),u=1e9*process.uptime(),o=i-u):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(3),o=n(0),u=o.InternalError,c=o.Timeout,s=o.LoopBreak,a=o.LoopCont,l=n(1),h=l.isProduction,f=l.checkFunc,_=l.checkOnError,v=l.noop,p=l.loop,y=l.repeat,d=l.forEach,m=l.LOOP_TERM_LABEL,x=l.as_await,k=h?v:function(e){var t=e._root;if(t){var n=t._stack;if(n){if(n[n.length-1]===e)return;t.error(u,"Invalid call (sanity check)")}}throw new Error("InternalError: Unexpected call, object is out of service")},g=h?v:function(e,t,n){k(e),f(e,t),_(e,n)},w=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this.state=t.state,this._queue=null,this._call_args=r,this._on_error=n,this._on_cancel=null,this._limit_event=null}return r(e,[{key:"add",value:function(e,t){g(this,e,t);var n=[e,t],r=this._queue;return r?r.push(n):this._queue=[n],this}},{key:"parallel",value:function(e){var t=new i(this._root,this);return this.add(function(e){t.executeParallel(e)},e),t}},{key:"success",value:function(){k(this),null!==this._queue&&this.error(u,"Invalid success() call");for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._root._handle_success(t)}},{key:"error",value:function(e,t){k(this),this._root.error(e,t)}},{key:"setTimeout",value:function(e){var t=this;k(this);var n=this._root._async_tool;return null!==this._limit_event&&n.cancelCall(this._limit_event),this._limit_event=n.callLater(function(){!function(e){e._limit_event=null;var t=e.state;t.error_info=void 0,t.last_exception=new Error(c),e._root._handle_error(c)}(t)},e),this}},{key:"setCancel",value:function(e){return this._on_cancel=e,this}},{key:"waitExternal",value:function(){return this._on_cancel=v,this}},{key:"copyFrom",value:function(e){if(k(this),e._queue.length){var t=this._queue;null===t&&(t=[],this._queue=t),t.push.apply(t,e._queue)}var n=e.state,r=this.state;for(var i in n)void 0===r[i]&&(r[i]=n[i]);return this}},{key:"loop",value:function(e,t){return g(this,e),p(this,this._root,e,t),this}},{key:"repeat",value:function(e,t,n){return g(this,t),y(this,this._root,e,t,n),this}},{key:"forEach",value:function(e,t,n){return g(this,t),d(this,this._root,e,t,n),this}},{key:"break",value:function(e){k(this),this.state[m]=e,this._root.error(s)}},{key:"continue",value:function(e){k(this),this.state[m]=e,this._root.error(a)}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];k(this);var i=this._queue;return i&&i.length?i.push([function(){e._root._handle_success(n)},void 0]):this._root._next_args=n,this}},{key:"await",value:function(e,t){return k(this),x(this,this._root,e,t),this}},{key:"sync",value:function(e,t,n){return g(this,t,n),e.sync(this,t,n),this}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this.state=null}}]),e}();e.exports=w},,,,,,,function(e,t,n){"use strict";!function(t){var r=t.FutoIn||t.futoin||{};if(void 0===r.AsyncSteps){var i=n(6);t.$as=i,r.$as=i,t.FutoInError=i.FutoInError,r.AsyncSteps=i.AsyncSteps,t.FutoIn=r,t.futoin=r}e.exports=r.$as}(window)}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["futoin-asyncsteps"]=t():e.$as=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};["ConnectError","CommError","UnknownInterface","NotSupportedVersion","NotImplemented","Unauthorized","InternalError","InvokerError","InvalidRequest","DefenseRejected","PleaseReauth","SecurityError","Timeout","LoopBreak","LoopCont"].forEach(function(e){return Object.defineProperty(r,e,{enumerable:!0,value:e})}),e.exports=r},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,c=e[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=n(0),u=(o.InternalError,o.LoopCont),c=o.LoopBreak,s="undefined"==typeof Symbol?function(e){return e}:function(e){return Symbol(e)},a=s("_loop_term_label"),l=function(e,t,n,r,i){i&&i()||e.add(function(e){var o=e.state,s=t._exec_stack,l=s.length,h=[n,function(t,n){!function(e,t,n,r,i){if(t===u){var o=r[a];o&&o!==i||(r.last_exception=null,e._root._handle_success())}else if(t===c){var s=r[a];s&&s!==i||(r.last_exception=null,n._queue.length=0,e._root._handle_success())}}(t,n,e,o,r)}],_=[function(e){i&&i()||(s.length=l,f())},null],f=function(){e._queue=[h,_]};f()})},h=function(e,t,n,r,i){var o=0,u=n;l(e,t,function(e){r(e,o++)},i,function(){return o>=u})},_=[];Object.freeze(_);var f=function(){};e.exports=t={noop:f,makeSym:s,loop:l,repeat:h,forEach:function(e,t,n,r,o){if(Array.isArray(n)){var u=n;h(e,t,u.length,function(e,t){r(e,t,u[t])},o)}else if("undefined"!=typeof Map&&n instanceof Map){var c=n.entries();l(e,t,function(e){var t=c.next();t.done&&e.break();var n=i(t.value,2),o=n[0],u=n[1];r(e,o,u)},o)}else{var s=n,a=Object.keys(s);h(e,t,a.length,function(e,t){r(e,a[t],s[a[t]])},o)}},LOOP_TERM_LABEL:a,as_await:function(e,t,n,r){var i,o;n.then(function(e){i?i.state&&t._burst_success([e]):o=function(){t._handle_success([e])}},function(e){i?function(e,t,n){var r=e.state;if(r)if(e._on_cancel=null,n instanceof Error)r.last_exception=n,r.error_info=void 0,t._handle_error("PromiseReject");else{var i=n||"PromiseReject";r.last_exception=new Error(i),r.error_info=void 0,t._handle_error(i)}}(i,t,e):(i=null,o=e instanceof Error?function(){throw e}:function(t){t.error(e||"PromiseReject")})}),e.add(function(e){o?o(e):(i=e,e._on_cancel=function(){if(i){i=null;try{n.cancel()}catch(e){}}})},r)},EMPTY_ARRAY:_,prev_queue:function(e){var t=e._stack,n=t.length;return n>1?t[n-2]._queue:e._queue}},t.isProduction=!0,t.checkFunc=f,t.checkOnError=f;var v=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"push",value:function(){}},{key:"length",get:function(){return 0},set:function(e){}}])&&r(t.prototype,n),i&&r(t,i),e}());Object.freeze(v),t.newExecStack=function(){return v}},function(e,t,n){"use strict";if(t=e.exports={},"undefined"==typeof setImmediate){t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){return clearTimeout(e)},window._FutoInEventLoopQueue=window._FutoInEventLoopQueue||[];var r=window._FutoInEventLoopQueue,i=window.performance,o=null,u=function(){o&&clearTimeout(o),o=setTimeout(c,0)},c=function(){o=null;for(var e=i.now()+10;r.length;){var t=r.shift();try{t()}catch(e){throw u(),e}if(i.now()>=e){u();break}}};t.callImmediate=function(e){r.length||u();var t=function(){e()};return r.push(t),t},t.cancelImmediate=function(e){var t=r.indexOf(e);t>=0&&r.splice(t,1)}}else t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){clearTimeout(e)},t.callImmediate=function(e){return setImmediate(e)},t.cancelImmediate=function(e){clearImmediate(e)}},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=n(1),o=i.checkFunc,u=i.checkOnError,c=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this._as=n,this._queue=[],this._psteps=[],this._complete_count=0}var t,n,i;return t=e,(n=[{key:"add",value:function(e,t){return o(this,e),u(this,t),this._queue.push([e,t]),this}},{key:"_complete",value:function(){this._complete_count+=1,this._complete_count===this._psteps.length&&(this._as._root._handle_success(),this._cleanup())}},{key:"_error",value:function(e,t){try{this._as.error(e,t)}catch(e){}}},{key:"executeParallel",value:function(t){var n=this,r=this._queue,i=this._root;if(i!==t._root){var o=new e(t._root,t);return o._queue.push.apply(o._queue,r),void o.executeParallel(t)}if(this._as=t,r.length){t._on_cancel=function(){n.cancel()};var u=this._psteps,c=function(e){n._complete()},s=function(e,t){n._error(t,e.state.error_info)},a=i.constructor;r.forEach(function(e){var n=new a(t.state,i._async_tool);n._queue.push([function(t){t._queue=[[e[0],e[1]]]},s],[c,void 0]),u.push(n)}),u.forEach(function(e){e.execute()})}else this._complete()}},{key:"cancel",value:function(){this._psteps.forEach(function(e){e.cancel()}),this._cleanup()}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this._as=null,this._psteps=null}}])&&r(t.prototype,n),i&&r(t,i),e}();e.exports=c},function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(2),u=n(0).InternalError,c=n(9),s=n(3),a=n(1),l=a.isProduction,h=a.checkFunc,_=a.checkOnError,f=a.noop,v=a.loop,p=a.repeat,y=a.forEach,d=a.as_await,m=a.EMPTY_ARRAY,x=a.newExecStack,k=l?f:function(e){e._stack.length>0&&e.error(u,"Top level add in execution")},g=l?f:function(e,t,n){k(e),h(e,t),_(e,n)},w=100,E=w,b=null,q=function(e){e._post_exec=f,e._execute()},A=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),null===n&&(n=function(){return this.state}),this.state=n,this._queue=[],this._stack=[],this._exec_stack=x(),this._in_exec=!1,this._post_exec=f,this._exec_event=null,this._next_args=m,this._async_tool=r;var i=r.callImmediate,u=function(){E=w,b=t,t._exec_event=null,t._execute()};this._scheduleExecute=function(){--E<=0||!t._in_exec||b!==t?t._exec_event=i(u):t._in_exec&&(t._post_exec=q)}}var t,n,a;return t=e,(n=[{key:"add",value:function(e,t){return g(this,e,t),this._queue.push([e,t]),this}},{key:"parallel",value:function(e){k(this),_(this,e);var t=new s(this,this);return this._queue.push([function(e){t.executeParallel(e)},e]),t}},{key:"sync",value:function(e,t,n){return g(this,t,n),e.sync(this,t,n),this}},{key:"error",value:function(e,t){this.state.error_info=t;var n=new Error(e);throw this._in_exec||(this.state.last_exception=n,this._handle_error(e)),n}},{key:"copyFrom",value:function(e){this._queue.push.apply(this._queue,e._queue);var t=e.state,n=this.state;for(var r in t)r in n||(n[r]=t[r]);return this}},{key:"_handle_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m,t=this._stack;t.length||this.error(u,"Invalid success completion"),this._next_args=e;for(var n=t[t.length-1];;){var r=n._limit_event;if(r&&(this._async_tool.cancelCall(r),n._limit_event=null),n._cleanup(),t.pop(),!t.length)break;if((n=t[t.length-1])._queue.length)break}(t.length||this._queue.length)&&this._scheduleExecute()}},{key:"_handle_error",value:function(e){if(this._exec_event)this.cancel();else{this._next_args=m;var t=this._stack,n=this._exec_stack;this.state.async_stack=n;for(var r=this._in_exec,i=!0;t.length;){var o=t[t.length-1],u=o._limit_event,c=o._on_cancel,s=o._on_error;if(u&&(this._async_tool.cancelCall(u),o._limit_event=null),c&&(c.call(null,o),o._on_cancel=null),s){var a=t.length;o._queue=null,o._on_error=null,n.push(s);try{if(this._in_exec=!0,s.call(null,o,e),a!==t.length){i=!1;break}if(null!==o._queue){i=!1,this._scheduleExecute();break}}catch(t){this.state.last_exception=t,e=t.message}finally{this._in_exec=r}}o._cleanup(),t.pop()}i?this._queue=[]:r||this._post_exec(this)}}},{key:"cancel",value:function(){this._next_args=m;var e=this._exec_event;e&&(this._async_tool.cancelImmediate(e),this._exec_event=null);for(var t=this._stack,n=this._async_tool;t.length;){var r=t.pop(),i=r._limit_event,o=r._on_cancel;i&&(n.cancelCall(i),r._limit_event=null),o&&(o.call(null,r),r._on_cancel=null),r._cleanup()}return this._queue=[],this}},{key:"execute",value:function(){var e=b;return b=this,this._execute(),b=e,this}},{key:"_execute",value:function(){var e,t=this._stack;if((e=t.length?t[t.length-1]._queue:this._queue).length){var n=e.shift(),i=n[0];this._exec_stack.push(i);var o=this._next_args,u=o.length,s=new c(this,n[1],o);t.push(s);try{var a=t.length;this._in_exec=!0,u?(this._next_args=m,i.apply(void 0,[s].concat(r(o)))):i(s),a===t.length&&(null!==s._queue?this._scheduleExecute():s._on_cancel||s._limit_event||this._handle_success(this._next_args))}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}}},{key:"_burst_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;try{this._in_exec=!0,b=this,this._handle_success(e)}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}},{key:"loop",value:function(e,t){return g(this,e),v(this,this,e,t),this}},{key:"repeat",value:function(e,t,n){return g(this,t),p(this,this,e,t,n),this}},{key:"forEach",value:function(e,t,n){return g(this,t),y(this,this,e,t,n),this}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];k(this);var i=this._queue;return i.length>0?i.push([function(){e._handle_success(n)},void 0]):this._next_args=n,this}},{key:"await",value:function(e,t){return k(this),d(this,this,e,t),this}},{key:"promise",value:function(){var e=this;return k(this),new Promise(function(t,n){var r=e._queue;e._queue=[[function(e){e._queue=r},function(e,t){n(new Error(t))}],[function(e,n){t(n)},void 0]],b=e,e._execute()})}},{key:"isAsyncSteps",value:function(){return!0}}])&&i(t.prototype,n),a&&i(t,a),e}();e.exports=A},,function(e,t,n){"use strict";var r=n(2),i=n(7),o=n(0),u=n(4),c=n(1).isProduction;(t=e.exports=function(){return new u(null,t.ActiveAsyncTool)}).ActiveAsyncTool=r,t.AsyncTool=r,t.AsyncToolTest=i,t.FutoInError=o,t.Errors=o,t.AsyncSteps=u,t.isProduction=c,t.installAsyncToolTest=function(e){t.ActiveAsyncTool=!1===e?r:i},t.assertAS=function(e){try{if(e.isAsyncSteps())return}catch(e){}throw new Error("Not an instance of AsyncSteps: ".concat(e))}},function(e,t,n){"use strict";var r=n(8),i=[];(t=e.exports={}).callLater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=1e3*r();t&&(n+=t);for(var o={f:e,t:n},u=0;u<i.length;++u)if(i[u].t>n)return void i.splice(u,0,o);return i.push(o),o},t.cancelCall=function(e){var t=i.indexOf(e);t>=0&&i.splice(t,1)},t.nextEvent=function(){i.shift().f()},t.hasEvents=function(){return i.length>0},t.getEvents=function(){return i},t.resetEvents=function(){i.splice(0,i.length)},t.run=function(){for(;this.hasEvents();)this.nextEvent()},t.callImmediate=t.callLater,t.cancelImmediate=t.cancelCall},function(e,t){(function(){var t,n,r,i,o,u;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,i=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),u=1e9*process.uptime(),o=i-u):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=n(3),o=n(0),u=o.InternalError,c=o.Timeout,s=o.LoopBreak,a=o.LoopCont,l=n(1),h=l.isProduction,_=l.checkFunc,f=l.checkOnError,v=l.noop,p=l.loop,y=l.repeat,d=l.forEach,m=l.LOOP_TERM_LABEL,x=l.as_await,k=h?v:function(e){var t=e._root;if(t){var n=t._stack;if(n){if(n[n.length-1]===e)return;t.error(u,"Invalid call (sanity check)")}}throw new Error("InternalError: Unexpected call, object is out of service")},g=h?v:function(e,t,n){k(e),_(e,t),f(e,n)},w=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this.state=t.state,this._queue=null,this._call_args=r,this._on_error=n,this._on_cancel=null,this._limit_event=null}var t,n,o;return t=e,(n=[{key:"add",value:function(e,t){g(this,e,t);var n=[e,t],r=this._queue;return r?r.push(n):this._queue=[n],this}},{key:"parallel",value:function(e){var t=new i(this._root,this);return this.add(function(e){t.executeParallel(e)},e),t}},{key:"success",value:function(){k(this),null!==this._queue&&this.error(u,"Invalid success() call");for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._root._handle_success(t)}},{key:"error",value:function(e,t){k(this),this._root.error(e,t)}},{key:"setTimeout",value:function(e){var t=this;k(this);var n=this._root._async_tool;return null!==this._limit_event&&n.cancelCall(this._limit_event),this._limit_event=n.callLater(function(){!function(e){e._limit_event=null;var t=e.state;t.error_info=void 0,t.last_exception=new Error(c),e._root._handle_error(c)}(t)},e),this}},{key:"setCancel",value:function(e){return this._on_cancel=e,this}},{key:"waitExternal",value:function(){return this._on_cancel=v,this}},{key:"copyFrom",value:function(e){if(k(this),e._queue.length){var t=this._queue;null===t&&(t=[],this._queue=t),t.push.apply(t,e._queue)}var n=e.state,r=this.state;for(var i in n)void 0===r[i]&&(r[i]=n[i]);return this}},{key:"loop",value:function(e,t){return g(this,e),p(this,this._root,e,t),this}},{key:"repeat",value:function(e,t,n){return g(this,t),y(this,this._root,e,t,n),this}},{key:"forEach",value:function(e,t,n){return g(this,t),d(this,this._root,e,t,n),this}},{key:"break",value:function(e){k(this),this.state[m]=e,this._root.error(s)}},{key:"continue",value:function(e){k(this),this.state[m]=e,this._root.error(a)}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];k(this);var i=this._queue;return i&&i.length?i.push([function(){e._root._handle_success(n)},void 0]):this._root._next_args=n,this}},{key:"await",value:function(e,t){return k(this),x(this,this._root,e,t),this}},{key:"sync",value:function(e,t,n){return g(this,t,n),e.sync(this,t,n),this}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this.state=null}}])&&r(t.prototype,n),o&&r(t,o),e}();e.exports=w},,,,,,,function(e,t,n){"use strict";!function(t){var r=t.FutoIn||t.futoin||{};if(void 0===r.AsyncSteps){var i=n(6);t.$as=i,r.$as=i,t.FutoInError=i.FutoInError,r.AsyncSteps=i.AsyncSteps,t.FutoIn=r,t.futoin=r}e.exports=r.$as}(window)}])});

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["futoin-asyncsteps"]=t():e.$as=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=12)}([function(e,t,n){"use strict";var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};["ConnectError","CommError","UnknownInterface","NotSupportedVersion","NotImplemented","Unauthorized","InternalError","InvokerError","InvalidRequest","DefenseRejected","PleaseReauth","SecurityError","Timeout","LoopBreak","LoopCont"].forEach(function(e){return Object.defineProperty(r,e,{enumerable:!0,value:e})}),e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,c=e[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var i=n(0),u=(i.InternalError,i.LoopCont),c=i.LoopBreak,s="undefined"==typeof Symbol?function(e){return e}:function(e){return Symbol(e)},a=s("_loop_term_label"),l=function(e,t,n,r,o){o&&o()||e.add(function(e){var i=e.state,s=t._exec_stack,l=s.length,f=[n,function(t,n){!function(e,t,n,r,o){if(t===u){var i=r[a];i&&i!==o||(r.last_exception=null,e._root._handle_success())}else if(t===c){var s=r[a];s&&s!==o||(r.last_exception=null,n._queue.length=0,e._root._handle_success())}}(t,n,e,i,r)}],_=[function(e){o&&o()||(s.length=l,h())},null],h=function(){e._queue=[f,_]};h()})},f=function(e,t,n,r,o){var i=0,u=n;l(e,t,function(e){r(e,i++)},o,function(){return i>=u})},_=[];Object.freeze(_);var h=function(){};e.exports=t={noop:h,makeSym:s,loop:l,repeat:f,forEach:function(e,t,n,r,i){if(Array.isArray(n)){var u=n;f(e,t,u.length,function(e,t){r(e,t,u[t])},i)}else if("undefined"!=typeof Map&&n instanceof Map){var c=n.entries();l(e,t,function(e){var t=c.next();t.done&&e.break();var n=o(t.value,2),i=n[0],u=n[1];r(e,i,u)},i)}else{var s=n,a=Object.keys(s);f(e,t,a.length,function(e,t){r(e,a[t],s[a[t]])},i)}},LOOP_TERM_LABEL:a,as_await:function(e,t,n,r){var o=void 0,i=void 0;n.then(function(e){o?o.state&&t._burst_success([e]):i=function(){t._handle_success([e])}},function(e){o?function(e,t,n){var r=e.state;if(r)if(e._on_cancel=null,n instanceof Error)r.last_exception=n,r.error_info=void 0,t._handle_error("PromiseReject");else{var o=n||"PromiseReject";r.last_exception=new Error(o),r.error_info=void 0,t._handle_error(o)}}(o,t,e):(o=null,i=e instanceof Error?function(){throw e}:function(t){t.error(e||"PromiseReject")})}),e.add(function(e){i?i(e):(o=e,e._on_cancel=function(){if(o){o=null;try{n.cancel()}catch(e){}}})},r)},EMPTY_ARRAY:_,prev_queue:function(e){var t=e._stack,n=t.length;return n>1?t[n-2]._queue:e._queue}},t.isProduction=!0,t.checkFunc=h,t.checkOnError=h;var v=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"push",value:function(){}},{key:"length",get:function(){return 0},set:function(e){}}]),e}());Object.freeze(v),t.newExecStack=function(){return v}},function(e,t,n){"use strict";if(t=e.exports={},"undefined"==typeof setImmediate){t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){return clearTimeout(e)},window._FutoInEventLoopQueue=window._FutoInEventLoopQueue||[];var r=window._FutoInEventLoopQueue,o=window.performance,i=null,u=function(){i&&clearTimeout(i),i=setTimeout(c,0)},c=function(){i=null;for(var e=o.now()+10;r.length;){var t=r.shift();try{t()}catch(e){throw u(),e}if(o.now()>=e){u();break}}};t.callImmediate=function(e){r.length||u();var t=function(){e()};return r.push(t),t},t.cancelImmediate=function(e){var t=r.indexOf(e);t>=0&&r.splice(t,1)}}else t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){clearTimeout(e)},t.callImmediate=function(e){return setImmediate(e)},t.cancelImmediate=function(e){clearImmediate(e)}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(1),i=o.checkFunc,u=o.checkOnError,c=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this._as=n,this._queue=[],this._psteps=[],this._complete_count=0}return r(e,[{key:"add",value:function(e,t){return i(this,e),u(this,t),this._queue.push([e,t]),this}},{key:"_complete",value:function(){this._complete_count+=1,this._complete_count===this._psteps.length&&(this._as._root._handle_success(),this._cleanup())}},{key:"_error",value:function(e,t){try{this._as.error(e,t)}catch(e){}}},{key:"executeParallel",value:function(t){var n=this,r=this._queue,o=this._root;if(o!==t._root){var i=new e(t._root,t);return i._queue.push.apply(i._queue,r),void i.executeParallel(t)}if(this._as=t,r.length){t._on_cancel=function(){n.cancel()};var u=this._psteps,c=function(e){n._complete()},s=function(e,t){n._error(t,e.state.error_info)},a=o.constructor;r.forEach(function(e){var n=new a(t.state,o._async_tool);n._queue.push([function(t){t._queue=[[e[0],e[1]]]},s],[c,void 0]),u.push(n)}),u.forEach(function(e){e.execute()})}else this._complete()}},{key:"cancel",value:function(){this._psteps.forEach(function(e){e.cancel()}),this._cleanup()}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this._as=null,this._psteps=null}}]),e}();e.exports=c},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(2),i=n(0).InternalError,u=n(9),c=n(3),s=n(1),a=s.isProduction,l=s.checkFunc,f=s.checkOnError,_=s.noop,h=s.loop,v=s.repeat,p=s.forEach,y=s.as_await,d=s.EMPTY_ARRAY,m=s.newExecStack,x=a?_:function(e){e._stack.length>0&&e.error(i,"Top level add in execution")},g=a?_:function(e,t,n){x(e),l(e,t),f(e,n)},b=100,k=b,w=null,E=function(e){e._post_exec=_,e._execute()},q=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),null===n&&(n=function(){return this.state}),this.state=n,this._queue=[],this._stack=[],this._exec_stack=m(),this._in_exec=!1,this._post_exec=_,this._exec_event=null,this._next_args=d,this._async_tool=r;var i=r.callImmediate,u=function(){k=b,w=t,t._exec_event=null,t._execute()};this._scheduleExecute=function(){--k<=0||!t._in_exec||w!==t?t._exec_event=i(u):t._in_exec&&(t._post_exec=E)}}return r(e,[{key:"add",value:function(e,t){return g(this,e,t),this._queue.push([e,t]),this}},{key:"parallel",value:function(e){x(this),f(this,e);var t=new c(this,this);return this._queue.push([function(e){t.executeParallel(e)},e]),t}},{key:"sync",value:function(e,t,n){return g(this,t,n),e.sync(this,t,n),this}},{key:"error",value:function(e,t){this.state.error_info=t;var n=new Error(e);throw this._in_exec||(this.state.last_exception=n,this._handle_error(e)),n}},{key:"copyFrom",value:function(e){this._queue.push.apply(this._queue,e._queue);var t=e.state,n=this.state;for(var r in t)r in n||(n[r]=t[r]);return this}},{key:"_handle_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,t=this._stack;t.length||this.error(i,"Invalid success completion"),this._next_args=e;for(var n=t[t.length-1];;){var r=n._limit_event;if(r&&(this._async_tool.cancelCall(r),n._limit_event=null),n._cleanup(),t.pop(),!t.length)break;if((n=t[t.length-1])._queue.length)break}(t.length||this._queue.length)&&this._scheduleExecute()}},{key:"_handle_error",value:function(e){if(this._exec_event)this.cancel();else{this._next_args=d;var t=this._stack,n=this._exec_stack;this.state.async_stack=n;for(var r=this._in_exec,o=!0;t.length;){var i=t[t.length-1],u=i._limit_event,c=i._on_cancel,s=i._on_error;if(u&&(this._async_tool.cancelCall(u),i._limit_event=null),c&&(c.call(null,i),i._on_cancel=null),s){var a=t.length;i._queue=null,i._on_error=null,n.push(s);try{if(this._in_exec=!0,s.call(null,i,e),a!==t.length){o=!1;break}if(null!==i._queue){o=!1,this._scheduleExecute();break}}catch(t){this.state.last_exception=t,e=t.message}finally{this._in_exec=r}}i._cleanup(),t.pop()}o?this._queue=[]:r||this._post_exec(this)}}},{key:"cancel",value:function(){this._next_args=d;var e=this._exec_event;e&&(this._async_tool.cancelImmediate(e),this._exec_event=null);for(var t=this._stack,n=this._async_tool;t.length;){var r=t.pop(),o=r._limit_event,i=r._on_cancel;o&&(n.cancelCall(o),r._limit_event=null),i&&(i.call(null,r),r._on_cancel=null),r._cleanup()}return this._queue=[],this}},{key:"execute",value:function(){var e=w;return w=this,this._execute(),w=e,this}},{key:"_execute",value:function(){var e=this._stack,t=void 0;if((t=e.length?e[e.length-1]._queue:this._queue).length){var n=t.shift(),r=n[0];this._exec_stack.push(r);var o=this._next_args,i=o.length,c=new u(this,n[1],o);e.push(c);try{var s=e.length;this._in_exec=!0,i?(this._next_args=d,r.apply(void 0,[c].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(o)))):r(c),s===e.length&&(null!==c._queue?this._scheduleExecute():c._on_cancel||c._limit_event||this._handle_success(this._next_args))}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}}},{key:"_burst_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;try{this._in_exec=!0,w=this,this._handle_success(e)}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}},{key:"loop",value:function(e,t){return g(this,e),h(this,this,e,t),this}},{key:"repeat",value:function(e,t,n){return g(this,t),v(this,this,e,t,n),this}},{key:"forEach",value:function(e,t,n){return g(this,t),p(this,this,e,t,n),this}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];x(this);var o=this._queue;return o.length>0?o.push([function(){e._handle_success(n)},void 0]):this._next_args=n,this}},{key:"await",value:function(e,t){return x(this),y(this,this,e,t),this}},{key:"promise",value:function(){var e=this;return x(this),new Promise(function(t,n){var r=e._queue;e._queue=[[function(e){e._queue=r},function(e,t){n(new Error(t))}],[function(e,n){t(n)},void 0]],w=e,e._execute()})}},{key:"isAsyncSteps",value:function(){return!0}}]),e}();e.exports=q},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(0).NotImplemented,i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"sync",value:function(e,t,n){e.error(o,"#sync() API")}}]),e}();e.exports=i},function(e,t,n){"use strict";var r=n(2),o=n(7),i=n(0),u=n(4),c=n(1).isProduction;(t=e.exports=function(){return new u(null,t.ActiveAsyncTool)}).ActiveAsyncTool=r,t.AsyncTool=r,t.AsyncToolTest=o,t.FutoInError=i,t.Errors=i,t.AsyncSteps=u,t.isProduction=c,t.installAsyncToolTest=function(e){t.ActiveAsyncTool=!1===e?r:o},t.assertAS=function(e){try{if(e.isAsyncSteps())return}catch(e){}throw new Error("Not an instance of AsyncSteps: "+e)}},function(e,t,n){"use strict";var r=n(8),o=[];(t=e.exports={}).callLater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=1e3*r();t&&(n+=t);for(var i={f:e,t:n},u=0;u<o.length;++u)if(o[u].t>n)return void o.splice(u,0,i);return o.push(i),i},t.cancelCall=function(e){var t=o.indexOf(e);t>=0&&o.splice(t,1)},t.nextEvent=function(){o.shift().f()},t.hasEvents=function(){return o.length>0},t.getEvents=function(){return o},t.resetEvents=function(){o.splice(0,o.length)},t.run=function(){for(;this.hasEvents();)this.nextEvent()},t.callImmediate=t.callLater,t.cancelImmediate=t.cancelCall},function(e,t){(function(){var t,n,r,o,i,u;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-i)/1e6},n=process.hrtime,o=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),u=1e9*process.uptime(),i=o-u):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(3),i=n(0),u=i.InternalError,c=i.Timeout,s=i.LoopBreak,a=i.LoopCont,l=n(1),f=l.isProduction,_=l.checkFunc,h=l.checkOnError,v=l.noop,p=l.loop,y=l.repeat,d=l.forEach,m=l.LOOP_TERM_LABEL,x=l.as_await,g=f?v:function(e){var t=e._root;if(t){var n=t._stack;if(n){if(n[n.length-1]===e)return;t.error(u,"Invalid call (sanity check)")}}throw new Error("InternalError: Unexpected call, object is out of service")},b=f?v:function(e,t,n){g(e),_(e,t),h(e,n)},k=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this.state=t.state,this._queue=null,this._call_args=r,this._on_error=n,this._on_cancel=null,this._limit_event=null}return r(e,[{key:"add",value:function(e,t){b(this,e,t);var n=[e,t],r=this._queue;return r?r.push(n):this._queue=[n],this}},{key:"parallel",value:function(e){var t=new o(this._root,this);return this.add(function(e){t.executeParallel(e)},e),t}},{key:"success",value:function(){g(this),null!==this._queue&&this.error(u,"Invalid success() call");for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._root._handle_success(t)}},{key:"error",value:function(e,t){g(this),this._root.error(e,t)}},{key:"setTimeout",value:function(e){var t=this;g(this);var n=this._root._async_tool;return null!==this._limit_event&&n.cancelCall(this._limit_event),this._limit_event=n.callLater(function(){!function(e){e._limit_event=null;var t=e.state;t.error_info=void 0,t.last_exception=new Error(c),e._root._handle_error(c)}(t)},e),this}},{key:"setCancel",value:function(e){return this._on_cancel=e,this}},{key:"waitExternal",value:function(){return this._on_cancel=v,this}},{key:"copyFrom",value:function(e){if(g(this),e._queue.length){var t=this._queue;null===t&&(t=[],this._queue=t),t.push.apply(t,e._queue)}var n=e.state,r=this.state;for(var o in n)void 0===r[o]&&(r[o]=n[o]);return this}},{key:"loop",value:function(e,t){return b(this,e),p(this,this._root,e,t),this}},{key:"repeat",value:function(e,t,n){return b(this,t),y(this,this._root,e,t,n),this}},{key:"forEach",value:function(e,t,n){return b(this,t),d(this,this._root,e,t,n),this}},{key:"break",value:function(e){g(this),this.state[m]=e,this._root.error(s)}},{key:"continue",value:function(e){g(this),this.state[m]=e,this._root.error(a)}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];g(this);var o=this._queue;return o&&o.length?o.push([function(){e._root._handle_success(n)},void 0]):this._root._next_args=n,this}},{key:"await",value:function(e,t){return g(this),x(this,this._root,e,t),this}},{key:"sync",value:function(e,t,n){return b(this,t,n),e.sync(this,t,n),this}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this.state=null}}]),e}();e.exports=k},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(5),i=n(0).DefenseRejected,u=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r._max=e,r._locked=0,r._owners=new WeakMap,r._queue=[],r._max_queue=n,r._release_handler=function(e){r._release(e._root)},r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"_lock",value:function(e,t){var n=this._owners,r=n.get(t);if(r)return n.set(t,r+1),!0;if(this._locked>=this._max){var o=this._queue,u=this._max_queue;return null!==u&&o.length>=u&&t.error(i,"Mutex queue limit"),o.push(e),!1}return this._locked+=1,n.set(t,1),!0}},{key:"_release",value:function(e){var t=this._owners,n=t.get(e);if(n){if(n>1)return void t.set(e,n-1);t.delete(e),this._locked-=1;for(var r=this._queue;r.length;){var o=r.shift();if(o.state){var i=o._root;this._lock(o,i),i._handle_success(o._call_args);break}}}else{var u=this._queue.indexOf(e);u>=0&&this._queue.splice(u,1)}}},{key:"sync",value:function(e,t,n){var r=this;e.add(function(e){!function(e,t,n,r){var o=e._root;e._on_cancel=t._release_handler,e._queue=[[function(n){t._lock(e,o)?o._handle_success(e._call_args):(n.waitExternal(),n._call_args=e._call_args)},void 0],[n,r],[function(e){t._release(o),o._handle_success(e._call_args)},void 0]]}(e,r,t,n)})}}]),t}();e.exports=u},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(5),i=n(0).DefenseRejected,u=n(1).prev_queue,c=function(e,t,n,r){var o=e._root;t._lock(e)?(e._on_error=r,n.apply(void 0,[e].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(e._call_args)))):(e._on_cancel=t._cancel_handler,o._next_args=e._call_args,u(o).unshift([n,r]))},s=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o._max=e,o._current=0;var i=o._queue=[];return o._timer=null,o._period_ms=n,o._max_queue=r,o._cancel_handler=function(e){var t=i.indexOf(e);t>=0&&i.splice(t,1)},o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"_lock",value:function(e){if(this._ensureTimer(),this._current>=this._max){var t=this._queue,n=this._max_queue;return null!==n&&t.length>=n&&e.error(i,"Throttle queue limit"),t.push(e),!1}return this._current+=1,!0}},{key:"_ensureTimer",value:function(){var e=this;this._timer||(this._timer=setInterval(function(){e._resetPeriod()},this._period_ms))}},{key:"_resetPeriod",value:function(){this._current=0;var e=this._queue;if(!e.length)return clearInterval(this._timer),void(this._timer=null);for(var t=this._max,n=0;e.length&&n<t;){var r=e.shift();if(r.state){++n;var o=r._root;o._handle_success(o._next_args)}}this._current=n}},{key:"sync",value:function(e,t,n){var r=this;e.add(function(e){c(e,r,t,n)})}}]),t}();e.exports=s},function(e,t,n){"use strict";!function(t){var r=t.FutoIn||t.futoin||{};if(void 0===r.AsyncSteps){var o=n(13);t.$as=o,r.$as=o,t.FutoInError=o.FutoInError,r.AsyncSteps=o.AsyncSteps,t.FutoIn=r,t.futoin=r}e.exports=r.$as}(window)},function(e,t,n){"use strict";(t=e.exports=n(6)).ISync=n(5),t.Mutex=n(10),t.Throttle=n(11),t.Limiter=n(14),t.testcase=n(15)},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(5),i=n(10),u=n(11),c=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._mutex=new i(e.concurrent||1,e.max_queue||0),n._throttle=new u(e.rate||1,e.period_ms||1e3,e.burst||0),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"sync",value:function(e,t,n){var r=this;e.sync(this._mutex,function(e){e._root._next_args=e._call_args,e.sync(r._throttle,t,n)})}}]),t}();e.exports=c},function(e,t,n){"use strict";var r=n(4);e.exports=function(e,t){return function(n){var o=this,i=new r;i.add(function(n){n.add(function(n){e.call(o,n),t&&n.add(function(e){e.error("NegativeTestMustThrow")})},t)},function(e,t){console.log("ERROR: "+t+" ("+e.state.error_info+")"),n(e.state.last_exception||new Error("Generic Fail"))}),i.add(function(e){return n()}),i.execute()}}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["futoin-asyncsteps"]=t():e.$as=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=12)}([function(e,t,n){"use strict";var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};["ConnectError","CommError","UnknownInterface","NotSupportedVersion","NotImplemented","Unauthorized","InternalError","InvokerError","InvalidRequest","DefenseRejected","PleaseReauth","SecurityError","Timeout","LoopBreak","LoopCont"].forEach(function(e){return Object.defineProperty(r,e,{enumerable:!0,value:e})}),e.exports=r},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,c=e[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var i=n(0),u=(i.InternalError,i.LoopCont),c=i.LoopBreak,s="undefined"==typeof Symbol?function(e){return e}:function(e){return Symbol(e)},a=s("_loop_term_label"),l=function(e,t,n,r,o){o&&o()||e.add(function(e){var i=e.state,s=t._exec_stack,l=s.length,f=[n,function(t,n){!function(e,t,n,r,o){if(t===u){var i=r[a];i&&i!==o||(r.last_exception=null,e._root._handle_success())}else if(t===c){var s=r[a];s&&s!==o||(r.last_exception=null,n._queue.length=0,e._root._handle_success())}}(t,n,e,i,r)}],_=[function(e){o&&o()||(s.length=l,h())},null],h=function(){e._queue=[f,_]};h()})},f=function(e,t,n,r,o){var i=0,u=n;l(e,t,function(e){r(e,i++)},o,function(){return i>=u})},_=[];Object.freeze(_);var h=function(){};e.exports=t={noop:h,makeSym:s,loop:l,repeat:f,forEach:function(e,t,n,r,i){if(Array.isArray(n)){var u=n;f(e,t,u.length,function(e,t){r(e,t,u[t])},i)}else if("undefined"!=typeof Map&&n instanceof Map){var c=n.entries();l(e,t,function(e){var t=c.next();t.done&&e.break();var n=o(t.value,2),i=n[0],u=n[1];r(e,i,u)},i)}else{var s=n,a=Object.keys(s);f(e,t,a.length,function(e,t){r(e,a[t],s[a[t]])},i)}},LOOP_TERM_LABEL:a,as_await:function(e,t,n,r){var o,i;n.then(function(e){o?o.state&&t._burst_success([e]):i=function(){t._handle_success([e])}},function(e){o?function(e,t,n){var r=e.state;if(r)if(e._on_cancel=null,n instanceof Error)r.last_exception=n,r.error_info=void 0,t._handle_error("PromiseReject");else{var o=n||"PromiseReject";r.last_exception=new Error(o),r.error_info=void 0,t._handle_error(o)}}(o,t,e):(o=null,i=e instanceof Error?function(){throw e}:function(t){t.error(e||"PromiseReject")})}),e.add(function(e){i?i(e):(o=e,e._on_cancel=function(){if(o){o=null;try{n.cancel()}catch(e){}}})},r)},EMPTY_ARRAY:_,prev_queue:function(e){var t=e._stack,n=t.length;return n>1?t[n-2]._queue:e._queue}},t.isProduction=!0,t.checkFunc=h,t.checkOnError=h;var p=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,o;return t=e,(n=[{key:"push",value:function(){}},{key:"length",get:function(){return 0},set:function(e){}}])&&r(t.prototype,n),o&&r(t,o),e}());Object.freeze(p),t.newExecStack=function(){return p}},function(e,t,n){"use strict";if(t=e.exports={},"undefined"==typeof setImmediate){t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){return clearTimeout(e)},window._FutoInEventLoopQueue=window._FutoInEventLoopQueue||[];var r=window._FutoInEventLoopQueue,o=window.performance,i=null,u=function(){i&&clearTimeout(i),i=setTimeout(c,0)},c=function(){i=null;for(var e=o.now()+10;r.length;){var t=r.shift();try{t()}catch(e){throw u(),e}if(o.now()>=e){u();break}}};t.callImmediate=function(e){r.length||u();var t=function(){e()};return r.push(t),t},t.cancelImmediate=function(e){var t=r.indexOf(e);t>=0&&r.splice(t,1)}}else t.callLater=function(e,t){return setTimeout(e,t)},t.cancelCall=function(e){clearTimeout(e)},t.callImmediate=function(e){return setImmediate(e)},t.cancelImmediate=function(e){clearImmediate(e)}},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(1),i=o.checkFunc,u=o.checkOnError,c=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this._as=n,this._queue=[],this._psteps=[],this._complete_count=0}var t,n,o;return t=e,(n=[{key:"add",value:function(e,t){return i(this,e),u(this,t),this._queue.push([e,t]),this}},{key:"_complete",value:function(){this._complete_count+=1,this._complete_count===this._psteps.length&&(this._as._root._handle_success(),this._cleanup())}},{key:"_error",value:function(e,t){try{this._as.error(e,t)}catch(e){}}},{key:"executeParallel",value:function(t){var n=this,r=this._queue,o=this._root;if(o!==t._root){var i=new e(t._root,t);return i._queue.push.apply(i._queue,r),void i.executeParallel(t)}if(this._as=t,r.length){t._on_cancel=function(){n.cancel()};var u=this._psteps,c=function(e){n._complete()},s=function(e,t){n._error(t,e.state.error_info)},a=o.constructor;r.forEach(function(e){var n=new a(t.state,o._async_tool);n._queue.push([function(t){t._queue=[[e[0],e[1]]]},s],[c,void 0]),u.push(n)}),u.forEach(function(e){e.execute()})}else this._complete()}},{key:"cancel",value:function(){this._psteps.forEach(function(e){e.cancel()}),this._cleanup()}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this._as=null,this._psteps=null}}])&&r(t.prototype,n),o&&r(t,o),e}();e.exports=c},function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=n(2),u=n(0).InternalError,c=n(9),s=n(3),a=n(1),l=a.isProduction,f=a.checkFunc,_=a.checkOnError,h=a.noop,p=a.loop,v=a.repeat,y=a.forEach,d=a.as_await,m=a.EMPTY_ARRAY,b=a.newExecStack,g=l?h:function(e){e._stack.length>0&&e.error(u,"Top level add in execution")},x=l?h:function(e,t,n){g(e),f(e,t),_(e,n)},w=100,k=w,E=null,O=function(e){e._post_exec=h,e._execute()},q=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),null===n&&(n=function(){return this.state}),this.state=n,this._queue=[],this._stack=[],this._exec_stack=b(),this._in_exec=!1,this._post_exec=h,this._exec_event=null,this._next_args=m,this._async_tool=r;var o=r.callImmediate,u=function(){k=w,E=t,t._exec_event=null,t._execute()};this._scheduleExecute=function(){--k<=0||!t._in_exec||E!==t?t._exec_event=o(u):t._in_exec&&(t._post_exec=O)}}var t,n,a;return t=e,(n=[{key:"add",value:function(e,t){return x(this,e,t),this._queue.push([e,t]),this}},{key:"parallel",value:function(e){g(this),_(this,e);var t=new s(this,this);return this._queue.push([function(e){t.executeParallel(e)},e]),t}},{key:"sync",value:function(e,t,n){return x(this,t,n),e.sync(this,t,n),this}},{key:"error",value:function(e,t){this.state.error_info=t;var n=new Error(e);throw this._in_exec||(this.state.last_exception=n,this._handle_error(e)),n}},{key:"copyFrom",value:function(e){this._queue.push.apply(this._queue,e._queue);var t=e.state,n=this.state;for(var r in t)r in n||(n[r]=t[r]);return this}},{key:"_handle_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m,t=this._stack;t.length||this.error(u,"Invalid success completion"),this._next_args=e;for(var n=t[t.length-1];;){var r=n._limit_event;if(r&&(this._async_tool.cancelCall(r),n._limit_event=null),n._cleanup(),t.pop(),!t.length)break;if((n=t[t.length-1])._queue.length)break}(t.length||this._queue.length)&&this._scheduleExecute()}},{key:"_handle_error",value:function(e){if(this._exec_event)this.cancel();else{this._next_args=m;var t=this._stack,n=this._exec_stack;this.state.async_stack=n;for(var r=this._in_exec,o=!0;t.length;){var i=t[t.length-1],u=i._limit_event,c=i._on_cancel,s=i._on_error;if(u&&(this._async_tool.cancelCall(u),i._limit_event=null),c&&(c.call(null,i),i._on_cancel=null),s){var a=t.length;i._queue=null,i._on_error=null,n.push(s);try{if(this._in_exec=!0,s.call(null,i,e),a!==t.length){o=!1;break}if(null!==i._queue){o=!1,this._scheduleExecute();break}}catch(t){this.state.last_exception=t,e=t.message}finally{this._in_exec=r}}i._cleanup(),t.pop()}o?this._queue=[]:r||this._post_exec(this)}}},{key:"cancel",value:function(){this._next_args=m;var e=this._exec_event;e&&(this._async_tool.cancelImmediate(e),this._exec_event=null);for(var t=this._stack,n=this._async_tool;t.length;){var r=t.pop(),o=r._limit_event,i=r._on_cancel;o&&(n.cancelCall(o),r._limit_event=null),i&&(i.call(null,r),r._on_cancel=null),r._cleanup()}return this._queue=[],this}},{key:"execute",value:function(){var e=E;return E=this,this._execute(),E=e,this}},{key:"_execute",value:function(){var e,t=this._stack;if((e=t.length?t[t.length-1]._queue:this._queue).length){var n=e.shift(),o=n[0];this._exec_stack.push(o);var i=this._next_args,u=i.length,s=new c(this,n[1],i);t.push(s);try{var a=t.length;this._in_exec=!0,u?(this._next_args=m,o.apply(void 0,[s].concat(r(i)))):o(s),a===t.length&&(null!==s._queue?this._scheduleExecute():s._on_cancel||s._limit_event||this._handle_success(this._next_args))}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}}},{key:"_burst_success",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;try{this._in_exec=!0,E=this,this._handle_success(e)}catch(e){this.state.last_exception=e,this._handle_error(e.message)}finally{this._in_exec=!1}this._post_exec(this)}},{key:"loop",value:function(e,t){return x(this,e),p(this,this,e,t),this}},{key:"repeat",value:function(e,t,n){return x(this,t),v(this,this,e,t,n),this}},{key:"forEach",value:function(e,t,n){return x(this,t),y(this,this,e,t,n),this}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];g(this);var o=this._queue;return o.length>0?o.push([function(){e._handle_success(n)},void 0]):this._next_args=n,this}},{key:"await",value:function(e,t){return g(this),d(this,this,e,t),this}},{key:"promise",value:function(){var e=this;return g(this),new Promise(function(t,n){var r=e._queue;e._queue=[[function(e){e._queue=r},function(e,t){n(new Error(t))}],[function(e,n){t(n)},void 0]],E=e,e._execute()})}},{key:"isAsyncSteps",value:function(){return!0}}])&&o(t.prototype,n),a&&o(t,a),e}();e.exports=q},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(0).NotImplemented,i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"sync",value:function(e,t,n){e.error(o,"#sync() API")}}])&&r(t.prototype,n),i&&r(t,i),e}();e.exports=i},function(e,t,n){"use strict";var r=n(2),o=n(7),i=n(0),u=n(4),c=n(1).isProduction;(t=e.exports=function(){return new u(null,t.ActiveAsyncTool)}).ActiveAsyncTool=r,t.AsyncTool=r,t.AsyncToolTest=o,t.FutoInError=i,t.Errors=i,t.AsyncSteps=u,t.isProduction=c,t.installAsyncToolTest=function(e){t.ActiveAsyncTool=!1===e?r:o},t.assertAS=function(e){try{if(e.isAsyncSteps())return}catch(e){}throw new Error("Not an instance of AsyncSteps: ".concat(e))}},function(e,t,n){"use strict";var r=n(8),o=[];(t=e.exports={}).callLater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=1e3*r();t&&(n+=t);for(var i={f:e,t:n},u=0;u<o.length;++u)if(o[u].t>n)return void o.splice(u,0,i);return o.push(i),i},t.cancelCall=function(e){var t=o.indexOf(e);t>=0&&o.splice(t,1)},t.nextEvent=function(){o.shift().f()},t.hasEvents=function(){return o.length>0},t.getEvents=function(){return o},t.resetEvents=function(){o.splice(0,o.length)},t.run=function(){for(;this.hasEvents();)this.nextEvent()},t.callImmediate=t.callLater,t.cancelImmediate=t.cancelCall},function(e,t){(function(){var t,n,r,o,i,u;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-i)/1e6},n=process.hrtime,o=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),u=1e9*process.uptime(),i=o-u):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(3),i=n(0),u=i.InternalError,c=i.Timeout,s=i.LoopBreak,a=i.LoopCont,l=n(1),f=l.isProduction,_=l.checkFunc,h=l.checkOnError,p=l.noop,v=l.loop,y=l.repeat,d=l.forEach,m=l.LOOP_TERM_LABEL,b=l.as_await,g=f?p:function(e){var t=e._root;if(t){var n=t._stack;if(n){if(n[n.length-1]===e)return;t.error(u,"Invalid call (sanity check)")}}throw new Error("InternalError: Unexpected call, object is out of service")},x=f?p:function(e,t,n){g(e),_(e,t),h(e,n)},w=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._root=t,this.state=t.state,this._queue=null,this._call_args=r,this._on_error=n,this._on_cancel=null,this._limit_event=null}var t,n,i;return t=e,(n=[{key:"add",value:function(e,t){x(this,e,t);var n=[e,t],r=this._queue;return r?r.push(n):this._queue=[n],this}},{key:"parallel",value:function(e){var t=new o(this._root,this);return this.add(function(e){t.executeParallel(e)},e),t}},{key:"success",value:function(){g(this),null!==this._queue&&this.error(u,"Invalid success() call");for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._root._handle_success(t)}},{key:"error",value:function(e,t){g(this),this._root.error(e,t)}},{key:"setTimeout",value:function(e){var t=this;g(this);var n=this._root._async_tool;return null!==this._limit_event&&n.cancelCall(this._limit_event),this._limit_event=n.callLater(function(){!function(e){e._limit_event=null;var t=e.state;t.error_info=void 0,t.last_exception=new Error(c),e._root._handle_error(c)}(t)},e),this}},{key:"setCancel",value:function(e){return this._on_cancel=e,this}},{key:"waitExternal",value:function(){return this._on_cancel=p,this}},{key:"copyFrom",value:function(e){if(g(this),e._queue.length){var t=this._queue;null===t&&(t=[],this._queue=t),t.push.apply(t,e._queue)}var n=e.state,r=this.state;for(var o in n)void 0===r[o]&&(r[o]=n[o]);return this}},{key:"loop",value:function(e,t){return x(this,e),v(this,this._root,e,t),this}},{key:"repeat",value:function(e,t,n){return x(this,t),y(this,this._root,e,t,n),this}},{key:"forEach",value:function(e,t,n){return x(this,t),d(this,this._root,e,t,n),this}},{key:"break",value:function(e){g(this),this.state[m]=e,this._root.error(s)}},{key:"continue",value:function(e){g(this),this.state[m]=e,this._root.error(a)}},{key:"successStep",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];g(this);var o=this._queue;return o&&o.length?o.push([function(){e._root._handle_success(n)},void 0]):this._root._next_args=n,this}},{key:"await",value:function(e,t){return g(this),b(this,this._root,e,t),this}},{key:"sync",value:function(e,t,n){return x(this,t,n),e.sync(this,t,n),this}},{key:"isAsyncSteps",value:function(){return!0}},{key:"_cleanup",value:function(){this._root=null,this.state=null}}])&&r(t.prototype,n),i&&r(t,i),e}();e.exports=w},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=n(5),a=n(0).DefenseRejected,l=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=i(this,u(t).call(this)))._max=n,e._locked=0,e._owners=new WeakMap,e._queue=[],e._max_queue=r,e._release_handler=function(t){e._release(t._root)},e}var n,r,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,s),n=t,(r=[{key:"_lock",value:function(e,t){var n=this._owners,r=n.get(t);if(r)return n.set(t,r+1),!0;if(this._locked>=this._max){var o=this._queue,i=this._max_queue;return null!==i&&o.length>=i&&t.error(a,"Mutex queue limit"),o.push(e),!1}return this._locked+=1,n.set(t,1),!0}},{key:"_release",value:function(e){var t=this._owners,n=t.get(e);if(n){if(n>1)return void t.set(e,n-1);t.delete(e),this._locked-=1;for(var r=this._queue;r.length;){var o=r.shift();if(o.state){var i=o._root;this._lock(o,i),i._handle_success(o._call_args);break}}}else{var u=this._queue.indexOf(e);u>=0&&this._queue.splice(u,1)}}},{key:"sync",value:function(e,t,n){var r=this;e.add(function(e){!function(e,t,n,r){var o=e._root;e._on_cancel=t._release_handler,e._queue=[[function(n){t._lock(e,o)?o._handle_success(e._call_args):(n.waitExternal(),n._call_args=e._call_args)},void 0],[n,r],[function(e){t._release(o),o._handle_success(e._call_args)},void 0]]}(e,r,t,n)})}}])&&o(n.prototype,r),l&&o(n,l),t}();e.exports=l},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var a=n(5),l=n(0).DefenseRejected,f=n(1).prev_queue,_=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=i(this,u(t).call(this)))._max=e,n._current=0;var c=n._queue=[];return n._timer=null,n._period_ms=r,n._max_queue=o,n._cancel_handler=function(e){var t=c.indexOf(e);t>=0&&c.splice(t,1)},n}var n,r,_;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,a),n=t,(r=[{key:"_lock",value:function(e){if(this._ensureTimer(),this._current>=this._max){var t=this._queue,n=this._max_queue;return null!==n&&t.length>=n&&e.error(l,"Throttle queue limit"),t.push(e),!1}return this._current+=1,!0}},{key:"_ensureTimer",value:function(){var e=this;this._timer||(this._timer=setInterval(function(){e._resetPeriod()},this._period_ms))}},{key:"_resetPeriod",value:function(){this._current=0;var e=this._queue;if(!e.length)return clearInterval(this._timer),void(this._timer=null);for(var t=this._max,n=0;e.length&&n<t;){var r=e.shift();if(r.state){++n;var o=r._root;o._handle_success(o._next_args)}}this._current=n}},{key:"sync",value:function(e,t,n){var r=this;e.add(function(e){!function(e,t,n,r){var o=e._root;t._lock(e)?(e._on_error=r,n.apply(void 0,[e].concat(s(e._call_args)))):(e._on_cancel=t._cancel_handler,o._next_args=e._call_args,f(o).unshift([n,r]))}(e,r,t,n)})}}])&&o(n.prototype,r),_&&o(n,_),t}();e.exports=_},function(e,t,n){"use strict";!function(t){var r=t.FutoIn||t.futoin||{};if(void 0===r.AsyncSteps){var o=n(13);t.$as=o,r.$as=o,t.FutoInError=o.FutoInError,r.AsyncSteps=o.AsyncSteps,t.FutoIn=r,t.futoin=r}e.exports=r.$as}(window)},function(e,t,n){"use strict";(t=e.exports=n(6)).ISync=n(5),t.Mutex=n(10),t.Throttle=n(11),t.Limiter=n(14),t.testcase=n(15)},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=n(5),a=n(10),l=n(11),f=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=i(this,u(t).call(this)))._mutex=new a(n.concurrent||1,n.max_queue||0),e._throttle=new l(n.rate||1,n.period_ms||1e3,n.burst||0),e}var n,r,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,s),n=t,(r=[{key:"sync",value:function(e,t,n){var r=this;e.sync(this._mutex,function(e){e._root._next_args=e._call_args,e.sync(r._throttle,t,n)})}}])&&o(n.prototype,r),f&&o(n,f),t}();e.exports=f},function(e,t,n){"use strict";var r=n(4);e.exports=function(e,t){return function(n){var o=this,i=new r;i.add(function(n){n.add(function(n){e.call(o,n),t&&n.add(function(e){e.error("NegativeTestMustThrow")})},t)},function(e,t){console.log("ERROR: ".concat(t," (").concat(e.state.error_info,")")),n(e.state.last_exception||new Error("Generic Fail"))}),i.add(function(e){return n()}),i.execute()}}}])});

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

!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=51)}([function(t,n,r){var e=r(36)("wks"),o=r(16),i=r(1).Symbol,u="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=e},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(2);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var r=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(1),o=r(9),i=r(6),u=r(16)("src"),c=Function.toString,s=(""+c).split("toString");r(4).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,c){var f="function"==typeof r;f&&(i(r,"name")||o(r,"name",n)),t[n]!==r&&(f&&(i(r,u)||o(r,u,t[n]?""+t[n]:s.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:o(t,n,r):(delete t[n],o(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n,r){var e=r(1),o=r(4),i=r(9),u=r(5),c=r(8),s=function(t,n,r){var f,a,p,l,v=t&s.F,h=t&s.G,d=t&s.S,y=t&s.P,_=t&s.B,x=h?e:d?e[n]||(e[n]={}):(e[n]||{}).prototype,g=h?o:o[n]||(o[n]={}),m=g.prototype||(g.prototype={});for(f in h&&(r=n),r)p=((a=!v&&x&&void 0!==x[f])?x:r)[f],l=_&&a?c(p,e):y&&"function"==typeof p?c(Function.call,p):p,x&&u(x,f,p,t&s.U),g[f]!=p&&i(g,f,l),y&&m[f]!=p&&(m[f]=p)};e.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},function(t,n,r){var e=r(15);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(13),o=r(23);t.exports=r(10)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){t.exports=!r(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(3),o=r(37),i=r(38),u=Object.defineProperty;n.f=r(10)?Object.defineProperty:function(t,n,r){if(e(t),n=i(n,!0),e(r),o)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n){t.exports={}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(24),o=r(25);t.exports=function(t){return e(o(t))}},function(t,n,r){var e=r(13).f,o=r(6),i=r(0)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,i)&&e(t,i,{configurable:!0,value:n})}},function(t,n,r){var e=r(8),o=r(70),i=r(71),u=r(3),c=r(27),s=r(72),f={},a={};(n=t.exports=function(t,n,r,p,l){var v,h,d,y,_=l?function(){return t}:s(t),x=e(r,p,n?2:1),g=0;if("function"!=typeof _)throw TypeError(t+" is not iterable!");if(i(_)){for(v=c(t.length);v>g;g++)if((y=n?x(u(h=t[g])[0],h[1]):x(t[g]))===f||y===a)return y}else for(d=_.call(t);!(h=d.next()).done;)if((y=o(d,x,h.value,n))===f||y===a)return y}).BREAK=f,n.RETURN=a},function(t,n,r){var e=r(12),o=r(0)("toStringTag"),i="Arguments"==e(function(){return arguments}());t.exports=function(t){var n,r,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),o))?r:i?e(n):"Object"==(u=e(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n){t.exports=!1},function(t,n,r){var e=r(2),o=r(1).document,i=e(o)&&e(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){var e=r(12);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){var e=r(59),o=r(41);t.exports=Object.keys||function(t){return e(t,o)}},function(t,n,r){var e=r(28),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(36)("keys"),o=r(16);t.exports=function(t){return e[t]||(e[t]=o(t))}},function(t,n,r){var e=r(25);t.exports=function(t){return Object(e(t))}},function(t,n,r){var e=r(16)("meta"),o=r(2),i=r(6),u=r(13).f,c=0,s=Object.isExtensible||function(){return!0},f=!r(11)(function(){return s(Object.preventExtensions({}))}),a=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},p=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,e)){if(!s(t))return"F";if(!n)return"E";a(t)}return t[e].i},getWeak:function(t,n){if(!i(t,e)){if(!s(t))return!0;if(!n)return!1;a(t)}return t[e].w},onFreeze:function(t){return f&&p.NEED&&s(t)&&!i(t,e)&&a(t),t}}},function(t,n,r){var e=r(5);t.exports=function(t,n,r){for(var o in n)e(t,o,n[o],r);return t}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n,r){"use strict";var e=r(15);t.exports.f=function(t){return new function(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=t,r=e}),this.resolve=e(n),this.reject=e(r)}(t)}},function(t,n,r){"use strict";var e=r(20),o={};o[r(0)("toStringTag")]="z",o+""!="[object z]"&&r(5)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){var e=r(4),o=r(1),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,n){return i[t]||(i[t]=void 0!==n?n:{})})("versions",[]).push({version:e.version,mode:r(21)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,n,r){t.exports=!r(10)&&!r(11)(function(){return 7!=Object.defineProperty(r(22)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){for(var e=r(53),o=r(26),i=r(5),u=r(1),c=r(9),s=r(14),f=r(0),a=f("iterator"),p=f("toStringTag"),l=s.Array,v={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},h=o(v),d=0;d<h.length;d++){var y,_=h[d],x=v[_],g=u[_],m=g&&g.prototype;if(m&&(m[a]||c(m,a,l),m[p]||c(m,p,_),s[_]=l,x))for(y in e)m[y]||i(m,y,e[y],!0)}},function(t,n,r){"use strict";var e=r(21),o=r(7),i=r(5),u=r(9),c=r(14),s=r(56),f=r(18),a=r(62),p=r(0)("iterator"),l=!([].keys&&"next"in[].keys()),v=function(){return this};t.exports=function(t,n,r,h,d,y,_){s(r,n,h);var x,g,m,b=function(t){if(!l&&t in O)return O[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},w=n+" Iterator",j="values"==d,S=!1,O=t.prototype,P=O[p]||O["@@iterator"]||d&&O[d],E=P||b(d),M=d?j?b("entries"):E:void 0,T="Array"==n&&O.entries||P;if(T&&(m=a(T.call(new t)))!==Object.prototype&&m.next&&(f(m,w,!0),e||"function"==typeof m[p]||u(m,p,v)),j&&P&&"values"!==P.name&&(S=!0,E=function(){return P.call(this)}),e&&!_||!l&&!S&&O[p]||u(O,p,E),c[n]=E,c[w]=v,d)if(x={values:j?E:b("values"),keys:y?E:b("keys"),entries:M},_)for(g in x)g in O||i(O,g,x[g]);else o(o.P+o.F*(l||S),n,x);return x}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){var e=r(1).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(8),o=r(24),i=r(30),u=r(27),c=r(64);t.exports=function(t,n){var r=1==t,s=2==t,f=3==t,a=4==t,p=6==t,l=5==t||p,v=n||c;return function(n,c,h){for(var d,y,_=i(n),x=o(_),g=e(c,h,3),m=u(x.length),b=0,w=r?v(n,m):s?v(n,0):void 0;m>b;b++)if((l||b in x)&&(y=g(d=x[b],b,_),t))if(r)w[b]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return b;case 2:w.push(d)}else if(a)return!1;return p?-1:f||a?a:w}}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,r){var e=r(0)("iterator"),o=!1;try{var i=[7][e]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i=[7],u=i[e]();u.next=function(){return{done:r=!0}},i[e]=function(){return u},t(i)}catch(t){}return r}},function(t,n,r){var e=r(3),o=r(15),i=r(0)("species");t.exports=function(t,n){var r,u=e(t).constructor;return void 0===u||void 0==(r=e(u)[i])?n:o(r)}},function(t,n,r){var e,o,i,u=r(8),c=r(85),s=r(42),f=r(22),a=r(1),p=a.process,l=a.setImmediate,v=a.clearImmediate,h=a.MessageChannel,d=a.Dispatch,y=0,_={},x=function(){var t=+this;if(_.hasOwnProperty(t)){var n=_[t];delete _[t],n()}},g=function(t){x.call(t.data)};l&&v||(l=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return _[++y]=function(){c("function"==typeof t?t:Function(t),n)},e(y),y},v=function(t){delete _[t]},"process"==r(12)(p)?e=function(t){p.nextTick(u(x,t,1))}:d&&d.now?e=function(t){d.now(u(x,t,1))}:h?(i=(o=new h).port2,o.port1.onmessage=g,e=u(i.postMessage,i,1)):a.addEventListener&&"function"==typeof postMessage&&!a.importScripts?(e=function(t){a.postMessage(t+"","*")},a.addEventListener("message",g,!1)):e="onreadystatechange"in f("script")?function(t){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),x.call(t)}}:function(t){setTimeout(u(x,t,1),0)}),t.exports={set:l,clear:v}},function(t,n){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,n,r){var e=r(3),o=r(2),i=r(34);t.exports=function(t,n){if(e(t),o(n)&&n.constructor===t)return n;var r=i.f(t);return(0,r.resolve)(n),r.promise}},function(t,n,r){"use strict";r(52),r(81)},function(t,n,r){r(35),r(39),r(63),r(77),r(79),t.exports=r(4).WeakMap},function(t,n,r){"use strict";var e=r(54),o=r(55),i=r(14),u=r(17);t.exports=r(40)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):o(0,"keys"==n?r:"values"==n?t[r]:[r,t[r]])},"values"),i.Arguments=i.Array,e("keys"),e("values"),e("entries")},function(t,n,r){var e=r(0)("unscopables"),o=Array.prototype;void 0==o[e]&&r(9)(o,e,{}),t.exports=function(t){o[e][t]=!0}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,r){"use strict";var e=r(57),o=r(23),i=r(18),u={};r(9)(u,r(0)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:o(1,r)}),i(t,n+" Iterator")}},function(t,n,r){var e=r(3),o=r(58),i=r(41),u=r(29)("IE_PROTO"),c=function(){},s=function(){var t,n=r(22)("iframe"),e=i.length;for(n.style.display="none",r(42).appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),s=t.F;e--;)delete s.prototype[i[e]];return s()};t.exports=Object.create||function(t,n){var r;return null!==t?(c.prototype=e(t),r=new c,c.prototype=null,r[u]=t):r=s(),void 0===n?r:o(r,n)}},function(t,n,r){var e=r(13),o=r(3),i=r(26);t.exports=r(10)?Object.defineProperties:function(t,n){o(t);for(var r,u=i(n),c=u.length,s=0;c>s;)e.f(t,r=u[s++],n[r]);return t}},function(t,n,r){var e=r(6),o=r(17),i=r(60)(!1),u=r(29)("IE_PROTO");t.exports=function(t,n){var r,c=o(t),s=0,f=[];for(r in c)r!=u&&e(c,r)&&f.push(r);for(;n.length>s;)e(c,r=n[s++])&&(~i(f,r)||f.push(r));return f}},function(t,n,r){var e=r(17),o=r(27),i=r(61);t.exports=function(t){return function(n,r,u){var c,s=e(n),f=o(s.length),a=i(u,f);if(t&&r!=r){for(;f>a;)if((c=s[a++])!=c)return!0}else for(;f>a;a++)if((t||a in s)&&s[a]===r)return t||a||0;return!t&&-1}}},function(t,n,r){var e=r(28),o=Math.max,i=Math.min;t.exports=function(t,n){return(t=e(t))<0?o(t+n,0):i(t,n)}},function(t,n,r){var e=r(6),o=r(30),i=r(29)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),e(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){"use strict";var e,o=r(43)(0),i=r(5),u=r(31),c=r(67),s=r(69),f=r(2),a=r(11),p=r(45),l=u.getWeak,v=Object.isExtensible,h=s.ufstore,d={},y=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},_={get:function(t){if(f(t)){var n=l(t);return!0===n?h(p(this,"WeakMap")).get(t):n?n[this._i]:void 0}},set:function(t,n){return s.def(p(this,"WeakMap"),t,n)}},x=t.exports=r(73)("WeakMap",y,_,s,!0,!0);a(function(){return 7!=(new x).set((Object.freeze||Object)(d),7).get(d)})&&(c((e=s.getConstructor(y,"WeakMap")).prototype,_),u.NEED=!0,o(["delete","has","get","set"],function(t){var n=x.prototype,r=n[t];i(n,t,function(n,o){if(f(n)&&!v(n)){this._f||(this._f=new e);var i=this._f[t](n,o);return"set"==t?this:i}return r.call(this,n,o)})}))},function(t,n,r){var e=r(65);t.exports=function(t,n){return new(e(t))(n)}},function(t,n,r){var e=r(2),o=r(66),i=r(0)("species");t.exports=function(t){var n;return o(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!o(n.prototype)||(n=void 0),e(n)&&null===(n=n[i])&&(n=void 0)),void 0===n?Array:n}},function(t,n,r){var e=r(12);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(26),o=r(68),i=r(44),u=r(30),c=r(24),s=Object.assign;t.exports=!s||r(11)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=s({},t)[r]||Object.keys(s({},n)).join("")!=e})?function(t,n){for(var r=u(t),s=arguments.length,f=1,a=o.f,p=i.f;s>f;)for(var l,v=c(arguments[f++]),h=a?e(v).concat(a(v)):e(v),d=h.length,y=0;d>y;)p.call(v,l=h[y++])&&(r[l]=v[l]);return r}:s},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){"use strict";var e=r(32),o=r(31).getWeak,i=r(3),u=r(2),c=r(33),s=r(19),f=r(43),a=r(6),p=r(45),l=f(5),v=f(6),h=0,d=function(t){return t._l||(t._l=new y)},y=function(){this.a=[]},_=function(t,n){return l(t.a,function(t){return t[0]===n})};y.prototype={get:function(t){var n=_(this,t);if(n)return n[1]},has:function(t){return!!_(this,t)},set:function(t,n){var r=_(this,t);r?r[1]=n:this.a.push([t,n])},delete:function(t){var n=v(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,r,i){var f=t(function(t,e){c(t,f,n,"_i"),t._t=n,t._i=h++,t._l=void 0,void 0!=e&&s(e,r,t[i],t)});return e(f.prototype,{delete:function(t){if(!u(t))return!1;var r=o(t);return!0===r?d(p(this,n)).delete(t):r&&a(r,this._i)&&delete r[this._i]},has:function(t){if(!u(t))return!1;var r=o(t);return!0===r?d(p(this,n)).has(t):r&&a(r,this._i)}}),f},def:function(t,n,r){var e=o(i(n),!0);return!0===e?d(t).set(n,r):e[t._i]=r,t},ufstore:d}},function(t,n,r){var e=r(3);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(n){var i=t.return;throw void 0!==i&&e(i.call(t)),n}}},function(t,n,r){var e=r(14),o=r(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||i[o]===t)}},function(t,n,r){var e=r(20),o=r(0)("iterator"),i=r(14);t.exports=r(4).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[e(t)]}},function(t,n,r){"use strict";var e=r(1),o=r(7),i=r(5),u=r(32),c=r(31),s=r(19),f=r(33),a=r(2),p=r(11),l=r(46),v=r(18),h=r(74);t.exports=function(t,n,r,d,y,_){var x=e[t],g=x,m=y?"set":"add",b=g&&g.prototype,w={},j=function(t){var n=b[t];i(b,t,"delete"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return _&&!a(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof g&&(_||b.forEach&&!p(function(){(new g).entries().next()}))){var S=new g,O=S[m](_?{}:-0,1)!=S,P=p(function(){S.has(1)}),E=l(function(t){new g(t)}),M=!_&&p(function(){for(var t=new g,n=5;n--;)t[m](n,n);return!t.has(-0)});E||((g=n(function(n,r){f(n,g,t);var e=h(new x,n,g);return void 0!=r&&s(r,y,e[m],e),e})).prototype=b,b.constructor=g),(P||M)&&(j("delete"),j("has"),y&&j("get")),(M||O)&&j(m),_&&b.clear&&delete b.clear}else g=d.getConstructor(n,t,y,m),u(g.prototype,r),c.NEED=!0;return v(g,t),w[t]=g,o(o.G+o.W+o.F*(g!=x),w),_||d.setStrong(g,t,y),g}},function(t,n,r){var e=r(2),o=r(75).set;t.exports=function(t,n,r){var i,u=n.constructor;return u!==r&&"function"==typeof u&&(i=u.prototype)!==r.prototype&&e(i)&&o&&o(t,i),t}},function(t,n,r){var e=r(2),o=r(3),i=function(t,n){if(o(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{(e=r(8)(Function.call,r(76).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return i(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:i}},function(t,n,r){var e=r(44),o=r(23),i=r(17),u=r(38),c=r(6),s=r(37),f=Object.getOwnPropertyDescriptor;n.f=r(10)?f:function(t,n){if(t=i(t),n=u(n,!0),s)try{return f(t,n)}catch(t){}if(c(t,n))return o(!e.f.call(t,n),t[n])}},function(t,n,r){r(78)("WeakMap")},function(t,n,r){"use strict";var e=r(7);t.exports=function(t){e(e.S,t,{of:function(){for(var t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return new this(n)}})}},function(t,n,r){r(80)("WeakMap")},function(t,n,r){"use strict";var e=r(7),o=r(15),i=r(8),u=r(19);t.exports=function(t){e(e.S,t,{from:function(t){var n,r,e,c,s=arguments[1];return o(this),(n=void 0!==s)&&o(s),void 0==t?new this:(r=[],n?(e=0,c=i(s,arguments[2],2),u(t,!1,function(t){r.push(c(t,e++))})):u(t,!1,r.push,r),new this(r))}})}},function(t,n,r){r(35),r(82),r(39),r(84),r(89),r(90),t.exports=r(4).Promise},function(t,n,r){"use strict";var e=r(83)(!0);r(40)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){var e=r(28),o=r(25);t.exports=function(t){return function(n,r){var i,u,c=String(o(n)),s=e(r),f=c.length;return s<0||s>=f?t?"":void 0:(i=c.charCodeAt(s))<55296||i>56319||s+1===f||(u=c.charCodeAt(s+1))<56320||u>57343?t?c.charAt(s):i:t?c.slice(s,s+2):u-56320+(i-55296<<10)+65536}}},function(t,n,r){"use strict";var e,o,i,u,c=r(21),s=r(1),f=r(8),a=r(20),p=r(7),l=r(2),v=r(15),h=r(33),d=r(19),y=r(47),_=r(48).set,x=r(86)(),g=r(34),m=r(49),b=r(87),w=r(50),j=s.TypeError,S=s.process,O=S&&S.versions,P=O&&O.v8||"",E=s.Promise,M="process"==a(S),T=function(){},k=o=g.f,L=!!function(){try{var t=E.resolve(1),n=(t.constructor={})[r(0)("species")]=function(t){t(T,T)};return(M||"function"==typeof PromiseRejectionEvent)&&t.then(T)instanceof n&&0!==P.indexOf("6.6")&&-1===b.indexOf("Chrome/66")}catch(t){}}(),A=function(t){var n;return!(!l(t)||"function"!=typeof(n=t.then))&&n},F=function(t,n){if(!t._n){t._n=!0;var r=t._c;x(function(){for(var e=t._v,o=1==t._s,i=0,u=function(n){var r,i,u,c=o?n.ok:n.fail,s=n.resolve,f=n.reject,a=n.domain;try{c?(o||(2==t._h&&R(t),t._h=1),!0===c?r=e:(a&&a.enter(),r=c(e),a&&(a.exit(),u=!0)),r===n.promise?f(j("Promise-chain cycle")):(i=A(r))?i.call(r,s,f):s(r)):f(e)}catch(t){a&&!u&&a.exit(),f(t)}};r.length>i;)u(r[i++]);t._c=[],t._n=!1,n&&!t._h&&C(t)})}},C=function(t){_.call(s,function(){var n,r,e,o=t._v,i=W(t);if(i&&(n=m(function(){M?S.emit("unhandledRejection",o,t):(r=s.onunhandledrejection)?r({promise:t,reason:o}):(e=s.console)&&e.error&&e.error("Unhandled promise rejection",o)}),t._h=M||W(t)?2:1),t._a=void 0,i&&n.e)throw n.v})},W=function(t){return 1!==t._h&&0===(t._a||t._c).length},R=function(t){_.call(s,function(){var n;M?S.emit("rejectionHandled",t):(n=s.onrejectionhandled)&&n({promise:t,reason:t._v})})},D=function(t){var n=this;n._d||(n._d=!0,(n=n._w||n)._v=t,n._s=2,n._a||(n._a=n._c.slice()),F(n,!0))},I=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw j("Promise can't be resolved itself");(n=A(t))?x(function(){var e={_w:r,_d:!1};try{n.call(t,f(I,e,1),f(D,e,1))}catch(t){D.call(e,t)}}):(r._v=t,r._s=1,F(r,!1))}catch(t){D.call({_w:r,_d:!1},t)}}};L||(E=function(t){h(this,E,"Promise","_h"),v(t),e.call(this);try{t(f(I,this,1),f(D,this,1))}catch(t){D.call(this,t)}},(e=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=r(32)(E.prototype,{then:function(t,n){var r=k(y(this,E));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=M?S.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&F(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),i=function(){var t=new e;this.promise=t,this.resolve=f(I,t,1),this.reject=f(D,t,1)},g.f=k=function(t){return t===E||t===u?new i(t):o(t)}),p(p.G+p.W+p.F*!L,{Promise:E}),r(18)(E,"Promise"),r(88)("Promise"),u=r(4).Promise,p(p.S+p.F*!L,"Promise",{reject:function(t){var n=k(this);return(0,n.reject)(t),n.promise}}),p(p.S+p.F*(c||!L),"Promise",{resolve:function(t){return w(c&&this===u?E:this,t)}}),p(p.S+p.F*!(L&&r(46)(function(t){E.all(t).catch(T)})),"Promise",{all:function(t){var n=this,r=k(n),e=r.resolve,o=r.reject,i=m(function(){var r=[],i=0,u=1;d(t,!1,function(t){var c=i++,s=!1;r.push(void 0),u++,n.resolve(t).then(function(t){s||(s=!0,r[c]=t,--u||e(r))},o)}),--u||e(r)});return i.e&&o(i.v),r.promise},race:function(t){var n=this,r=k(n),e=r.reject,o=m(function(){d(t,!1,function(t){n.resolve(t).then(r.resolve,e)})});return o.e&&e(o.v),r.promise}})},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},function(t,n,r){var e=r(1),o=r(48).set,i=e.MutationObserver||e.WebKitMutationObserver,u=e.process,c=e.Promise,s="process"==r(12)(u);t.exports=function(){var t,n,r,f=function(){var e,o;for(s&&(e=u.domain)&&e.exit();t;){o=t.fn,t=t.next;try{o()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(s)r=function(){u.nextTick(f)};else if(!i||e.navigator&&e.navigator.standalone)if(c&&c.resolve){var a=c.resolve(void 0);r=function(){a.then(f)}}else r=function(){o.call(e,f)};else{var p=!0,l=document.createTextNode("");new i(f).observe(l,{characterData:!0}),r=function(){l.data=p=!p}}return function(e){var o={fn:e,next:void 0};n&&(n.next=o),t||(t=o,r()),n=o}}},function(t,n,r){var e=r(1).navigator;t.exports=e&&e.userAgent||""},function(t,n,r){"use strict";var e=r(1),o=r(13),i=r(10),u=r(0)("species");t.exports=function(t){var n=e[t];i&&n&&!n[u]&&o.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){"use strict";var e=r(7),o=r(4),i=r(1),u=r(47),c=r(50);e(e.P+e.R,"Promise",{finally:function(t){var n=u(this,o.Promise||i.Promise),r="function"==typeof t;return this.then(r?function(r){return c(n,t()).then(function(){return r})}:t,r?function(r){return c(n,t()).then(function(){throw r})}:t)}})},function(t,n,r){"use strict";var e=r(7),o=r(34),i=r(49);e(e.S,"Promise",{try:function(t){var n=o.f(this),r=i(t);return(r.e?n.reject:n.resolve)(r.v),n.promise}})}]);
!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=51)}([function(t,n,r){var e=r(36)("wks"),o=r(16),i=r(1).Symbol,u="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=e},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(2);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var r=t.exports={version:"2.6.2"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(1),o=r(9),i=r(6),u=r(16)("src"),c=Function.toString,s=(""+c).split("toString");r(4).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,c){var f="function"==typeof r;f&&(i(r,"name")||o(r,"name",n)),t[n]!==r&&(f&&(i(r,u)||o(r,u,t[n]?""+t[n]:s.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:o(t,n,r):(delete t[n],o(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n,r){var e=r(1),o=r(4),i=r(9),u=r(5),c=r(8),s=function(t,n,r){var f,a,l,p,v=t&s.F,h=t&s.G,y=t&s.S,d=t&s.P,_=t&s.B,x=h?e:y?e[n]||(e[n]={}):(e[n]||{}).prototype,g=h?o:o[n]||(o[n]={}),m=g.prototype||(g.prototype={});for(f in h&&(r=n),r)l=((a=!v&&x&&void 0!==x[f])?x:r)[f],p=_&&a?c(l,e):d&&"function"==typeof l?c(Function.call,l):l,x&&u(x,f,l,t&s.U),g[f]!=l&&i(g,f,p),d&&m[f]!=l&&(m[f]=l)};e.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},function(t,n,r){var e=r(15);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(13),o=r(23);t.exports=r(10)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){t.exports=!r(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(3),o=r(37),i=r(38),u=Object.defineProperty;n.f=r(10)?Object.defineProperty:function(t,n,r){if(e(t),n=i(n,!0),e(r),o)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n){t.exports={}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(24),o=r(25);t.exports=function(t){return e(o(t))}},function(t,n,r){var e=r(13).f,o=r(6),i=r(0)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,i)&&e(t,i,{configurable:!0,value:n})}},function(t,n,r){var e=r(8),o=r(70),i=r(71),u=r(3),c=r(27),s=r(72),f={},a={};(n=t.exports=function(t,n,r,l,p){var v,h,y,d,_=p?function(){return t}:s(t),x=e(r,l,n?2:1),g=0;if("function"!=typeof _)throw TypeError(t+" is not iterable!");if(i(_)){for(v=c(t.length);v>g;g++)if((d=n?x(u(h=t[g])[0],h[1]):x(t[g]))===f||d===a)return d}else for(y=_.call(t);!(h=y.next()).done;)if((d=o(y,x,h.value,n))===f||d===a)return d}).BREAK=f,n.RETURN=a},function(t,n,r){var e=r(12),o=r(0)("toStringTag"),i="Arguments"==e(function(){return arguments}());t.exports=function(t){var n,r,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),o))?r:i?e(n):"Object"==(u=e(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n){t.exports=!1},function(t,n,r){var e=r(2),o=r(1).document,i=e(o)&&e(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){var e=r(12);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){var e=r(59),o=r(41);t.exports=Object.keys||function(t){return e(t,o)}},function(t,n,r){var e=r(28),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(36)("keys"),o=r(16);t.exports=function(t){return e[t]||(e[t]=o(t))}},function(t,n,r){var e=r(25);t.exports=function(t){return Object(e(t))}},function(t,n,r){var e=r(16)("meta"),o=r(2),i=r(6),u=r(13).f,c=0,s=Object.isExtensible||function(){return!0},f=!r(11)(function(){return s(Object.preventExtensions({}))}),a=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,e)){if(!s(t))return"F";if(!n)return"E";a(t)}return t[e].i},getWeak:function(t,n){if(!i(t,e)){if(!s(t))return!0;if(!n)return!1;a(t)}return t[e].w},onFreeze:function(t){return f&&l.NEED&&s(t)&&!i(t,e)&&a(t),t}}},function(t,n,r){var e=r(5);t.exports=function(t,n,r){for(var o in n)e(t,o,n[o],r);return t}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n,r){"use strict";var e=r(15);function o(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=t,r=e}),this.resolve=e(n),this.reject=e(r)}t.exports.f=function(t){return new o(t)}},function(t,n,r){"use strict";var e=r(20),o={};o[r(0)("toStringTag")]="z",o+""!="[object z]"&&r(5)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){var e=r(4),o=r(1),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,n){return i[t]||(i[t]=void 0!==n?n:{})})("versions",[]).push({version:e.version,mode:r(21)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,n,r){t.exports=!r(10)&&!r(11)(function(){return 7!=Object.defineProperty(r(22)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){for(var e=r(53),o=r(26),i=r(5),u=r(1),c=r(9),s=r(14),f=r(0),a=f("iterator"),l=f("toStringTag"),p=s.Array,v={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},h=o(v),y=0;y<h.length;y++){var d,_=h[y],x=v[_],g=u[_],m=g&&g.prototype;if(m&&(m[a]||c(m,a,p),m[l]||c(m,l,_),s[_]=p,x))for(d in e)m[d]||i(m,d,e[d],!0)}},function(t,n,r){"use strict";var e=r(21),o=r(7),i=r(5),u=r(9),c=r(14),s=r(56),f=r(18),a=r(62),l=r(0)("iterator"),p=!([].keys&&"next"in[].keys()),v=function(){return this};t.exports=function(t,n,r,h,y,d,_){s(r,n,h);var x,g,m,b=function(t){if(!p&&t in O)return O[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},w=n+" Iterator",j="values"==y,S=!1,O=t.prototype,P=O[l]||O["@@iterator"]||y&&O[y],E=P||b(y),M=y?j?b("entries"):E:void 0,T="Array"==n&&O.entries||P;if(T&&(m=a(T.call(new t)))!==Object.prototype&&m.next&&(f(m,w,!0),e||"function"==typeof m[l]||u(m,l,v)),j&&P&&"values"!==P.name&&(S=!0,E=function(){return P.call(this)}),e&&!_||!p&&!S&&O[l]||u(O,l,E),c[n]=E,c[w]=v,y)if(x={values:j?E:b("values"),keys:d?E:b("keys"),entries:M},_)for(g in x)g in O||i(O,g,x[g]);else o(o.P+o.F*(p||S),n,x);return x}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){var e=r(1).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(8),o=r(24),i=r(30),u=r(27),c=r(64);t.exports=function(t,n){var r=1==t,s=2==t,f=3==t,a=4==t,l=6==t,p=5==t||l,v=n||c;return function(n,c,h){for(var y,d,_=i(n),x=o(_),g=e(c,h,3),m=u(x.length),b=0,w=r?v(n,m):s?v(n,0):void 0;m>b;b++)if((p||b in x)&&(d=g(y=x[b],b,_),t))if(r)w[b]=d;else if(d)switch(t){case 3:return!0;case 5:return y;case 6:return b;case 2:w.push(y)}else if(a)return!1;return l?-1:f||a?a:w}}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,r){var e=r(0)("iterator"),o=!1;try{var i=[7][e]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i=[7],u=i[e]();u.next=function(){return{done:r=!0}},i[e]=function(){return u},t(i)}catch(t){}return r}},function(t,n,r){var e=r(3),o=r(15),i=r(0)("species");t.exports=function(t,n){var r,u=e(t).constructor;return void 0===u||null==(r=e(u)[i])?n:o(r)}},function(t,n,r){var e,o,i,u=r(8),c=r(85),s=r(42),f=r(22),a=r(1),l=a.process,p=a.setImmediate,v=a.clearImmediate,h=a.MessageChannel,y=a.Dispatch,d=0,_={},x=function(){var t=+this;if(_.hasOwnProperty(t)){var n=_[t];delete _[t],n()}},g=function(t){x.call(t.data)};p&&v||(p=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return _[++d]=function(){c("function"==typeof t?t:Function(t),n)},e(d),d},v=function(t){delete _[t]},"process"==r(12)(l)?e=function(t){l.nextTick(u(x,t,1))}:y&&y.now?e=function(t){y.now(u(x,t,1))}:h?(i=(o=new h).port2,o.port1.onmessage=g,e=u(i.postMessage,i,1)):a.addEventListener&&"function"==typeof postMessage&&!a.importScripts?(e=function(t){a.postMessage(t+"","*")},a.addEventListener("message",g,!1)):e="onreadystatechange"in f("script")?function(t){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),x.call(t)}}:function(t){setTimeout(u(x,t,1),0)}),t.exports={set:p,clear:v}},function(t,n){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,n,r){var e=r(3),o=r(2),i=r(34);t.exports=function(t,n){if(e(t),o(n)&&n.constructor===t)return n;var r=i.f(t);return(0,r.resolve)(n),r.promise}},function(t,n,r){"use strict";r(52),r(81)},function(t,n,r){r(35),r(39),r(63),r(77),r(79),t.exports=r(4).WeakMap},function(t,n,r){"use strict";var e=r(54),o=r(55),i=r(14),u=r(17);t.exports=r(40)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):o(0,"keys"==n?r:"values"==n?t[r]:[r,t[r]])},"values"),i.Arguments=i.Array,e("keys"),e("values"),e("entries")},function(t,n,r){var e=r(0)("unscopables"),o=Array.prototype;null==o[e]&&r(9)(o,e,{}),t.exports=function(t){o[e][t]=!0}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,r){"use strict";var e=r(57),o=r(23),i=r(18),u={};r(9)(u,r(0)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:o(1,r)}),i(t,n+" Iterator")}},function(t,n,r){var e=r(3),o=r(58),i=r(41),u=r(29)("IE_PROTO"),c=function(){},s=function(){var t,n=r(22)("iframe"),e=i.length;for(n.style.display="none",r(42).appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),s=t.F;e--;)delete s.prototype[i[e]];return s()};t.exports=Object.create||function(t,n){var r;return null!==t?(c.prototype=e(t),r=new c,c.prototype=null,r[u]=t):r=s(),void 0===n?r:o(r,n)}},function(t,n,r){var e=r(13),o=r(3),i=r(26);t.exports=r(10)?Object.defineProperties:function(t,n){o(t);for(var r,u=i(n),c=u.length,s=0;c>s;)e.f(t,r=u[s++],n[r]);return t}},function(t,n,r){var e=r(6),o=r(17),i=r(60)(!1),u=r(29)("IE_PROTO");t.exports=function(t,n){var r,c=o(t),s=0,f=[];for(r in c)r!=u&&e(c,r)&&f.push(r);for(;n.length>s;)e(c,r=n[s++])&&(~i(f,r)||f.push(r));return f}},function(t,n,r){var e=r(17),o=r(27),i=r(61);t.exports=function(t){return function(n,r,u){var c,s=e(n),f=o(s.length),a=i(u,f);if(t&&r!=r){for(;f>a;)if((c=s[a++])!=c)return!0}else for(;f>a;a++)if((t||a in s)&&s[a]===r)return t||a||0;return!t&&-1}}},function(t,n,r){var e=r(28),o=Math.max,i=Math.min;t.exports=function(t,n){return(t=e(t))<0?o(t+n,0):i(t,n)}},function(t,n,r){var e=r(6),o=r(30),i=r(29)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),e(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){"use strict";var e,o=r(43)(0),i=r(5),u=r(31),c=r(67),s=r(69),f=r(2),a=r(11),l=r(45),p=u.getWeak,v=Object.isExtensible,h=s.ufstore,y={},d=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},_={get:function(t){if(f(t)){var n=p(t);return!0===n?h(l(this,"WeakMap")).get(t):n?n[this._i]:void 0}},set:function(t,n){return s.def(l(this,"WeakMap"),t,n)}},x=t.exports=r(73)("WeakMap",d,_,s,!0,!0);a(function(){return 7!=(new x).set((Object.freeze||Object)(y),7).get(y)})&&(c((e=s.getConstructor(d,"WeakMap")).prototype,_),u.NEED=!0,o(["delete","has","get","set"],function(t){var n=x.prototype,r=n[t];i(n,t,function(n,o){if(f(n)&&!v(n)){this._f||(this._f=new e);var i=this._f[t](n,o);return"set"==t?this:i}return r.call(this,n,o)})}))},function(t,n,r){var e=r(65);t.exports=function(t,n){return new(e(t))(n)}},function(t,n,r){var e=r(2),o=r(66),i=r(0)("species");t.exports=function(t){var n;return o(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!o(n.prototype)||(n=void 0),e(n)&&null===(n=n[i])&&(n=void 0)),void 0===n?Array:n}},function(t,n,r){var e=r(12);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(26),o=r(68),i=r(44),u=r(30),c=r(24),s=Object.assign;t.exports=!s||r(11)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=s({},t)[r]||Object.keys(s({},n)).join("")!=e})?function(t,n){for(var r=u(t),s=arguments.length,f=1,a=o.f,l=i.f;s>f;)for(var p,v=c(arguments[f++]),h=a?e(v).concat(a(v)):e(v),y=h.length,d=0;y>d;)l.call(v,p=h[d++])&&(r[p]=v[p]);return r}:s},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){"use strict";var e=r(32),o=r(31).getWeak,i=r(3),u=r(2),c=r(33),s=r(19),f=r(43),a=r(6),l=r(45),p=f(5),v=f(6),h=0,y=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},_=function(t,n){return p(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=_(this,t);if(n)return n[1]},has:function(t){return!!_(this,t)},set:function(t,n){var r=_(this,t);r?r[1]=n:this.a.push([t,n])},delete:function(t){var n=v(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,r,i){var f=t(function(t,e){c(t,f,n,"_i"),t._t=n,t._i=h++,t._l=void 0,null!=e&&s(e,r,t[i],t)});return e(f.prototype,{delete:function(t){if(!u(t))return!1;var r=o(t);return!0===r?y(l(this,n)).delete(t):r&&a(r,this._i)&&delete r[this._i]},has:function(t){if(!u(t))return!1;var r=o(t);return!0===r?y(l(this,n)).has(t):r&&a(r,this._i)}}),f},def:function(t,n,r){var e=o(i(n),!0);return!0===e?y(t).set(n,r):e[t._i]=r,t},ufstore:y}},function(t,n,r){var e=r(3);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(n){var i=t.return;throw void 0!==i&&e(i.call(t)),n}}},function(t,n,r){var e=r(14),o=r(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||i[o]===t)}},function(t,n,r){var e=r(20),o=r(0)("iterator"),i=r(14);t.exports=r(4).getIteratorMethod=function(t){if(null!=t)return t[o]||t["@@iterator"]||i[e(t)]}},function(t,n,r){"use strict";var e=r(1),o=r(7),i=r(5),u=r(32),c=r(31),s=r(19),f=r(33),a=r(2),l=r(11),p=r(46),v=r(18),h=r(74);t.exports=function(t,n,r,y,d,_){var x=e[t],g=x,m=d?"set":"add",b=g&&g.prototype,w={},j=function(t){var n=b[t];i(b,t,"delete"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return _&&!a(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof g&&(_||b.forEach&&!l(function(){(new g).entries().next()}))){var S=new g,O=S[m](_?{}:-0,1)!=S,P=l(function(){S.has(1)}),E=p(function(t){new g(t)}),M=!_&&l(function(){for(var t=new g,n=5;n--;)t[m](n,n);return!t.has(-0)});E||((g=n(function(n,r){f(n,g,t);var e=h(new x,n,g);return null!=r&&s(r,d,e[m],e),e})).prototype=b,b.constructor=g),(P||M)&&(j("delete"),j("has"),d&&j("get")),(M||O)&&j(m),_&&b.clear&&delete b.clear}else g=y.getConstructor(n,t,d,m),u(g.prototype,r),c.NEED=!0;return v(g,t),w[t]=g,o(o.G+o.W+o.F*(g!=x),w),_||y.setStrong(g,t,d),g}},function(t,n,r){var e=r(2),o=r(75).set;t.exports=function(t,n,r){var i,u=n.constructor;return u!==r&&"function"==typeof u&&(i=u.prototype)!==r.prototype&&e(i)&&o&&o(t,i),t}},function(t,n,r){var e=r(2),o=r(3),i=function(t,n){if(o(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{(e=r(8)(Function.call,r(76).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return i(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:i}},function(t,n,r){var e=r(44),o=r(23),i=r(17),u=r(38),c=r(6),s=r(37),f=Object.getOwnPropertyDescriptor;n.f=r(10)?f:function(t,n){if(t=i(t),n=u(n,!0),s)try{return f(t,n)}catch(t){}if(c(t,n))return o(!e.f.call(t,n),t[n])}},function(t,n,r){r(78)("WeakMap")},function(t,n,r){"use strict";var e=r(7);t.exports=function(t){e(e.S,t,{of:function(){for(var t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return new this(n)}})}},function(t,n,r){r(80)("WeakMap")},function(t,n,r){"use strict";var e=r(7),o=r(15),i=r(8),u=r(19);t.exports=function(t){e(e.S,t,{from:function(t){var n,r,e,c,s=arguments[1];return o(this),(n=void 0!==s)&&o(s),null==t?new this:(r=[],n?(e=0,c=i(s,arguments[2],2),u(t,!1,function(t){r.push(c(t,e++))})):u(t,!1,r.push,r),new this(r))}})}},function(t,n,r){r(35),r(82),r(39),r(84),r(89),r(90),t.exports=r(4).Promise},function(t,n,r){"use strict";var e=r(83)(!0);r(40)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){var e=r(28),o=r(25);t.exports=function(t){return function(n,r){var i,u,c=String(o(n)),s=e(r),f=c.length;return s<0||s>=f?t?"":void 0:(i=c.charCodeAt(s))<55296||i>56319||s+1===f||(u=c.charCodeAt(s+1))<56320||u>57343?t?c.charAt(s):i:t?c.slice(s,s+2):u-56320+(i-55296<<10)+65536}}},function(t,n,r){"use strict";var e,o,i,u,c=r(21),s=r(1),f=r(8),a=r(20),l=r(7),p=r(2),v=r(15),h=r(33),y=r(19),d=r(47),_=r(48).set,x=r(86)(),g=r(34),m=r(49),b=r(87),w=r(50),j=s.TypeError,S=s.process,O=S&&S.versions,P=O&&O.v8||"",E=s.Promise,M="process"==a(S),T=function(){},k=o=g.f,L=!!function(){try{var t=E.resolve(1),n=(t.constructor={})[r(0)("species")]=function(t){t(T,T)};return(M||"function"==typeof PromiseRejectionEvent)&&t.then(T)instanceof n&&0!==P.indexOf("6.6")&&-1===b.indexOf("Chrome/66")}catch(t){}}(),A=function(t){var n;return!(!p(t)||"function"!=typeof(n=t.then))&&n},F=function(t,n){if(!t._n){t._n=!0;var r=t._c;x(function(){for(var e=t._v,o=1==t._s,i=0,u=function(n){var r,i,u,c=o?n.ok:n.fail,s=n.resolve,f=n.reject,a=n.domain;try{c?(o||(2==t._h&&R(t),t._h=1),!0===c?r=e:(a&&a.enter(),r=c(e),a&&(a.exit(),u=!0)),r===n.promise?f(j("Promise-chain cycle")):(i=A(r))?i.call(r,s,f):s(r)):f(e)}catch(t){a&&!u&&a.exit(),f(t)}};r.length>i;)u(r[i++]);t._c=[],t._n=!1,n&&!t._h&&C(t)})}},C=function(t){_.call(s,function(){var n,r,e,o=t._v,i=W(t);if(i&&(n=m(function(){M?S.emit("unhandledRejection",o,t):(r=s.onunhandledrejection)?r({promise:t,reason:o}):(e=s.console)&&e.error&&e.error("Unhandled promise rejection",o)}),t._h=M||W(t)?2:1),t._a=void 0,i&&n.e)throw n.v})},W=function(t){return 1!==t._h&&0===(t._a||t._c).length},R=function(t){_.call(s,function(){var n;M?S.emit("rejectionHandled",t):(n=s.onrejectionhandled)&&n({promise:t,reason:t._v})})},D=function(t){var n=this;n._d||(n._d=!0,(n=n._w||n)._v=t,n._s=2,n._a||(n._a=n._c.slice()),F(n,!0))},I=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw j("Promise can't be resolved itself");(n=A(t))?x(function(){var e={_w:r,_d:!1};try{n.call(t,f(I,e,1),f(D,e,1))}catch(t){D.call(e,t)}}):(r._v=t,r._s=1,F(r,!1))}catch(t){D.call({_w:r,_d:!1},t)}}};L||(E=function(t){h(this,E,"Promise","_h"),v(t),e.call(this);try{t(f(I,this,1),f(D,this,1))}catch(t){D.call(this,t)}},(e=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=r(32)(E.prototype,{then:function(t,n){var r=k(d(this,E));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=M?S.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&F(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),i=function(){var t=new e;this.promise=t,this.resolve=f(I,t,1),this.reject=f(D,t,1)},g.f=k=function(t){return t===E||t===u?new i(t):o(t)}),l(l.G+l.W+l.F*!L,{Promise:E}),r(18)(E,"Promise"),r(88)("Promise"),u=r(4).Promise,l(l.S+l.F*!L,"Promise",{reject:function(t){var n=k(this);return(0,n.reject)(t),n.promise}}),l(l.S+l.F*(c||!L),"Promise",{resolve:function(t){return w(c&&this===u?E:this,t)}}),l(l.S+l.F*!(L&&r(46)(function(t){E.all(t).catch(T)})),"Promise",{all:function(t){var n=this,r=k(n),e=r.resolve,o=r.reject,i=m(function(){var r=[],i=0,u=1;y(t,!1,function(t){var c=i++,s=!1;r.push(void 0),u++,n.resolve(t).then(function(t){s||(s=!0,r[c]=t,--u||e(r))},o)}),--u||e(r)});return i.e&&o(i.v),r.promise},race:function(t){var n=this,r=k(n),e=r.reject,o=m(function(){y(t,!1,function(t){n.resolve(t).then(r.resolve,e)})});return o.e&&e(o.v),r.promise}})},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},function(t,n,r){var e=r(1),o=r(48).set,i=e.MutationObserver||e.WebKitMutationObserver,u=e.process,c=e.Promise,s="process"==r(12)(u);t.exports=function(){var t,n,r,f=function(){var e,o;for(s&&(e=u.domain)&&e.exit();t;){o=t.fn,t=t.next;try{o()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(s)r=function(){u.nextTick(f)};else if(!i||e.navigator&&e.navigator.standalone)if(c&&c.resolve){var a=c.resolve(void 0);r=function(){a.then(f)}}else r=function(){o.call(e,f)};else{var l=!0,p=document.createTextNode("");new i(f).observe(p,{characterData:!0}),r=function(){p.data=l=!l}}return function(e){var o={fn:e,next:void 0};n&&(n.next=o),t||(t=o,r()),n=o}}},function(t,n,r){var e=r(1).navigator;t.exports=e&&e.userAgent||""},function(t,n,r){"use strict";var e=r(1),o=r(13),i=r(10),u=r(0)("species");t.exports=function(t){var n=e[t];i&&n&&!n[u]&&o.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){"use strict";var e=r(7),o=r(4),i=r(1),u=r(47),c=r(50);e(e.P+e.R,"Promise",{finally:function(t){var n=u(this,o.Promise||i.Promise),r="function"==typeof t;return this.then(r?function(r){return c(n,t()).then(function(){return r})}:t,r?function(r){return c(n,t()).then(function(){throw r})}:t)}})},function(t,n,r){"use strict";var e=r(7),o=r(34),i=r(49);e(e.S,"Promise",{try:function(t){var n=o.f(this),r=i(t);return(r.e?n.reject:n.resolve)(r.v),n.promise}})}]);
"use strict";
/**

@@ -28,8 +27,16 @@ * @file Module's entry point and AsyncSteps class itself

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var AsyncTool = require('./lib/AsyncTool');

@@ -41,2 +48,3 @@

var AsyncStepProtector = require('./lib/AsyncStepProtector');
var ParallelStep = require('./lib/ParallelStep');

@@ -57,23 +65,22 @@

var sanityCheck = isProduction ? noop : function (as) {
if (as._stack.length > 0) {
as.error(InternalError, "Top level add in execution");
}
if (as._stack.length > 0) {
as.error(InternalError, "Top level add in execution");
}
};
var sanityCheckAdd = isProduction ? noop : function (as, func, onerror) {
sanityCheck(as);
checkFunc(as, func);
checkOnError(as, onerror);
};
sanityCheck(as);
checkFunc(as, func);
checkOnError(as, onerror);
}; // This small trick has a huge speedup result (75-90%)
// This small trick has a huge speedup result (75-90%)
var EXEC_BURST = 100;
var g_curr_burst = EXEC_BURST;
// avoid another AsyncSteps instance continuation
var g_curr_burst = EXEC_BURST; // avoid another AsyncSteps instance continuation
var g_burst_owner = null;
var post_execute_cb = function post_execute_cb(asi) {
asi._post_exec = noop;
asi._execute();
asi._post_exec = noop;
asi._execute();
};
/**

@@ -83,599 +90,586 @@ * Root AsyncStep implementation

var AsyncSteps = function () {
function AsyncSteps() {
var _this = this;
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var async_tool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AsyncTool;
var AsyncSteps =
/*#__PURE__*/
function () {
function AsyncSteps() {
var _this = this;
_classCallCheck(this, AsyncSteps);
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var async_tool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AsyncTool;
if (state === null) {
state = function state() {
return this.state;
};
}
_classCallCheck(this, AsyncSteps);
this.state = state;
this._queue = [];
this._stack = [];
this._exec_stack = newExecStack();
this._in_exec = false;
this._post_exec = noop;
this._exec_event = null;
this._next_args = EMPTY_ARRAY;
this._async_tool = async_tool;
// ---
var callImmediate = async_tool.callImmediate;
var event_execute_cb = function event_execute_cb() {
g_curr_burst = EXEC_BURST;
g_burst_owner = _this;
_this._exec_event = null;
_this._execute();
};
this._scheduleExecute = function () {
if (--g_curr_burst <= 0 || !_this._in_exec || g_burst_owner !== _this) {
_this._exec_event = callImmediate(event_execute_cb);
} else if (_this._in_exec) {
_this._post_exec = post_execute_cb;
}
};
if (state === null) {
state = function state() {
return this.state;
};
}
/**
* Add sub-step. Can be called multiple times.
* @param {ExecFunc} func - function defining non-blocking step execution
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} self
* @alias AsyncSteps#add
*/
this.state = state;
this._queue = [];
this._stack = [];
this._exec_stack = newExecStack();
this._in_exec = false;
this._post_exec = noop;
this._exec_event = null;
this._next_args = EMPTY_ARRAY;
this._async_tool = async_tool; // ---
var callImmediate = async_tool.callImmediate;
_createClass(AsyncSteps, [{
key: 'add',
value: function add(func, onerror) {
sanityCheckAdd(this, func, onerror);
var event_execute_cb = function event_execute_cb() {
g_curr_burst = EXEC_BURST;
g_burst_owner = _this;
_this._exec_event = null;
this._queue.push([func, onerror]);
_this._execute();
};
return this;
}
this._scheduleExecute = function () {
if (--g_curr_burst <= 0 || !_this._in_exec || g_burst_owner !== _this) {
_this._exec_event = callImmediate(event_execute_cb);
} else if (_this._in_exec) {
_this._post_exec = post_execute_cb;
}
};
}
/**
* Add sub-step. Can be called multiple times.
* @param {ExecFunc} func - function defining non-blocking step execution
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} self
* @alias AsyncSteps#add
*/
/**
* Creates a step internally and returns specialized AsyncSteps interfaces all steps
* of which are executed in quasi-parallel.
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} interface for parallel step adding
* @alias AsyncSteps#parallel
*/
}, {
key: 'parallel',
value: function parallel(onerror) {
sanityCheck(this);
checkOnError(this, onerror);
_createClass(AsyncSteps, [{
key: "add",
value: function add(func, onerror) {
sanityCheckAdd(this, func, onerror);
var p = new ParallelStep(this, this);
this._queue.push([func, onerror]);
this._queue.push([function (as) {
p.executeParallel(as);
}, onerror]);
return this;
}
/**
* Creates a step internally and returns specialized AsyncSteps interfaces all steps
* of which are executed in quasi-parallel.
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} interface for parallel step adding
* @alias AsyncSteps#parallel
*/
return p;
}
}, {
key: "parallel",
value: function parallel(onerror) {
sanityCheck(this);
checkOnError(this, onerror);
var p = new ParallelStep(this, this);
/**
* Add sub-step with synchronization against supplied object.
* @param {ISync} object - Mutex, Throttle or other type of synchronization implementation.
* @param {ExecFunc} func - function defining non-blocking step execution
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} self
* @alias AsyncSteps#sync
*/
this._queue.push([function (as) {
p.executeParallel(as);
}, onerror]);
}, {
key: 'sync',
value: function sync(object, func, onerror) {
sanityCheckAdd(this, func, onerror);
return p;
}
/**
* Add sub-step with synchronization against supplied object.
* @param {ISync} object - Mutex, Throttle or other type of synchronization implementation.
* @param {ExecFunc} func - function defining non-blocking step execution
* @param {ErrorFunc=} onerror - Optional, provide error handler
* @returns {AsyncSteps} self
* @alias AsyncSteps#sync
*/
object.sync(this, func, onerror);
}, {
key: "sync",
value: function sync(object, func, onerror) {
sanityCheckAdd(this, func, onerror);
object.sync(this, func, onerror);
return this;
}
/**
* Set error and throw to abort execution.
*
* *NOTE: If called outside of AsyncSteps stack (e.g. by external event), make sure you catch the exception*
* @param {string} name - error message, expected to be identifier "InternalError"
* @param {string=} error_info - optional descriptive message assigned to as.state.error_info
* @throws {Error}
* @alias AsyncSteps#error
*/
return this;
}
}, {
key: "error",
value: function error(name, error_info) {
this.state.error_info = error_info;
var e = new Error(name);
/**
* Set error and throw to abort execution.
*
* *NOTE: If called outside of AsyncSteps stack (e.g. by external event), make sure you catch the exception*
* @param {string} name - error message, expected to be identifier "InternalError"
* @param {string=} error_info - optional descriptive message assigned to as.state.error_info
* @throws {Error}
* @alias AsyncSteps#error
*/
if (!this._in_exec) {
this.state.last_exception = e;
}, {
key: 'error',
value: function error(name, error_info) {
this.state.error_info = error_info;
this._handle_error(name);
}
var e = new Error(name);
throw e;
}
/**
* Copy steps and not yet defined state variables from "model" AsyncSteps instance
* @param {AsyncSteps} other - model instance, which must get be executed
* @returns {AsyncSteps} self
* @alias AsyncSteps#copyFrom
*/
if (!this._in_exec) {
this.state.last_exception = e;
this._handle_error(name);
}
}, {
key: "copyFrom",
value: function copyFrom(other) {
this._queue.push.apply(this._queue, other._queue);
throw e;
}
var os = other.state;
var s = this.state;
/**
* Copy steps and not yet defined state variables from "model" AsyncSteps instance
* @param {AsyncSteps} other - model instance, which must get be executed
* @returns {AsyncSteps} self
* @alias AsyncSteps#copyFrom
*/
}, {
key: 'copyFrom',
value: function copyFrom(other) {
this._queue.push.apply(this._queue, other._queue);
var os = other.state;
var s = this.state;
for (var k in os) {
if (!(k in s)) {
s[k] = os[k];
}
}
return this;
for (var k in os) {
if (!(k in s)) {
s[k] = os[k];
}
}
/**
* @private
* @param {array} [args] List of success() args
*/
return this;
}
/**
* @private
* @param {array} [args] List of success() args
*/
}, {
key: '_handle_success',
value: function _handle_success() {
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;
}, {
key: "_handle_success",
value: function _handle_success() {
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;
var stack = this._stack;
var stack = this._stack;
if (!stack.length) {
this.error(InternalError, 'Invalid success completion');
}
if (!stack.length) {
this.error(InternalError, 'Invalid success completion');
}
this._next_args = args;
this._next_args = args;
for (var asp = stack[stack.length - 1];;) {
var limit_event = asp._limit_event;
for (var asp = stack[stack.length - 1];;) {
var limit_event = asp._limit_event;
if (limit_event) {
this._async_tool.cancelCall(limit_event);
if (limit_event) {
this._async_tool.cancelCall(limit_event);
asp._limit_event = null;
}
asp._limit_event = null;
}
asp._cleanup(); // aid GC
stack.pop();
asp._cleanup(); // aid GC
// ---
if (!stack.length) {
break;
}
asp = stack[stack.length - 1];
stack.pop(); // ---
if (asp._queue.length) {
break;
}
}
if (stack.length || this._queue.length) {
this._scheduleExecute();
}
if (!stack.length) {
break;
}
/**
* @private
* @param {string} [name] Error to handle
*/
asp = stack[stack.length - 1];
}, {
key: '_handle_error',
value: function _handle_error(name) {
if (this._exec_event) {
this.cancel();
return;
}
if (asp._queue.length) {
break;
}
}
this._next_args = EMPTY_ARRAY;
if (stack.length || this._queue.length) {
this._scheduleExecute();
}
}
/**
* @private
* @param {string} [name] Error to handle
*/
var stack = this._stack;
var exec_stack = this._exec_stack;
}, {
key: "_handle_error",
value: function _handle_error(name) {
if (this._exec_event) {
this.cancel();
return;
}
this.state.async_stack = exec_stack;
this._next_args = EMPTY_ARRAY;
var stack = this._stack;
var exec_stack = this._exec_stack;
this.state.async_stack = exec_stack;
var orig_in_exec = this._in_exec;
var cleanup = true;
var orig_in_exec = this._in_exec;
var cleanup = true;
while (stack.length) {
var asp = stack[stack.length - 1];
var limit_event = asp._limit_event;
var on_cancel = asp._on_cancel;
var on_error = asp._on_error;
while (stack.length) {
var asp = stack[stack.length - 1];
var limit_event = asp._limit_event;
var on_cancel = asp._on_cancel;
var on_error = asp._on_error;
if (limit_event) {
this._async_tool.cancelCall(limit_event);
if (limit_event) {
this._async_tool.cancelCall(limit_event);
asp._limit_event = null;
}
asp._limit_event = null;
}
if (on_cancel) {
on_cancel.call(null, asp);
asp._on_cancel = null;
}
if (on_cancel) {
on_cancel.call(null, asp);
asp._on_cancel = null;
}
if (on_error) {
var slen = stack.length;
asp._queue = null; // suppress non-empty queue for success() in onerror
asp._on_error = null; // do no repeat
exec_stack.push(on_error);
if (on_error) {
var slen = stack.length;
asp._queue = null; // suppress non-empty queue for success() in onerror
try {
this._in_exec = true;
on_error.call(null, asp, name);
asp._on_error = null; // do no repeat
if (slen !== stack.length) {
cleanup = false;
break; // override with success()
}
exec_stack.push(on_error);
if (asp._queue !== null) {
cleanup = false;
this._scheduleExecute();
break;
}
} catch (e) {
this.state.last_exception = e;
name = e.message;
} finally {
this._in_exec = orig_in_exec;
}
}
try {
this._in_exec = true;
on_error.call(null, asp, name);
asp._cleanup(); // aid GC
stack.pop();
if (slen !== stack.length) {
cleanup = false;
break; // override with success()
}
if (cleanup) {
// Clear queue on finish
this._queue = [];
} else if (!orig_in_exec) {
this._post_exec(this);
if (asp._queue !== null) {
cleanup = false;
this._scheduleExecute();
break;
}
} catch (e) {
this.state.last_exception = e;
name = e.message;
} finally {
this._in_exec = orig_in_exec;
}
}
/**
* Use only on root AsyncSteps instance. Abort execution of AsyncSteps instance in progress.
* @returns {AsyncSteps} self
* @alias AsyncSteps#cancel
*/
asp._cleanup(); // aid GC
}, {
key: 'cancel',
value: function cancel() {
this._next_args = EMPTY_ARRAY;
var exec_event = this._exec_event;
stack.pop();
}
if (exec_event) {
this._async_tool.cancelImmediate(exec_event);
this._exec_event = null;
}
if (cleanup) {
// Clear queue on finish
this._queue = [];
} else if (!orig_in_exec) {
this._post_exec(this);
}
}
/**
* Use only on root AsyncSteps instance. Abort execution of AsyncSteps instance in progress.
* @returns {AsyncSteps} self
* @alias AsyncSteps#cancel
*/
var stack = this._stack;
var async_tool = this._async_tool;
}, {
key: "cancel",
value: function cancel() {
this._next_args = EMPTY_ARRAY;
var exec_event = this._exec_event;
while (stack.length) {
var asp = stack.pop();
var limit_event = asp._limit_event;
var on_cancel = asp._on_cancel;
if (exec_event) {
this._async_tool.cancelImmediate(exec_event);
if (limit_event) {
async_tool.cancelCall(limit_event);
asp._limit_event = null;
}
this._exec_event = null;
}
if (on_cancel) {
on_cancel.call(null, asp);
asp._on_cancel = null;
}
var stack = this._stack;
var async_tool = this._async_tool;
asp._cleanup(); // aid GC
}
while (stack.length) {
var asp = stack.pop();
var limit_event = asp._limit_event;
var on_cancel = asp._on_cancel;
// Clear queue on finish
this._queue = [];
return this;
if (limit_event) {
async_tool.cancelCall(limit_event);
asp._limit_event = null;
}
/**
* Start execution of AsyncSteps using AsyncTool
*
* It must not be called more than once until cancel/complete (instance can be re-used)
* @returns {AsyncSteps} self
* @alias AsyncSteps#execute
*/
}, {
key: 'execute',
value: function execute() {
var prev_owner = g_burst_owner;
g_burst_owner = this;
this._execute();
g_burst_owner = prev_owner;
return this;
if (on_cancel) {
on_cancel.call(null, asp);
asp._on_cancel = null;
}
}, {
key: '_execute',
value: function _execute() {
var stack = this._stack;
var q = void 0;
if (stack.length) {
q = stack[stack.length - 1]._queue;
} else {
q = this._queue;
}
asp._cleanup(); // aid GC
if (!q.length) {
return;
}
} // Clear queue on finish
var curr = q.shift();
var func = curr[0];
this._exec_stack.push(func);
var next_args = this._next_args;
var na_len = next_args.length;
this._queue = [];
return this;
}
/**
* Start execution of AsyncSteps using AsyncTool
*
* It must not be called more than once until cancel/complete (instance can be re-used)
* @returns {AsyncSteps} self
* @alias AsyncSteps#execute
*/
var asp = new AsyncStepProtector(this, curr[1], next_args);
stack.push(asp);
}, {
key: "execute",
value: function execute() {
var prev_owner = g_burst_owner;
g_burst_owner = this;
try {
var oc = stack.length;
this._execute();
this._in_exec = true;
g_burst_owner = prev_owner;
return this;
}
}, {
key: "_execute",
value: function _execute() {
var stack = this._stack;
var q;
if (!na_len) {
func(asp);
} else {
this._next_args = EMPTY_ARRAY;
func.apply(undefined, [asp].concat(_toConsumableArray(next_args)));
}
if (stack.length) {
q = stack[stack.length - 1]._queue;
} else {
q = this._queue;
}
if (oc === stack.length) {
if (asp._queue !== null) {
this._scheduleExecute();
} else if (!asp._on_cancel && !asp._limit_event) {
// Implicit success
this._handle_success(this._next_args);
}
}
} catch (e) {
this.state.last_exception = e;
this._handle_error(e.message);
} finally {
this._in_exec = false;
}
if (!q.length) {
return;
}
this._post_exec(this);
}
var curr = q.shift();
var func = curr[0];
/**
* Optimized success() which performs burst execution
* @param {array} [args] List of success() args
* @private
*/
this._exec_stack.push(func);
}, {
key: '_burst_success',
value: function _burst_success() {
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;
var next_args = this._next_args;
var na_len = next_args.length;
var asp = new AsyncStepProtector(this, curr[1], next_args);
stack.push(asp);
try {
this._in_exec = true;
g_burst_owner = this;
this._handle_success(args);
} catch (e) {
this.state.last_exception = e;
this._handle_error(e.message);
} finally {
this._in_exec = false;
}
try {
var oc = stack.length;
this._in_exec = true;
this._post_exec(this);
if (!na_len) {
func(asp);
} else {
this._next_args = EMPTY_ARRAY;
func.apply(void 0, [asp].concat(_toConsumableArray(next_args)));
}
/**
* It is just a subset of *ExecFunc*
* @callback LoopFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @alias loop_callback
* @see ExecFunc
*/
/**
* Execute loop until *as.break()* or *as.error()* is called
* @param {LoopFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#loop
*/
}, {
key: 'loop',
value: function loop(func, label) {
sanityCheckAdd(this, func);
_loop(this, this, func, label);
return this;
if (oc === stack.length) {
if (asp._queue !== null) {
this._scheduleExecute();
} else if (!asp._on_cancel && !asp._limit_event) {
// Implicit success
this._handle_success(this._next_args);
}
}
} catch (e) {
this.state.last_exception = e;
/**
* It is just a subset of *ExecFunc*
* @callback RepeatFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @param {integer} i - current iteration starting from 0
* @alias repeat_callback
* @see ExecFunc
*/
this._handle_error(e.message);
} finally {
this._in_exec = false;
}
/**
* Call *func(as, i)* for *count* times
* @param {integer} count - how many times to call the *func*
* @param {RepeatFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#repeat
*/
this._post_exec(this);
}
/**
* Optimized success() which performs burst execution
* @param {array} [args] List of success() args
* @private
*/
}, {
key: 'repeat',
value: function repeat(count, func, label) {
sanityCheckAdd(this, func);
}, {
key: "_burst_success",
value: function _burst_success() {
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;
_repeat(this, this, count, func, label);
try {
this._in_exec = true;
g_burst_owner = this;
return this;
}
this._handle_success(args);
} catch (e) {
this.state.last_exception = e;
/**
* It is just a subset of *ExecFunc*
* @callback ForEachFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @param {integer|string} key - key ID or name
* @param {*} value - value associated with key
* @alias foreach_callback
* @see ExecFunc
*/
this._handle_error(e.message);
} finally {
this._in_exec = false;
}
/**
* For each *map* or *list* element call *func( as, key, value )*
* @param {integer} map_or_list - map or list to iterate over
* @param {ForEachFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#forEach
*/
this._post_exec(this);
}
/**
* It is just a subset of *ExecFunc*
* @callback LoopFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @alias loop_callback
* @see ExecFunc
*/
}, {
key: 'forEach',
value: function forEach(map_or_list, func, label) {
sanityCheckAdd(this, func);
/**
* Execute loop until *as.break()* or *as.error()* is called
* @param {LoopFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#loop
*/
_forEach(this, this, map_or_list, func, label);
}, {
key: "loop",
value: function loop(func, label) {
sanityCheckAdd(this, func);
return this;
}
_loop(this, this, func, label);
/**
* Shortcut for `this.add( ( as ) => as.success( ...args ) )`
* @param {any} [args...] - argument to pass, if any
* @alias AsyncSteps#successStep
* @returns {AsyncSteps} self
*/
return this;
}
/**
* It is just a subset of *ExecFunc*
* @callback RepeatFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @param {integer} i - current iteration starting from 0
* @alias repeat_callback
* @see ExecFunc
*/
}, {
key: 'successStep',
value: function successStep() {
var _this2 = this;
/**
* Call *func(as, i)* for *count* times
* @param {integer} count - how many times to call the *func*
* @param {RepeatFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#repeat
*/
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
}, {
key: "repeat",
value: function repeat(count, func, label) {
sanityCheckAdd(this, func);
sanityCheck(this);
_repeat(this, this, count, func, label);
var queue = this._queue;
return this;
}
/**
* It is just a subset of *ExecFunc*
* @callback ForEachFunc
* @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection
* @param {integer|string} key - key ID or name
* @param {*} value - value associated with key
* @alias foreach_callback
* @see ExecFunc
*/
if (queue.length > 0) {
queue.push([function () {
_this2._handle_success(args);
}, undefined]);
} else {
this._next_args = args;
}
/**
* For each *map* or *list* element call *func( as, key, value )*
* @param {integer} map_or_list - map or list to iterate over
* @param {ForEachFunc} func - loop body
* @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops
* @returns {AsyncSteps} self
* @alias AsyncSteps#forEach
*/
return this;
}
}, {
key: "forEach",
value: function forEach(map_or_list, func, label) {
sanityCheckAdd(this, func);
/**
* Integrate a promise as a step.
* @param {Promise} promise - promise to add as a step
* @param {function} [onerror] error handler to check
* @alias AsyncSteps#await
* @returns {AsyncSteps} self
*/
_forEach(this, this, map_or_list, func, label);
}, {
key: 'await',
value: function _await(promise, onerror) {
sanityCheck(this);
return this;
}
/**
* Shortcut for `this.add( ( as ) => as.success( ...args ) )`
* @param {any} [args...] - argument to pass, if any
* @alias AsyncSteps#successStep
* @returns {AsyncSteps} self
*/
as_await(this, this, promise, onerror);
}, {
key: "successStep",
value: function successStep() {
var _this2 = this;
return this;
}
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
/**
* Execute AsyncSteps with Promise interface
* @returns {Promise} - promise wrapper for AsyncSteps
*/
sanityCheck(this);
var queue = this._queue;
}, {
key: 'promise',
value: function promise() {
var _this3 = this;
if (queue.length > 0) {
queue.push([function () {
_this2._handle_success(args);
}, undefined]);
} else {
this._next_args = args;
}
sanityCheck(this);
return this;
}
/**
* Integrate a promise as a step.
* @param {Promise} promise - promise to add as a step
* @param {function} [onerror] error handler to check
* @alias AsyncSteps#await
* @returns {AsyncSteps} self
*/
return new Promise(function (resolve, reject) {
var q = _this3._queue;
}, {
key: "await",
value: function _await(promise, onerror) {
sanityCheck(this);
as_await(this, this, promise, onerror);
return this;
}
/**
* Execute AsyncSteps with Promise interface
* @returns {Promise} - promise wrapper for AsyncSteps
*/
_this3._queue = [[function (as) {
as._queue = q;
}, function (as, err) {
reject(new Error(err));
}], [function (as, res) {
resolve(res);
}, undefined]];
}, {
key: "promise",
value: function promise() {
var _this3 = this;
g_burst_owner = _this3;
_this3._execute();
});
}
sanityCheck(this);
return new Promise(function (resolve, reject) {
var q = _this3._queue;
_this3._queue = [[function (as) {
as._queue = q;
}, function (as, err) {
reject(new Error(err));
}], [function (as, res) {
resolve(res);
}, undefined]];
g_burst_owner = _this3;
/**
* Not standard API for assertion with multiple instances of the module.
* @private
* @returns {boolean} true
*/
_this3._execute();
});
}
/**
* Not standard API for assertion with multiple instances of the module.
* @private
* @returns {boolean} true
*/
}, {
key: 'isAsyncSteps',
value: function isAsyncSteps() {
return true;
}
}]);
}, {
key: "isAsyncSteps",
value: function isAsyncSteps() {
return true;
}
}]);
return AsyncSteps;
return AsyncSteps;
}();
/**

@@ -726,3 +720,4 @@ * *execute_callback* as defined in **FTN12: FutoIn AsyncSteps** specification. Function must have

module.exports = AsyncSteps;
//# sourceMappingURL=AsyncSteps.js.map
"use strict";
/**

@@ -27,3 +26,2 @@ * @file

var error_list = ['ConnectError', 'CommError', 'UnknownInterface', 'NotSupportedVersion', 'NotImplemented', 'Unauthorized', 'InternalError', 'InvokerError', 'InvalidRequest', 'DefenseRejected', 'PleaseReauth', 'SecurityError', 'Timeout', 'LoopBreak', 'LoopCont'];
/**

@@ -37,3 +35,2 @@ * List of standard FutoIn Core errors. It may static get extended in runtime.

};
/**

@@ -148,2 +145,3 @@ * Connection error before request is sent.

error_list.forEach(function (v) {

@@ -155,4 +153,3 @@ return Object.defineProperty(Errors, v, {

});
module.exports = Errors;
//# sourceMappingURL=Errors.js.map
"use strict";
/**

@@ -24,9 +23,10 @@ * @file

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _require = require('./Errors'),
NotImplemented = _require.NotImplemented;
/**

@@ -38,3 +38,5 @@ * Base interface for synchronization primitives

var ISync = function () {
var ISync =
/*#__PURE__*/
function () {
function ISync() {

@@ -45,3 +47,3 @@ _classCallCheck(this, ISync);

_createClass(ISync, [{
key: 'sync',
key: "sync",
value: function sync(as, _func, _onerror) {

@@ -48,0 +50,0 @@ as.error(NotImplemented, '#sync() API');

"use strict";
/**

@@ -24,6 +23,8 @@ * @file Protector against AsyncSteps concept violation in use

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var ParallelStep = require('./ParallelStep');

@@ -49,33 +50,32 @@

var sanityCheck = isProduction ? noop : function (asp) {
var root = asp._root;
var root = asp._root;
if (root) {
var stack = root._stack;
if (root) {
var stack = root._stack;
if (stack) {
if (stack[stack.length - 1] === asp) {
return;
}
if (stack) {
if (stack[stack.length - 1] === asp) {
return;
}
root.error(InternalError, "Invalid call (sanity check)");
}
root.error(InternalError, "Invalid call (sanity check)");
}
}
throw new Error('InternalError: Unexpected call, object is out of service');
throw new Error("InternalError: Unexpected call, object is out of service");
};
var sanityCheckAdd = isProduction ? noop : function (asp, func, onerror) {
sanityCheck(asp);
checkFunc(asp, func);
checkOnError(asp, onerror);
sanityCheck(asp);
checkFunc(asp, func);
checkOnError(asp, onerror);
};
var on_timeout = function on_timeout(asi) {
asi._limit_event = null;
var state = asi.state;
asi._limit_event = null;
var state = asi.state;
state.error_info = undefined;
state.last_exception = new Error(Timeout);
state.error_info = undefined;
state.last_exception = new Error(Timeout);
asi._root._handle_error(Timeout);
asi._root._handle_error(Timeout);
};
/**

@@ -88,15 +88,38 @@ * AsyncStepProtector

var AsyncStepProtector = function () {
function AsyncStepProtector(root, on_error, call_args) {
_classCallCheck(this, AsyncStepProtector);
this._root = root;
this.state = root.state;
this._queue = null;
this._call_args = call_args;
this._on_error = on_error;
this._on_cancel = null;
this._limit_event = null;
var AsyncStepProtector =
/*#__PURE__*/
function () {
function AsyncStepProtector(root, on_error, call_args) {
_classCallCheck(this, AsyncStepProtector);
this._root = root;
this.state = root.state;
this._queue = null;
this._call_args = call_args;
this._on_error = on_error;
this._on_cancel = null;
this._limit_event = null;
}
/**
* @private
* @override
*/
_createClass(AsyncStepProtector, [{
key: "add",
value: function add(func, onerror) {
sanityCheckAdd(this, func, onerror);
var s = [func, onerror];
var q = this._queue;
if (q) {
q.push(s);
} else {
this._queue = [s];
}
return this;
}
/**

@@ -107,325 +130,279 @@ * @private

}, {
key: "parallel",
value: function parallel(onerror) {
var p = new ParallelStep(this._root, this);
this.add(function (as) {
p.executeParallel(as);
}, onerror);
return p;
}
/**
* Successfully complete current step execution, optionally passing result variables to the next step.
* @param {...*} [_arg] - unlimited number of result variables with no type constraint
* @alias AsyncSteps#success
*/
_createClass(AsyncStepProtector, [{
key: 'add',
value: function add(func, onerror) {
sanityCheckAdd(this, func, onerror);
}, {
key: "success",
value: function success() {
sanityCheck(this);
var s = [func, onerror];
var q = this._queue;
if (this._queue !== null) {
this.error(InternalError, "Invalid success() call");
}
if (q) {
q.push(s);
} else {
this._queue = [s];
}
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this;
}
this._root._handle_success(args);
}
/**
* @private
* @override
*/
/**
* @private
* @override
*/
}, {
key: "error",
value: function error(name, error_info) {
sanityCheck(this);
}, {
key: 'parallel',
value: function parallel(onerror) {
var p = new ParallelStep(this._root, this);
this._root.error(name, error_info);
}
/**
* Set timeout for external event completion with async *as.success()* or *as.error()* call.
* If step is not finished until timeout is reached then Timeout error is raised.
*
* @note Can be used only within **ExecFunc** body.
* @param {number} timeout_ms - Timeout in ms
* @returns {AsyncSteps} self
* @alias AsyncSteps#setTimeout
*/
this.add(function (as) {
p.executeParallel(as);
}, onerror);
}, {
key: "setTimeout",
value: function setTimeout(timeout_ms) {
var _this = this;
return p;
}
sanityCheck(this);
var async_tool = this._root._async_tool;
/**
* Successfully complete current step execution, optionally passing result variables to the next step.
* @param {...*} [_arg] - unlimited number of result variables with no type constraint
* @alias AsyncSteps#success
*/
if (this._limit_event !== null) {
async_tool.cancelCall(this._limit_event);
}
}, {
key: 'success',
value: function success() {
sanityCheck(this);
this._limit_event = async_tool.callLater(function () {
on_timeout(_this);
}, timeout_ms);
return this;
}
/**
* Set cancellation handler to properly handle timeouts and external cancellation.
*
* @note Can be used only within **ExecFunc** body.
* @param {CancelFunc} oncancel - cleanup/cancel logic of external processing
* @returns {AsyncSteps} self
* @alias AsyncSteps#setCancel
*/
if (this._queue !== null) {
this.error(InternalError, "Invalid success() call");
}
}, {
key: "setCancel",
value: function setCancel(oncancel) {
this._on_cancel = oncancel;
return this;
}
/**
* Mark currently executing step as waiting for external event.
*
* @note Can be used only within **ExecFunc** body.
* @returns {AsyncSteps} self
* @alias AsyncSteps#waitExternal
*/
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
}, {
key: "waitExternal",
value: function waitExternal() {
this._on_cancel = noop;
return this;
}
/**
* @private
* @override
*/
this._root._handle_success(args);
}
}, {
key: "copyFrom",
value: function copyFrom(other) {
sanityCheck(this);
/**
* @private
* @override
*/
if (other._queue.length) {
var q = this._queue;
}, {
key: 'error',
value: function error(name, error_info) {
sanityCheck(this);
this._root.error(name, error_info);
if (q === null) {
q = [];
this._queue = q;
}
/**
* Set timeout for external event completion with async *as.success()* or *as.error()* call.
* If step is not finished until timeout is reached then Timeout error is raised.
*
* @note Can be used only within **ExecFunc** body.
* @param {number} timeout_ms - Timeout in ms
* @returns {AsyncSteps} self
* @alias AsyncSteps#setTimeout
*/
q.push.apply(q, other._queue);
}
}, {
key: 'setTimeout',
value: function setTimeout(timeout_ms) {
var _this = this;
var os = other.state;
var s = this.state;
sanityCheck(this);
var async_tool = this._root._async_tool;
if (this._limit_event !== null) {
async_tool.cancelCall(this._limit_event);
}
this._limit_event = async_tool.callLater(function () {
on_timeout(_this);
}, timeout_ms);
return this;
for (var k in os) {
if (s[k] === undefined) {
s[k] = os[k];
}
}
/**
* Set cancellation handler to properly handle timeouts and external cancellation.
*
* @note Can be used only within **ExecFunc** body.
* @param {CancelFunc} oncancel - cleanup/cancel logic of external processing
* @returns {AsyncSteps} self
* @alias AsyncSteps#setCancel
*/
return this;
}
/**
* @private
* @override
*/
}, {
key: 'setCancel',
value: function setCancel(oncancel) {
this._on_cancel = oncancel;
return this;
}
}, {
key: "loop",
value: function loop(func, label) {
sanityCheckAdd(this, func);
/**
* Mark currently executing step as waiting for external event.
*
* @note Can be used only within **ExecFunc** body.
* @returns {AsyncSteps} self
* @alias AsyncSteps#waitExternal
*/
_loop(this, this._root, func, label);
}, {
key: 'waitExternal',
value: function waitExternal() {
this._on_cancel = noop;
return this;
}
return this;
}
/**
* @private
* @override
*/
/**
* @private
* @override
*/
}, {
key: "repeat",
value: function repeat(count, func, label) {
sanityCheckAdd(this, func);
}, {
key: 'copyFrom',
value: function copyFrom(other) {
sanityCheck(this);
_repeat(this, this._root, count, func, label);
if (other._queue.length) {
var q = this._queue;
return this;
}
/**
* @private
* @override
*/
if (q === null) {
q = [];
this._queue = q;
}
}, {
key: "forEach",
value: function forEach(map_or_list, func, label) {
sanityCheckAdd(this, func);
q.push.apply(q, other._queue);
}
_forEach(this, this._root, map_or_list, func, label);
var os = other.state;
var s = this.state;
return this;
}
/**
* Break execution of current loop, throws exception
* @param {string=} label - Optional. unwind loops, until *label* named loop is exited
* @alias AsyncSteps#break
*/
for (var k in os) {
if (s[k] === undefined) {
s[k] = os[k];
}
}
}, {
key: "break",
value: function _break(label) {
sanityCheck(this);
this.state[LOOP_TERM_LABEL] = label;
return this;
}
this._root.error(LoopBreak);
}
/**
* Continue loop execution from the next iteration, throws exception
* @param {string=} label - Optional. unwind loops, until *label* named loop is found
* @alias AsyncSteps#continue
*/
/**
* @private
* @override
*/
}, {
key: "continue",
value: function _continue(label) {
sanityCheck(this);
this.state[LOOP_TERM_LABEL] = label;
}, {
key: 'loop',
value: function loop(func, label) {
sanityCheckAdd(this, func);
this._root.error(LoopCont);
}
/**
* @private
* @override
*/
_loop(this, this._root, func, label);
}, {
key: "successStep",
value: function successStep() {
var _this2 = this;
return this;
}
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
/**
* @private
* @override
*/
sanityCheck(this);
var queue = this._queue;
}, {
key: 'repeat',
value: function repeat(count, func, label) {
sanityCheckAdd(this, func);
if (queue && queue.length) {
queue.push([function () {
_this2._root._handle_success(args);
}, undefined]);
} else {
this._root._next_args = args;
}
_repeat(this, this._root, count, func, label);
return this;
}
/**
* @private
* @override
*/
return this;
}
}, {
key: "await",
value: function _await(promise, onerror) {
sanityCheck(this);
as_await(this, this._root, promise, onerror);
return this;
}
/**
* @private
* @override
*/
/**
* @private
* @override
*/
}, {
key: "sync",
value: function sync(object, func, onerror) {
sanityCheckAdd(this, func, onerror);
object.sync(this, func, onerror);
return this;
}
/**
* @private
* @override
*/
}, {
key: 'forEach',
value: function forEach(map_or_list, func, label) {
sanityCheckAdd(this, func);
}, {
key: "isAsyncSteps",
value: function isAsyncSteps() {
return true;
}
/**
* @private
*/
_forEach(this, this._root, map_or_list, func, label);
}, {
key: "_cleanup",
value: function _cleanup() {
this._root = null; //this._queue = null;
//this._on_error = null;
//this._on_cancel = null;
return this;
}
this.state = null;
}
}]);
/**
* Break execution of current loop, throws exception
* @param {string=} label - Optional. unwind loops, until *label* named loop is exited
* @alias AsyncSteps#break
*/
}, {
key: 'break',
value: function _break(label) {
sanityCheck(this);
this.state[LOOP_TERM_LABEL] = label;
this._root.error(LoopBreak);
}
/**
* Continue loop execution from the next iteration, throws exception
* @param {string=} label - Optional. unwind loops, until *label* named loop is found
* @alias AsyncSteps#continue
*/
}, {
key: 'continue',
value: function _continue(label) {
sanityCheck(this);
this.state[LOOP_TERM_LABEL] = label;
this._root.error(LoopCont);
}
/**
* @private
* @override
*/
}, {
key: 'successStep',
value: function successStep() {
var _this2 = this;
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
sanityCheck(this);
var queue = this._queue;
if (queue && queue.length) {
queue.push([function () {
_this2._root._handle_success(args);
}, undefined]);
} else {
this._root._next_args = args;
}
return this;
}
/**
* @private
* @override
*/
}, {
key: 'await',
value: function _await(promise, onerror) {
sanityCheck(this);
as_await(this, this._root, promise, onerror);
return this;
}
/**
* @private
* @override
*/
}, {
key: 'sync',
value: function sync(object, func, onerror) {
sanityCheckAdd(this, func, onerror);
object.sync(this, func, onerror);
return this;
}
/**
* @private
* @override
*/
}, {
key: 'isAsyncSteps',
value: function isAsyncSteps() {
return true;
}
/**
* @private
*/
}, {
key: '_cleanup',
value: function _cleanup() {
this._root = null;
//this._queue = null;
//this._on_error = null;
//this._on_cancel = null;
this.state = null;
}
}]);
return AsyncStepProtector;
return AsyncStepProtector;
}();

@@ -432,0 +409,0 @@

"use strict";
/**

@@ -30,116 +29,121 @@ * @file

exports = module.exports = {};
/* istanbul ignore if */
/* istanbul ignore if */
if (typeof setImmediate === 'undefined') {
// Wrapper for simple setTimeout
// ---
exports.callLater = function (func, timeout_ms) {
return setTimeout(func, timeout_ms);
};
exports.cancelCall = function (func) {
return clearTimeout(func);
};
// Wrapper for simple setTimeout
// ---
exports.callLater = function (func, timeout_ms) {
return setTimeout(func, timeout_ms);
};
// Workaround for security-delayed setTimeout
// ---
exports.cancelCall = function (func) {
return clearTimeout(func);
}; // Workaround for security-delayed setTimeout
// ---
// workaround possible multiple instances of AsyncSteps
// eslint-disable-next-line no-undef
// workaround possible multiple instances of AsyncSteps
// eslint-disable-next-line no-undef
window._FutoInEventLoopQueue = window._FutoInEventLoopQueue || [];
var TIME_LIMIT = 10; // support browser with 100ms precision
// eslint-disable-next-line no-undef
var queue = window._FutoInEventLoopQueue;
// eslint-disable-next-line no-undef
var performance = window.performance;
var process_handle = null;
window._FutoInEventLoopQueue = window._FutoInEventLoopQueue || [];
var TIME_LIMIT = 10; // support browser with 100ms precision
// eslint-disable-next-line no-undef
var sched_immed_process = function sched_immed_process() {
if (process_handle) {
clearTimeout(process_handle);
}
var queue = window._FutoInEventLoopQueue; // eslint-disable-next-line no-undef
process_handle = setTimeout(process_queue, 0);
};
var performance = window.performance;
var process_handle = null;
var process_queue = function process_queue() {
process_handle = null;
var end_time = performance.now() + TIME_LIMIT;
var sched_immed_process = function sched_immed_process() {
if (process_handle) {
clearTimeout(process_handle);
}
while (queue.length) {
var r = queue.shift();
process_handle = setTimeout(process_queue, 0);
};
try {
r();
} catch (e) {
sched_immed_process();
throw e;
}
var process_queue = function process_queue() {
process_handle = null;
var end_time = performance.now() + TIME_LIMIT;
if (performance.now() >= end_time) {
sched_immed_process();
break;
}
}
};
while (queue.length) {
var r = queue.shift();
exports.callImmediate = function (func) {
if (!queue.length) {
sched_immed_process();
}
try {
r();
} catch (e) {
sched_immed_process();
throw e;
}
var handle = function handle() {
func();
}; // same func can be added multiple times
queue.push(handle);
if (performance.now() >= end_time) {
sched_immed_process();
break;
}
}
};
return handle;
};
exports.cancelImmediate = function (handle) {
var i = queue.indexOf(handle);
exports.callImmediate = function (func) {
if (!queue.length) {
sched_immed_process();
}
if (i >= 0) {
queue.splice(i, 1);
}
};
var handle = function handle() {
func();
}; // same func can be added multiple times
queue.push(handle);
return handle;
};
exports.cancelImmediate = function (handle) {
var i = queue.indexOf(handle);
if (i >= 0) {
queue.splice(i, 1);
}
};
} else {
/**
* Wrapper for setTimeout()
* @param {Function} func - callback to execute
* @param {number} [timeout_ms=0] - optional timeout in ms
* @returns {Object} - timer handle
* @alias AsyncTool.callLater
*/
exports.callLater = function (func, timeout_ms) {
return setTimeout(func, timeout_ms);
};
/**
* Wrapper for setTimeout()
* @param {Function} func - callback to execute
* @param {number} [timeout_ms=0] - optional timeout in ms
* @returns {Object} - timer handle
* @alias AsyncTool.callLater
*/
exports.callLater = function (func, timeout_ms) {
return setTimeout(func, timeout_ms);
};
/**
* Wrapper for clearTimeout()/clearImmediate()
* @param {Object} handle - Handle returned from AsyncTool.callLater
* @alias AsyncTool.cancelCall
*/
/**
* Wrapper for clearTimeout()/clearImmediate()
* @param {Object} handle - Handle returned from AsyncTool.callLater
* @alias AsyncTool.cancelCall
*/
exports.cancelCall = function (handle) {
clearTimeout(handle);
};
/**
* Wrapper for setImmediate()
* @param {Function} func - callback to execute
* @returns {Object} - timer handle
* @alias AsyncTool.callImmediate
*/
exports.callImmediate = function (func) {
return setImmediate(func);
};
exports.cancelCall = function (handle) {
clearTimeout(handle);
};
/**
* Wrapper for setImmediate()
* @param {Function} func - callback to execute
* @returns {Object} - timer handle
* @alias AsyncTool.callImmediate
*/
/**
* Wrapper for clearImmediate()
* @param {Object} handle - Handle returned from AsyncTool.callImmediate
* @alias AsyncTool.cancelImmediate
*/
exports.cancelImmediate = function (handle) {
clearImmediate(handle);
};
exports.callImmediate = function (func) {
return setImmediate(func);
};
/**
* Wrapper for clearImmediate()
* @param {Object} handle - Handle returned from AsyncTool.callImmediate
* @alias AsyncTool.cancelImmediate
*/
exports.cancelImmediate = function (handle) {
clearImmediate(handle);
};
}
//# sourceMappingURL=AsyncTool.js.map
"use strict";
/**

@@ -25,4 +24,4 @@ * @file AsyncTool test aid for easier debugging

var performance_now = require("performance-now");
var q = [];
/**

@@ -32,4 +31,4 @@ * Special event scheduler for testing to be installed with installAsyncToolTest()

*/
exports = module.exports = {};
/**

@@ -42,27 +41,26 @@ * Adds callback to internal queue

*/
exports.callLater = function (func) {
var timeout_ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var timeout_ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var t = performance_now() * 1e3;
var t = performance_now() * 1e3;
if (timeout_ms) {
t += timeout_ms;
}
if (timeout_ms) {
t += timeout_ms;
}
var e = {
f: func,
t: t
};
var e = {
f: func,
t: t
};
for (var i = 0; i < q.length; ++i) {
if (q[i].t > t) {
q.splice(i, 0, e);
return;
}
for (var i = 0; i < q.length; ++i) {
if (q[i].t > t) {
q.splice(i, 0, e);
return;
}
}
q.push(e);
return e;
q.push(e);
return e;
};
/**

@@ -73,10 +71,11 @@ * Removed callback from internal queue

*/
exports.cancelCall = function (handle) {
var i = q.indexOf(handle);
var i = q.indexOf(handle);
if (i >= 0) {
q.splice(i, 1);
}
if (i >= 0) {
q.splice(i, 1);
}
};
/**

@@ -86,11 +85,11 @@ * Process next even in the internal queue

*/
exports.nextEvent = function () {
var e = q.shift();
var e = q.shift(); // We do not wait for timeout, there is little practical use for that
// even in scope of testing. If we come to the point, where we need to sleep
// then no other event would get earlier under normal conditions.
// We do not wait for timeout, there is little practical use for that
// even in scope of testing. If we come to the point, where we need to sleep
// then no other event would get earlier under normal conditions.
e.f();
e.f();
};
/**

@@ -101,6 +100,7 @@ * Check if there are any events scheduled

*/
exports.hasEvents = function () {
return q.length > 0;
return q.length > 0;
};
/**

@@ -111,6 +111,7 @@ * Get internal even queue

*/
exports.getEvents = function () {
return q;
return q;
};
/**

@@ -120,6 +121,7 @@ * Clear internal event queue

*/
exports.resetEvents = function () {
q.splice(0, q.length);
q.splice(0, q.length);
};
/**

@@ -129,11 +131,13 @@ * Execute all remaining events in the internal queue

*/
exports.run = function () {
while (this.hasEvents()) {
this.nextEvent();
}
};
while (this.hasEvents()) {
this.nextEvent();
}
}; // Aliases for immediate
// Aliases for immediate
exports.callImmediate = exports.callLater;
exports.cancelImmediate = exports.cancelCall;
//# sourceMappingURL=AsyncToolTest.js.map

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

'use strict';
"use strict";

@@ -23,3 +23,2 @@ /**

*/
(function (window) {

@@ -32,3 +31,2 @@ 'use strict';

var $as = require('./main.js');
/**

@@ -39,4 +37,5 @@ * **window.$as** - browser-only reference to futoin-asyncsteps module

*/
window.$as = $as;
/**

@@ -47,4 +46,4 @@ * **window.FutoIn.$as** - browser-only reference to futoin-asyncsteps module

*/
futoin.$as = $as;
/**

@@ -55,4 +54,4 @@ * **window.FutoInError** - browser-only reference to futoin-asyncsteps.FutoInError

*/
window.FutoInError = $as.FutoInError;
/**

@@ -63,2 +62,3 @@ * **window.futoin.AsyncSteps** - browser-only reference to futoin-asyncsteps.AsyncSteps

*/
futoin.AsyncSteps = $as.AsyncSteps;

@@ -65,0 +65,0 @@ window.FutoIn = futoin;

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

'use strict';
"use strict";

@@ -23,3 +23,2 @@ /**

*/
(function (window) {

@@ -32,3 +31,2 @@ 'use strict';

var $as = require('./main-full.js');
/**

@@ -39,4 +37,5 @@ * **window.$as** - browser-only reference to futoin-asyncsteps module

*/
window.$as = $as;
/**

@@ -47,4 +46,4 @@ * **window.FutoIn.$as** - browser-only reference to futoin-asyncsteps module

*/
futoin.$as = $as;
/**

@@ -55,4 +54,4 @@ * **window.FutoInError** - browser-only reference to futoin-asyncsteps.FutoInError

*/
window.FutoInError = $as.FutoInError;
/**

@@ -63,4 +62,4 @@ * **window.futoin.AsyncSteps** - browser-only reference to futoin-asyncsteps.AsyncSteps

*/
futoin.AsyncSteps = $as.AsyncSteps;
window.FutoIn = futoin;

@@ -67,0 +66,0 @@ window.futoin = futoin;

'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var _require = require('../Errors'),
InternalError = _require.InternalError,
LoopCont = _require.LoopCont,
LoopBreak = _require.LoopBreak;
LoopBreak = _require.LoopBreak; //---
//---
var makeSym = typeof Symbol === 'undefined' ? function (name) {
return name;
return name;
} : function (name) {
return Symbol(name);
};
return Symbol(name);
}; //---
//---
var LOOP_TERM_LABEL = makeSym('_loop_term_label');
var loop_error = function loop_error(as, err, outer_as, state, label) {
if (err === LoopCont) {
var term_label = state[LOOP_TERM_LABEL];
if (err === LoopCont) {
var term_label = state[LOOP_TERM_LABEL];
if (!term_label || term_label === label) {
state.last_exception = null;
// Continue to next iteration
as._root._handle_success();
}
} else if (err === LoopBreak) {
var _term_label = state[LOOP_TERM_LABEL];
if (!term_label || term_label === label) {
state.last_exception = null; // Continue to next iteration
if (!_term_label || _term_label === label) {
state.last_exception = null;
outer_as._queue.length = 0;
as._root._handle_success();
}
as._root._handle_success();
}
} else if (err === LoopBreak) {
var _term_label = state[LOOP_TERM_LABEL];
if (!_term_label || _term_label === label) {
state.last_exception = null;
outer_as._queue.length = 0;
as._root._handle_success();
}
}
};
var loop = function loop(asi, root, func, label, end_cond) {
if (end_cond && end_cond()) {
return;
}
if (end_cond && end_cond()) {
return;
}
asi.add(function (outer_as) {
var state = outer_as.state;
asi.add(function (outer_as) {
var state = outer_as.state;
var exec_stack = root._exec_stack;
var es_len = exec_stack.length;
var step1 = [func, function (as, err) {
loop_error(as, err, outer_as, state, label);
}];
var step2 = [function (as) {
if (!end_cond || !end_cond()) {
exec_stack.length = es_len; // truncate iteration
var exec_stack = root._exec_stack;
var es_len = exec_stack.length;
create_iteration();
}
}, null];
var step1 = [func, function (as, err) {
loop_error(as, err, outer_as, state, label);
}];
var step2 = [function (as) {
if (!end_cond || !end_cond()) {
exec_stack.length = es_len; // truncate iteration
create_iteration();
}
}, null];
var create_iteration = function create_iteration() {
outer_as._queue = [step1, step2];
};
var create_iteration = function create_iteration() {
outer_as._queue = [step1, step2];
};
create_iteration();
});
}; //---
create_iteration();
});
};
//---
var repeat = function repeat(asi, root, count, func, label) {
var i = 0;
var c = count;
var i = 0;
var c = count;
loop(asi, root, function (as) {
func(as, i++);
}, label, function () {
return i >= c;
});
}; //---
loop(asi, root, function (as) {
func(as, i++);
}, label, function () {
return i >= c;
});
};
//---
var forEach = function forEach(asi, root, map_or_list, func, label) {
if (Array.isArray(map_or_list)) {
var arr = map_or_list;
if (Array.isArray(map_or_list)) {
var arr = map_or_list;
repeat(asi, root, arr.length, function (as, i) {
func(as, i, arr[i]);
}, label);
} else if (typeof Map !== 'undefined' && map_or_list instanceof Map) {
var iter = map_or_list.entries();
loop(asi, root, function (as) {
var next = iter.next();
repeat(asi, root, arr.length, function (as, i) {
func(as, i, arr[i]);
}, label);
} else if (typeof Map !== 'undefined' && map_or_list instanceof Map) {
var iter = map_or_list.entries();
if (next.done) {
as.break();
}
loop(asi, root, function (as) {
var next = iter.next();
var _next$value = _slicedToArray(next.value, 2),
key = _next$value[0],
value = _next$value[1];
if (next.done) {
as.break();
}
func(as, key, value);
}, label);
} else {
var obj = map_or_list;
var keys = Object.keys(obj);
repeat(asi, root, keys.length, function (as, i) {
func(as, keys[i], obj[keys[i]]);
}, label);
}
}; //---
var _next$value = _slicedToArray(next.value, 2),
key = _next$value[0],
value = _next$value[1];
func(as, key, value);
}, label);
} else {
var obj = map_or_list;
var keys = Object.keys(obj);
repeat(asi, root, keys.length, function (as, i) {
func(as, keys[i], obj[keys[i]]);
}, label);
}
};
//---
var await_async_error = function await_async_error(asi, root, reason) {
var state = asi.state;
var state = asi.state;
if (state) {
var default_error = 'PromiseReject';
asi._on_cancel = null;
if (state) {
var default_error = 'PromiseReject';
if (reason instanceof Error) {
state.last_exception = reason;
state.error_info = undefined;
asi._on_cancel = null;
root._handle_error(default_error);
} else {
var err = reason || default_error;
state.last_exception = new Error(err);
state.error_info = undefined;
if (reason instanceof Error) {
state.last_exception = reason;
state.error_info = undefined;
root._handle_error(default_error);
} else {
var err = reason || default_error;
state.last_exception = new Error(err);
state.error_info = undefined;
root._handle_error(err);
}
root._handle_error(err);
}
}
};
var as_await = function as_await(asi, root, promise, onerror) {
var step_as = void 0;
var complete = void 0;
var step_as;
var complete; // Attach handlers on the same tick
// Attach handlers on the same tick
promise.then(function (result) {
promise.then(function (result) {
if (step_as) {
if (step_as.state) {
root._burst_success([result]);
}
} else {
complete = function complete() {
root._handle_success([result]);
};
}
}, function (reason) {
if (step_as) {
await_async_error(step_as, root, reason);
} else {
// prevent cancel logic
step_as = null;
if (reason instanceof Error) {
complete = function complete() {
throw reason;
};
} else {
complete = function complete(asi) {
asi.error(reason || 'PromiseReject');
};
}
}
});
asi.add(function (as) {
if (complete) {
complete(as);
} else {
step_as = as;
as._on_cancel = function () {
if (step_as) {
if (step_as.state) {
root._burst_success([result]);
}
} else {
complete = function complete() {
root._handle_success([result]);
};
}
}, function (reason) {
if (step_as) {
await_async_error(step_as, root, reason);
} else {
// prevent cancel logic
step_as = null;
step_as = null;
if (reason instanceof Error) {
complete = function complete() {
throw reason;
};
} else {
complete = function complete(asi) {
asi.error(reason || 'PromiseReject');
};
}
try {
// BlueBird cancellation
promise.cancel();
} catch (_) {// ignore
}
}
});
};
}
}, onerror);
}; //---
asi.add(function (as) {
if (complete) {
complete(as);
} else {
step_as = as;
as._on_cancel = function () {
if (step_as) {
step_as = null;
var prev_queue = function prev_queue(root) {
var stack = root._stack;
var stack_len = stack.length;
return stack_len > 1 ? stack[stack_len - 2]._queue : root._queue;
}; //---
try {
// BlueBird cancellation
promise.cancel();
} catch (_) {
// ignore
}
}
};
}
}, onerror);
};
//---
var prev_queue = function prev_queue(root) {
var stack = root._stack;
var stack_len = stack.length;
return stack_len > 1 ? stack[stack_len - 2]._queue : root._queue;
};
//---
var EMPTY_ARRAY = [];
Object.freeze(EMPTY_ARRAY);
Object.freeze(EMPTY_ARRAY); //---
//---
var noop = function noop() {};
var noop = function noop() {}; //---
//---
module.exports = exports = {
noop: noop,
makeSym: makeSym,
loop: loop,
repeat: repeat,
forEach: forEach,
LOOP_TERM_LABEL: LOOP_TERM_LABEL,
as_await: as_await,
EMPTY_ARRAY: EMPTY_ARRAY,
prev_queue: prev_queue
noop: noop,
makeSym: makeSym,
loop: loop,
repeat: repeat,
forEach: forEach,
LOOP_TERM_LABEL: LOOP_TERM_LABEL,
as_await: as_await,
EMPTY_ARRAY: EMPTY_ARRAY,
prev_queue: prev_queue
};
if (process.env.NODE_ENV === 'production') {
exports.isProduction = true;
exports.checkFunc = noop;
exports.checkOnError = noop;
exports.isProduction = true;
exports.checkFunc = noop;
exports.checkOnError = noop;
var fake_exec_stack = new (
/*#__PURE__*/
function () {
function _class() {
_classCallCheck(this, _class);
}
var fake_exec_stack = new (function () {
function _class() {
_classCallCheck(this, _class);
}
_createClass(_class, [{
key: "push",
value: function push() {}
}, {
key: "length",
get: function get() {
return 0;
},
set: function set(l) {}
}]);
_createClass(_class, [{
key: 'push',
value: function push() {}
}, {
key: 'length',
get: function get() {
return 0;
},
set: function set(l) {}
}]);
return _class;
}())();
Object.freeze(fake_exec_stack);
return _class;
}())();
Object.freeze(fake_exec_stack);
exports.newExecStack = function () {
return fake_exec_stack;
};
exports.newExecStack = function () {
return fake_exec_stack;
};
} else {
exports.isProduction = false;
exports.checkFunc = function (asi, func) {
if (func.length < 1) {
asi.error(InternalError, "Step function must expect at least AsyncStep interface");
}
};
exports.isProduction = false;
exports.checkOnError = function (asi, onerror) {
if (onerror && onerror.length !== 2) {
asi.error(InternalError, "Error handler must take exactly two arguments");
}
};
exports.checkFunc = function (asi, func) {
if (func.length < 1) {
asi.error(InternalError, "Step function must expect at least AsyncStep interface");
}
};
exports.newExecStack = function () {
return [];
};
exports.checkOnError = function (asi, onerror) {
if (onerror && onerror.length !== 2) {
asi.error(InternalError, "Error handler must take exactly two arguments");
}
};
exports.newExecStack = function () {
return [];
};
}
//# sourceMappingURL=common.js.map
"use strict";
/**

@@ -25,3 +24,2 @@ * @file Module's entry point and AsyncSteps class itself

exports = module.exports = require('./main');
exports.ISync = require('../ISync');

@@ -28,0 +26,0 @@ exports.Mutex = require('../Mutex');

"use strict";
/**

@@ -29,4 +28,7 @@ * @file Module's entry point and AsyncSteps class itself

var AsyncTool = require('./AsyncTool');
var AsyncToolTest = require('./AsyncToolTest');
var Errors = require('../Errors');
var AsyncSteps = require('../AsyncSteps');

@@ -36,3 +38,2 @@

isProduction = _require.isProduction;
/**

@@ -45,3 +46,3 @@ * @private

exports = module.exports = function () {
return new AsyncSteps(null, exports.ActiveAsyncTool);
return new AsyncSteps(null, exports.ActiveAsyncTool);
};

@@ -56,3 +57,2 @@

exports.isProduction = isProduction;
/**

@@ -64,10 +64,10 @@ * Use for unit testing to fine control step execution.

*/
exports.installAsyncToolTest = function (install) {
if (install === false) {
exports.ActiveAsyncTool = AsyncTool;
} else {
exports.ActiveAsyncTool = AsyncToolTest;
}
if (install === false) {
exports.ActiveAsyncTool = AsyncTool;
} else {
exports.ActiveAsyncTool = AsyncToolTest;
}
};
/**

@@ -78,13 +78,14 @@ * Ensure parameter is instance of AsyncSteps interfaces

*/
exports.assertAS = function (as) {
try {
if (as.isAsyncSteps()) {
return;
}
} catch (_) {
// pass
try {
if (as.isAsyncSteps()) {
return;
}
} catch (_) {// pass
}
throw new Error('Not an instance of AsyncSteps: ' + as);
throw new Error("Not an instance of AsyncSteps: ".concat(as));
};
//# sourceMappingURL=main.js.map
"use strict";
/**

@@ -24,10 +23,11 @@ * @file Implementation of parallel step

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _require = require('./common'),
checkFunc = _require.checkFunc,
checkOnError = _require.checkOnError;
/**

@@ -42,158 +42,159 @@ * ParallelStep

var ParallelStep = function () {
function ParallelStep(root, as) {
_classCallCheck(this, ParallelStep);
var ParallelStep =
/*#__PURE__*/
function () {
function ParallelStep(root, as) {
_classCallCheck(this, ParallelStep);
this._root = root;
this._as = as;
this._queue = [];
this._psteps = [];
this._complete_count = 0;
this._root = root;
this._as = as;
this._queue = [];
this._psteps = [];
this._complete_count = 0;
}
/**
* @private
* @override
*/
_createClass(ParallelStep, [{
key: "add",
value: function add(func, onerror) {
checkFunc(this, func);
checkOnError(this, onerror);
this._queue.push([func, onerror]);
return this;
}
/**
* @private
* @override
*/
}, {
key: "_complete",
value: function _complete() {
this._complete_count += 1;
_createClass(ParallelStep, [{
key: "add",
value: function add(func, onerror) {
checkFunc(this, func);
checkOnError(this, onerror);
if (this._complete_count === this._psteps.length) {
this._as._root._handle_success();
this._queue.push([func, onerror]);
this._cleanup();
}
}
/**
* @private
* @param {string} [name] Error name
* @param {string} [info] Error info
*/
return this;
}
}, {
key: "_error",
value: function _error(name, info) {
try {
this._as.error(name, info);
} catch (_) {// ignore
}
}
/**
* @private
* @param {AsyncSteps} [as] current step interface
*/
/**
* @private
*/
}, {
key: "executeParallel",
value: function executeParallel(as) {
var _this = this;
}, {
key: "_complete",
value: function _complete() {
this._complete_count += 1;
var q = this._queue;
var root = this._root;
if (this._complete_count === this._psteps.length) {
this._as._root._handle_success();
this._cleanup();
}
}
if (root !== as._root) {
var p = new ParallelStep(as._root, as);
/**
* @private
* @param {string} [name] Error name
* @param {string} [info] Error info
*/
p._queue.push.apply(p._queue, q);
}, {
key: "_error",
value: function _error(name, info) {
try {
this._as.error(name, info);
} catch (_) {
// ignore
}
}
p.executeParallel(as);
return;
}
/**
* @private
* @param {AsyncSteps} [as] current step interface
*/
this._as = as;
}, {
key: "executeParallel",
value: function executeParallel(as) {
var _this = this;
if (!q.length) {
this._complete();
var q = this._queue;
var root = this._root;
return;
}
if (root !== as._root) {
var p = new ParallelStep(as._root, as);
p._queue.push.apply(p._queue, q);
p.executeParallel(as);
return;
}
as._on_cancel = function () {
_this.cancel();
};
/* */
this._as = as;
if (!q.length) {
this._complete();
return;
}
var plist = this._psteps;
as._on_cancel = function () {
_this.cancel();
};
var success_func = function success_func(as) {
_this._complete();
};
/* */
var plist = this._psteps;
var success_func = function success_func(as) {
_this._complete();
};
var error_func = function error_func(as, err) {
_this._error(err, as.state.error_info);
};
var AsyncSteps = root.constructor;
var error_func = function error_func(as, err) {
_this._error(err, as.state.error_info);
};
q.forEach(function (p) {
var pa = new AsyncSteps(as.state, root._async_tool);
var AsyncSteps = root.constructor;
q.forEach(function (p) {
var pa = new AsyncSteps(as.state, root._async_tool);
pa._queue.push([function (as) {
as._queue = [[p[0], p[1]]];
}, error_func], [success_func, undefined]);
pa._queue.push([function (as) {
as._queue = [[p[0], p[1]]];
}, error_func], [success_func, undefined]);
plist.push(pa);
});
plist.push(pa);
}); // Should be separate from the previous loop for
// in case cancel() arrives in the middle
// Should be separate from the previous loop for
// in case cancel() arrives in the middle
plist.forEach(function (p) {
// NOTE: do not use #_execute() due to lack of burst ownership handling
p.execute();
});
}
plist.forEach(function (p) {
// NOTE: do not use #_execute() due to lack of burst ownership handling
p.execute();
});
}
/**
* @private
*/
/**
* @private
*/
}, {
key: "cancel",
value: function cancel() {
this._psteps.forEach(function (p) {
p.cancel();
});
}, {
key: "cancel",
value: function cancel() {
this._psteps.forEach(function (p) {
p.cancel();
});
this._cleanup();
}
this._cleanup();
}
/**
* @private
* @override
*/
/**
* @private
* @override
*/
}, {
key: "isAsyncSteps",
value: function isAsyncSteps() {
return true;
}
/**
* @private
*/
}, {
key: "isAsyncSteps",
value: function isAsyncSteps() {
return true;
}
}, {
key: "_cleanup",
value: function _cleanup() {
this._root = null;
this._as = null;
this._psteps = null;
}
}]);
/**
* @private
*/
}, {
key: "_cleanup",
value: function _cleanup() {
this._root = null;
this._as = null;
this._psteps = null;
}
}]);
return ParallelStep;
return ParallelStep;
}();

@@ -200,0 +201,0 @@

'use strict';
/**

@@ -23,3 +22,4 @@ * @file

require('core-js/fn/weak-map');
require('core-js/fn/promise');
//# sourceMappingURL=polyfill.js.map
'use strict';
/**

@@ -24,14 +23,25 @@ * @file

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ISync = require('./ISync');
var Mutex = require('./Mutex');
var Throttle = require('./Throttle');
/**

@@ -41,39 +51,43 @@ * Limiter - complex processing limit for AsyncSteps

var Limiter = function (_ISync) {
_inherits(Limiter, _ISync);
/**
* C-tor
* @param {object} [options={}] - option map
* @param {integer} [options.concurrent=1] - maximum concurrent flows
* @param {integer} [options.max_queue=0] - maximum queued
* @param {integer} [options.rate=1] - maximum entries in period
* @param {integer} [options.period_ms=1000] - period length
* @param {integer} [options.burst=0] - maximum queue for rate limiting
*/
function Limiter() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var Limiter =
/*#__PURE__*/
function (_ISync) {
_inherits(Limiter, _ISync);
_classCallCheck(this, Limiter);
/**
* C-tor
* @param {object} [options={}] - option map
* @param {integer} [options.concurrent=1] - maximum concurrent flows
* @param {integer} [options.max_queue=0] - maximum queued
* @param {integer} [options.rate=1] - maximum entries in period
* @param {integer} [options.period_ms=1000] - period length
* @param {integer} [options.burst=0] - maximum queue for rate limiting
*/
function Limiter() {
var _this;
var _this = _possibleConstructorReturn(this, (Limiter.__proto__ || Object.getPrototypeOf(Limiter)).call(this));
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_this._mutex = new Mutex(options.concurrent || 1, options.max_queue || 0);
_this._throttle = new Throttle(options.rate || 1, options.period_ms || 1000, options.burst || 0);
return _this;
}
_classCallCheck(this, Limiter);
_createClass(Limiter, [{
key: 'sync',
value: function sync(as, step, onerror) {
var _this2 = this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Limiter).call(this));
_this._mutex = new Mutex(options.concurrent || 1, options.max_queue || 0);
_this._throttle = new Throttle(options.rate || 1, options.period_ms || 1000, options.burst || 0);
return _this;
}
as.sync(this._mutex, function (as) {
as._root._next_args = as._call_args;
as.sync(_this2._throttle, step, onerror);
});
}
}]);
_createClass(Limiter, [{
key: "sync",
value: function sync(as, step, onerror) {
var _this2 = this;
return Limiter;
as.sync(this._mutex, function (as) {
as._root._next_args = as._call_args;
as.sync(_this2._throttle, step, onerror);
});
}
}]);
return Limiter;
}(ISync);

@@ -80,0 +94,0 @@

'use strict';
/**

@@ -24,10 +23,20 @@ * @file

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ISync = require('./ISync');

@@ -39,19 +48,20 @@

var mtx_sync = function mtx_sync(asp, mtx, step, on_error) {
var root = asp._root;
var release_step = function release_step(asi) {
mtx._release(root);
root._handle_success(asi._call_args);
};
var root = asp._root;
asp._on_cancel = mtx._release_handler;
asp._queue = [[function (asi) {
if (mtx._lock(asp, root)) {
root._handle_success(asp._call_args);
} else {
asi.waitExternal();
asi._call_args = asp._call_args;
}
}, undefined], [step, on_error], [release_step, undefined]];
var release_step = function release_step(asi) {
mtx._release(root);
root._handle_success(asi._call_args);
};
asp._on_cancel = mtx._release_handler;
asp._queue = [[function (asi) {
if (mtx._lock(asp, root)) {
root._handle_success(asp._call_args);
} else {
asi.waitExternal();
asi._call_args = asp._call_args;
}
}, undefined], [step, on_error], [release_step, undefined]];
};
/**

@@ -61,101 +71,109 @@ * Mutual exclusion mechanism for AsyncSteps

var Mutex = function (_ISync) {
_inherits(Mutex, _ISync);
/**
* C-tor
* @param {integer} [max=1] - maximum number of simultaneous critical section entries
* @param {integer} [max_queue=null] - limit queue length, if set
*/
function Mutex() {
var max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var max_queue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var Mutex =
/*#__PURE__*/
function (_ISync) {
_inherits(Mutex, _ISync);
_classCallCheck(this, Mutex);
/**
* C-tor
* @param {integer} [max=1] - maximum number of simultaneous critical section entries
* @param {integer} [max_queue=null] - limit queue length, if set
*/
function Mutex() {
var _this;
var _this = _possibleConstructorReturn(this, (Mutex.__proto__ || Object.getPrototypeOf(Mutex)).call(this));
var max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var max_queue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
_this._max = max;
_this._locked = 0;
_this._owners = new WeakMap();
_this._queue = [];
_this._max_queue = max_queue;
_this._release_handler = function (asi) {
_this._release(asi._root);
};
return _this;
}
_classCallCheck(this, Mutex);
_createClass(Mutex, [{
key: '_lock',
value: function _lock(asi, root) {
var owners = this._owners;
var owned = owners.get(root);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Mutex).call(this));
_this._max = max;
_this._locked = 0;
_this._owners = new WeakMap();
_this._queue = [];
_this._max_queue = max_queue;
if (owned) {
owners.set(root, owned + 1);
return true;
} else if (this._locked >= this._max) {
var queue = this._queue;
var max_queue = this._max_queue;
_this._release_handler = function (asi) {
_this._release(asi._root);
};
if (max_queue !== null && queue.length >= max_queue) {
root.error(DefenseRejected, 'Mutex queue limit');
}
return _this;
}
queue.push(asi);
return false;
} else {
this._locked += 1;
owners.set(root, 1);
return true;
}
_createClass(Mutex, [{
key: "_lock",
value: function _lock(asi, root) {
var owners = this._owners;
var owned = owners.get(root);
if (owned) {
owners.set(root, owned + 1);
return true;
} else if (this._locked >= this._max) {
var queue = this._queue;
var max_queue = this._max_queue;
if (max_queue !== null && queue.length >= max_queue) {
root.error(DefenseRejected, 'Mutex queue limit');
}
}, {
key: '_release',
value: function _release(root) {
var owners = this._owners;
var owned = owners.get(root);
if (owned) {
if (owned > 1) {
owners.set(root, owned - 1);
return;
}
queue.push(asi);
return false;
} else {
this._locked += 1;
owners.set(root, 1);
return true;
}
}
}, {
key: "_release",
value: function _release(root) {
var owners = this._owners;
var owned = owners.get(root);
owners.delete(root);
if (owned) {
if (owned > 1) {
owners.set(root, owned - 1);
return;
}
this._locked -= 1;
var queue = this._queue;
owners.delete(root);
this._locked -= 1;
var queue = this._queue;
while (queue.length) {
var other_as = queue.shift();
while (queue.length) {
var other_as = queue.shift();
if (other_as.state) {
var other_root = other_as._root;
this._lock(other_as, other_root);
other_root._handle_success(other_as._call_args);
break;
}
}
} else {
var idx = this._queue.indexOf(root);
if (other_as.state) {
var other_root = other_as._root;
if (idx >= 0) {
this._queue.splice(idx, 1);
}
}
this._lock(other_as, other_root);
other_root._handle_success(other_as._call_args);
break;
}
}
}, {
key: 'sync',
value: function sync(as, step, onerror) {
var _this2 = this;
} else {
var idx = this._queue.indexOf(root);
as.add(function (as) {
mtx_sync(as, _this2, step, onerror);
});
if (idx >= 0) {
this._queue.splice(idx, 1);
}
}]);
}
}
}, {
key: "sync",
value: function sync(as, step, onerror) {
var _this2 = this;
return Mutex;
as.add(function (as) {
mtx_sync(as, _this2, step, onerror);
});
}
}]);
return Mutex;
}(ISync);

@@ -162,0 +180,0 @@

@@ -1,30 +0,25 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var chai = require('chai'); //
//
var $as = typeof window !== 'undefined' ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var assert = chai.assert,
expect = chai.expect;
var ISync = $as.ISync;
var $as_test = $as.testcase;
describe('ISync', function () {
it('should throw default errors', $as_test(function (as) {
var is = new ISync();
as.sync(is, function (as, err) {
return as.error('MyError');
});
}, function (as, err) {
if (err === 'NotImplemented') {
as.success();
}
}));
it('should throw default errors', $as_test(function (as) {
var is = new ISync();
as.sync(is, function (as, err) {
return as.error('MyError');
});
}, function (as, err) {
if (err === 'NotImplemented') {
as.success();
}
}));
});
//# sourceMappingURL=isynctest.js.map

@@ -1,12 +0,9 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var chai = require('chai'); //
//
var $as = typeof window !== 'undefined' ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var assert = chai.assert,

@@ -24,132 +21,119 @@ expect = chai.expect;

describe('Limiter', function () {
it('should have correct defaults', function () {
var lim = new Limiter();
it('should have correct defaults', function () {
var lim = new Limiter();
expect(lim._mutex._max).to.equal(1);
expect(lim._mutex._max_queue).to.equal(0);
expect(lim._throttle._max).to.equal(1);
expect(lim._throttle._period_ms).to.equal(1e3);
expect(lim._throttle._max_queue).to.equal(0);
});
it('should have correct defaults', function () {
var lim = new Limiter({
concurrent: 12,
max_queue: 23,
rate: 34,
period_ms: 1234,
burst: 45
});
expect(lim._mutex._max).to.equal(12);
expect(lim._mutex._max_queue).to.equal(23);
expect(lim._throttle._max).to.equal(34);
expect(lim._throttle._period_ms).to.equal(1234);
expect(lim._throttle._max_queue).to.equal(45);
});
it('should handle limits', function (done) {
if (typeof window !== 'undefined') {
// Quite lags in browser
done();
return;
}
expect(lim._mutex._max).to.equal(1);
expect(lim._mutex._max_queue).to.equal(0);
expect(lim._throttle._max).to.equal(1);
expect(lim._throttle._period_ms).to.equal(1e3);
expect(lim._throttle._max_queue).to.equal(0);
var lim = new Limiter({
concurrent: 20,
max_queue: 77,
rate: 5,
period_ms: 100,
burst: 12
});
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
var rejected = 0;
it('should have correct defaults', function () {
var lim = new Limiter({
concurrent: 12,
max_queue: 23,
rate: 34,
period_ms: 1234,
burst: 45
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(lim, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
expect(lim._mutex._max).to.equal(12);
expect(lim._mutex._max_queue).to.equal(23);
expect(lim._throttle._max).to.equal(34);
expect(lim._throttle._period_ms).to.equal(1234);
expect(lim._throttle._max_queue).to.equal(45);
as.execute();
setTimeout(function () {
expect(passed).to.equal(5);
expect(rejected).to.equal(83);
}, 75);
setTimeout(function () {
expect(passed).to.equal(10);
expect(rejected).to.equal(83);
}, 150);
setTimeout(function () {
expect(passed).to.equal(5 + 12);
expect(rejected).to.equal(83);
as.cancel();
done();
}, 350);
});
it('should handle re-entrancy & success params', function (done) {
var lim = new Limiter({
concurrent: 1,
max_queue: 77,
rate: 5,
period_ms: 100,
burst: 12
});
it('should handle limits', function (done) {
if (typeof window !== 'undefined') {
// Quite lags in browser
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(lim, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(lim, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
return;
}
} else {
done('Fail');
}
});
as.execute();
};
var lim = new Limiter({
concurrent: 20,
max_queue: 77,
rate: 5,
period_ms: 100,
burst: 12
});
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
var rejected = 0;
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(lim, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.execute();
setTimeout(function () {
expect(passed).to.equal(5);
expect(rejected).to.equal(83);
}, 75);
setTimeout(function () {
expect(passed).to.equal(10);
expect(rejected).to.equal(83);
}, 150);
setTimeout(function () {
expect(passed).to.equal(5 + 12);
expect(rejected).to.equal(83);
as.cancel();
done();
}, 350);
});
it('should handle re-entrancy & success params', function (done) {
var lim = new Limiter({
concurrent: 1,
max_queue: 77,
rate: 5,
period_ms: 100,
burst: 12
});
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(lim, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(lim, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
}
} else {
done('Fail');
}
});
as.execute();
};
for (var i = 0; i < 2; ++i) {
_loop(i);
}
});
for (var i = 0; i < 2; ++i) {
_loop(i);
}
});
});
//# sourceMappingURL=limitertest.js.map

@@ -1,250 +0,228 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var chai = require('chai'); //
//
var $as = typeof window !== 'undefined' ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var assert = chai.assert,
expect = chai.expect;
var Mutex = $as.Mutex;
describe('Mutex', function () {
it('should handle re-entrancy & success params', function (done) {
var mtx = new Mutex();
it('should handle re-entrancy & success params', function (done) {
var mtx = new Mutex();
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(mtx, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(mtx, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
}
} else {
done(as.state.last_exception || 'Fail');
}
});
as.execute();
};
for (var i = 0; i < 2; ++i) {
_loop(i);
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(mtx, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(mtx, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
}
} else {
done(as.state.last_exception || 'Fail');
}
});
});
as.execute();
};
it('should correctly handle concurrency limit', function (done) {
var limit = 3;
var mtx = new Mutex(limit);
var curr = 0;
var max = 0;
for (var i = 0; i < 2; ++i) {
_loop(i);
}
});
it('should correctly handle concurrency limit', function (done) {
var limit = 3;
var mtx = new Mutex(limit);
var curr = 0;
var max = 0;
for (var i = limit * 3; i >= 0; --i) {
var as = $as();
as.sync(mtx, function (as) {
curr += 1;
max = max < curr ? curr : max;
for (var i = limit * 3; i >= 0; --i) {
var as = $as();
as.sync(mtx, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
// break burst execution
as.waitExternal();
setTimeout(function () {
curr -= 1;
as.state && as.success();
}, 0);
});
});
as.add(function (as) {
// break burst execution
as.waitExternal();
setTimeout(function () {
curr -= 1;
as.state && as.success();
}, 0);
});
});
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(limit);
done();
} catch (e) {
done(e);
}
});
}
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(limit);
done();
} catch (e) {
done(e);
}
});
}
as.execute();
}
});
it('should handle cancel', function (done) {
var mtx = new Mutex();
var as1 = $as();
as1.add(function (as) {
as.sync(mtx, function (as) {
as.waitExternal();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
$as().add(function (as) {
as.setTimeout(10);
as.sync(mtx, function (as) {
as.waitExternal();
});
}, function (as, err) {
if (err === 'Timeout') {
as1.cancel();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.sync(mtx, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle errors', function (done) {
var mtx = new Mutex();
var as1 = $as();
var as1p;
as1.add(function (as) {
as.sync(mtx, function (as) {
as.waitExternal();
as1p = as;
});
}, function (as, err) {
if (err === 'OK') {
as.success();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.loop(function (as) {
if (as1p) {
try {
as1p.error('OK');
} catch (e) {// ignore
}
as.execute();
as.break();
}
});
});
as.sync(mtx, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle parallel steps', function (done) {
var mtx = new Mutex();
var curr = 0;
var max = 0;
var as = $as();
var p = as.parallel();
it('should handle cancel', function (done) {
var mtx = new Mutex();
var as1 = $as();
for (var i = 10; i >= 0; --i) {
p.add(function (as) {
as.sync(mtx, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
curr -= 1;
});
});
});
as1.add(function (as) {
as.sync(mtx, function (as) {
as.waitExternal();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(1);
done();
} catch (e) {
done(e);
}
});
}
}
$as().add(function (as) {
as.setTimeout(10);
as.sync(mtx, function (as) {
as.waitExternal();
});
}, function (as, err) {
if (err === 'Timeout') {
as1.cancel();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
as.execute();
});
it('should handle queue limit', function (done) {
var mtx = new Mutex(2, 5);
var curr = 0;
var max = 0;
var total = 0;
var rejected = 0;
var as = $as();
var p = as.parallel();
$as().add(function (as) {
as.sync(mtx, function (as) {
done();
for (var i = 10; i > 0; --i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(mtx, function (as) {
curr += 1;
total += 1;
max = max < curr ? curr : max;
as.add(function (as) {
as.waitExternal();
setTimeout(function () {
return as.state && as.success();
}, 100);
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle errors', function (done) {
var mtx = new Mutex();
var as1 = $as();
var as1p = void 0;
as1.add(function (as) {
as.sync(mtx, function (as) {
as.waitExternal();
as1p = as;
as.add(function (as) {
curr -= 1;
});
});
}, function (as, err) {
if (err === 'OK') {
as.success();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.loop(function (as) {
if (as1p) {
try {
as1p.error('OK');
} catch (e) {
// ignore
}
as.break();
}
});
as.sync(mtx, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle parallel steps', function (done) {
var mtx = new Mutex();
var curr = 0;
var max = 0;
var as = $as();
var p = as.parallel();
for (var i = 10; i >= 0; --i) {
p.add(function (as) {
as.sync(mtx, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
curr -= 1;
});
});
});
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(1);
done();
} catch (e) {
done(e);
}
});
}
}
as.execute();
});
it('should handle queue limit', function (done) {
var mtx = new Mutex(2, 5);
var curr = 0;
var max = 0;
var total = 0;
var rejected = 0;
var as = $as();
var p = as.parallel();
for (var i = 10; i > 0; --i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(mtx, function (as) {
curr += 1;
total += 1;
max = max < curr ? curr : max;
as.add(function (as) {
as.waitExternal();
setTimeout(function () {
return as.state && as.success();
}, 100);
});
as.add(function (as) {
curr -= 1;
});
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.add(function (as) {
try {
expect(max).to.equal(2);
expect(total).to.equal(7);
expect(rejected).to.equal(3);
done();
} catch (e) {
done(e);
}
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.execute();
as.add(function (as) {
try {
expect(max).to.equal(2);
expect(total).to.equal(7);
expect(rejected).to.equal(3);
done();
} catch (e) {
done(e);
}
});
as.execute();
});
});
//# sourceMappingURL=mutextest.js.map
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
var $as = require('../lib/main-full');
var optihelp = require('@futoin/optihelp');

@@ -11,103 +14,117 @@

var await_i = 0;
optihelp('Compare', { test_time: 3 }).test('AsyncSteps', function (done) {
$as().add(function (as) {
++as_i;
as.add(function (as) {
++as_i;
});
}).add(function (as) {
return done();
}).execute();
optihelp('Compare', {
test_time: 10
}).test('AsyncSteps', function (done) {
$as().add(function (as) {
++as_i;
as.add(function (as) {
++as_i;
});
}).add(function (as) {
return done();
}).execute();
}).test('async-await', function (done) {
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2() {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
++await_i;
_context2.next = 3;
return (
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
++await_i;
_context2.next = 3;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
++await_i;
case 1:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
case 1:
case "end":
return _context.stop();
}
}
}, _callee, this);
}))
);
case 3:
case 'end':
return _context2.stop();
}
}
}, _callee2, undefined);
}))().then(done);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}))().then(done);
}).test('as-repeat', function (done) {
$as().repeat(REPEAT_COUNT, function (as, i) {
as_i += i;
}).add(function (as) {
return done();
}).execute();
$as().repeat(REPEAT_COUNT, function (as, i) {
as_i += i;
}).add(function (as) {
return done();
}).execute();
}).test('await-for', function (done) {
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var inner, i;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
inner = function () {
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(i) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
await_i += i;
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee4() {
var inner, i;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
inner =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3(i) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
await_i += i;
case 1:
case 'end':
return _context3.stop();
}
}
}, _callee3, undefined);
}));
case 1:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
return function inner(_x) {
return _ref4.apply(this, arguments);
};
}();
return function inner(_x) {
return _ref4.apply(this, arguments);
};
}();
i = 0;
i = 0;
case 2:
if (!(i < REPEAT_COUNT)) {
_context4.next = 8;
break;
}
case 2:
if (!(i < REPEAT_COUNT)) {
_context4.next = 8;
break;
}
_context4.next = 5;
return inner(i);
_context4.next = 5;
return inner(i);
case 5:
++i;
_context4.next = 2;
break;
case 5:
++i;
_context4.next = 2;
break;
case 8:
case 'end':
return _context4.stop();
}
}
}, _callee4, undefined);
}))().then(done);
case 8:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}))().then(done);
}).start(function () {
console.log('as_i: ' + as_i);
console.log('await_i: ' + await_i);
console.log("as_i: ".concat(as_i));
console.log("await_i: ".concat(await_i));
});
//# sourceMappingURL=opticompare.js.map
'use strict';
var $as = require('../lib/main-full');
var optihelp = require('@futoin/optihelp');
var _require = require('../lib/common'),
THROTTLE = _require.THROTTLE;
THROTTLE = _require.THROTTLE; //---
//---
var test_array = [];

@@ -17,138 +16,142 @@ var test_object = {};

for (var i = 1000; i > 0; --i) {
test_array.push(i);
test_object['key_' + i] = i;
test_map.set('key_' + i, i);
}
test_array.push(i);
test_object["key_".concat(i)] = i;
test_map.set("key_".concat(i), i);
} //---
//---
var Mutex = $as.Mutex,
Limiter = $as.Limiter,
Throttle = $as.Throttle;
var mtx = new Mutex();
var trtl = new Throttle(1);
var lmtr = new Limiter();
optihelp('AsyncSteps', { test_time: 5 }).test('Add step', function () {
$as().add(function (as) {});
optihelp('AsyncSteps', {
test_time: 5
}).test('Add step', function () {
$as().add(function (as) {});
}).test('Add step with error handler', function () {
$as().add(function (as) {}, function (as, err) {});
$as().add(function (as) {}, function (as, err) {});
}).test('Simple execute', function () {
$as().add(function (as) {}).execute();
$as().add(function (as) {}).execute();
}).test('Simple error handling', function () {
$as().add(function (as) {
return as.error('SomeError', 'SomeInfo');
}).execute();
$as().add(function (as) {
return as.error('SomeError', 'SomeInfo');
}).execute();
}).test('Inner add step', function (done) {
$as().add(function (as) {
as.add(function (as) {});
}).add(function (as) {
return done();
}).execute();
$as().add(function (as) {
as.add(function (as) {});
}).add(function (as) {
return done();
}).execute();
}).test('successStep', function (done) {
$as().successStep().add(function (as) {
return done();
}).execute();
$as().successStep().add(function (as) {
return done();
}).execute();
}).test('Inner successStep', function (done) {
$as().add(function (as) {
return as.successStep();
}).add(function (as) {
return done();
}).execute();
$as().add(function (as) {
return as.successStep();
}).add(function (as) {
return done();
}).execute();
}).test('Parallel', function (done) {
var as = $as();
var p = as.parallel();
p.add(function (as) {});
p.add(function (as) {});
var as = $as();
var p = as.parallel();
p.add(function (as) {});
p.add(function (as) {});
as.add(function (as) {
return done();
});
as.execute();
}).test('Simple error recovery', function (done) {
$as().add(function (as) {
return as.error('SomeError', 'SomeInfo');
}, function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
}).test('Complex error recovery', function (done) {
$as().add(function (as) {
as.add(function (as) {
return done();
return as.add(function (as) {
return as.error('SomeError', 'SomeInfo');
});
});
as.execute();
}).test('Simple error recovery', function (done) {
$as().add(function (as) {
return as.error('SomeError', 'SomeInfo');
}, function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
}).test('Complex error recovery', function (done) {
$as().add(function (as) {
as.add(function (as) {
return as.add(function (as) {
return as.error('SomeError', 'SomeInfo');
});
});
}, function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
}, function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
}).test('Simple cancel', function () {
$as().add(function (as) {}).add(function (as) {}).execute().cancel();
$as().add(function (as) {}).add(function (as) {}).execute().cancel();
}).test('Single repeat loop', function (done) {
$as().repeat(1, function (as, i) {}).add(function (as) {
return done();
}).execute();
$as().repeat(1, function (as, i) {}).add(function (as) {
return done();
}).execute();
}).test('1000 repeat loop', function (done) {
$as().repeat(1000, function (as, i) {}).add(function (as) {
return done();
}).execute();
$as().repeat(1000, function (as, i) {}).add(function (as) {
return done();
}).execute();
}).test('forEach Array', function (done) {
$as().forEach(test_array, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
$as().forEach(test_array, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
}).test('forEach Object', function (done) {
$as().forEach(test_object, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
$as().forEach(test_object, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
}).test('forEach Map', function (done) {
$as().forEach(test_map, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
$as().forEach(test_map, function (as, k, v) {}).add(function (as) {
return done();
}).execute();
}).test('await resolved', function (done) {
$as().await(Promise.resolve(true)).add(function (as) {
return done();
}).execute();
$as().await(Promise.resolve(true)).add(function (as) {
return done();
}).execute();
}).test('await rejected', function (done) {
$as().await(Promise.reject('Fail'), function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
$as().await(Promise.reject('Fail'), function (as, err) {
return as.success();
}).add(function (as) {
return done();
}).execute();
}).test('await deferred', function (done) {
$as().await(new Promise(function (resolve, _) {
return resolve(true);
})).add(function (as) {
return done();
}).execute();
$as().await(new Promise(function (resolve, _) {
return resolve(true);
})).add(function (as) {
return done();
}).execute();
}).test('sync Mutex', function (done) {
$as().sync(mtx, function (as) {}).add(function (as) {
return done();
}).execute();
}).test('sync Mutex blocking', function (done) {
$as().sync(mtx, function (as) {
$as().sync(mtx, function (as) {}).add(function (as) {
return done();
return done();
}).execute();
}).test('sync Mutex blocking', function (done) {
$as().sync(mtx, function (as) {
$as().sync(mtx, function (as) {}).add(function (as) {
return done();
}).execute();
}).execute();
}).execute();
}).test('sync Throttle', function (done) {
trtl._resetPeriod();
trtl._resetPeriod();
$as().sync(trtl, function (as) {}).add(function (as) {
return done();
}).execute();
}).test('sync Throttle blocking', function (done) {
trtl._resetPeriod();
$as().sync(trtl, function (as) {
$as().sync(trtl, function (as) {}).add(function (as) {
return done();
return done();
}).execute();
}).test('sync Throttle blocking', function (done) {
trtl._resetPeriod();
$as().sync(trtl, function (as) {
$as().sync(trtl, function (as) {}).add(function (as) {
return done();
}).execute();
trtl._resetPeriod();
}).execute();
}).execute();
}).test('sync Limiter', function (done) {
lmtr._throttle._resetPeriod();
$as().sync(lmtr, function (as) {}).add(function (as) {
return done();
}).execute();
lmtr._throttle._resetPeriod();
$as().sync(lmtr, function (as) {}).add(function (as) {
return done();
}).execute();
}).start();
//# sourceMappingURL=optihelp.js.map

@@ -1,72 +0,61 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var chai = require('chai'); //
//
var $as = typeof window !== 'undefined' ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var assert = chai.assert,
expect = chai.expect;
var $as_test = $as.testcase;
describe('$as_test', function () {
it('should handle possitive test', $as_test(function (as) {}));
it('should handle negative test', $as_test(function (as) {
as.error('MyError');
it('should handle possitive test', $as_test(function (as) {}));
it('should handle negative test', $as_test(function (as) {
as.error('MyError');
}, function (as, err) {
if (err === 'MyError') {
as.success();
}
}));
it('should handle failure', function (done) {
$as_test(function (as) {
as.error('MyError');
})(function (err) {
try {
expect(err.message).to.equal('MyError');
done();
} catch (err) {
done(err);
}
});
});
it('should handle failure without exception', function (done) {
$as_test(function (as) {
as.error('MyError');
}, function (as, err) {
if (err === 'MyError') {
as.success();
}
}));
it('should handle failure', function (done) {
$as_test(function (as) {
as.error('MyError');
})(function (err) {
try {
expect(err.message).to.equal('MyError');
done();
} catch (err) {
done(err);
}
});
delete as.state.last_exception;
})(function (err) {
try {
expect(err.message).to.equal('Generic Fail');
done();
} catch (err) {
done(err);
}
});
it('should handle failure without exception', function (done) {
$as_test(function (as) {
as.error('MyError');
}, function (as, err) {
delete as.state.last_exception;
})(function (err) {
try {
expect(err.message).to.equal('Generic Fail');
done();
} catch (err) {
done(err);
}
});
});
it('should pass Mocha this', $as_test(function (as) {
this.timeout(1e3); // calls Mocha
}));
it('should force failure on negative test', function (done) {
$as_test(function (as) {}, function (as, err) {})(function (err) {
try {
expect(err.message).to.equal('NegativeTestMustThrow');
done();
} catch (err) {
done(err);
}
});
it('should pass Mocha this', $as_test(function (as) {
this.timeout(1e3); // calls Mocha
}));
it('should force failure on negative test', function (done) {
$as_test(function (as) {}, function (as, err) {})(function (err) {
try {
expect(err.message).to.equal('NegativeTestMustThrow');
done();
} catch (err) {
done(err);
}
});
});
});
});
//# sourceMappingURL=tctest.js.map

@@ -1,12 +0,9 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var chai = require('chai'); //
//
var $as = typeof window !== 'undefined' ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var assert = chai.assert,

@@ -20,326 +17,304 @@ expect = chai.expect;

describe('Throttle', function () {
it('should handle re-entrancy & success params', function (done) {
var thrtl = new Throttle(2, 10);
it('should handle re-entrancy & success params', function (done) {
var thrtl = new Throttle(2, 10);
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(thrtl, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(thrtl, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
}
} else {
done('Fail');
}
});
as.execute();
};
for (var i = 0; i < 2; ++i) {
_loop(i);
var _loop = function _loop(i) {
var as = $as();
as.add(function (as) {
return as.success('MyArgs');
});
as.sync(thrtl, function (as, arg) {
expect(arg).to.equal('MyArgs');
as.sync(thrtl, function (as) {
return as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
}, function (as, err) {
as.success(err);
});
as.add(function (as, err) {
if (err === 'OK') {
if (i) {
done();
}
} else {
done('Fail');
}
});
});
as.execute();
};
it('should correctly handle concurrency limit', function (done) {
var limit = 3;
var thrtl = new Throttle(limit, 100);
var curr = 0;
var max = 0;
for (var i = 0; i < 2; ++i) {
_loop(i);
}
});
it('should correctly handle concurrency limit', function (done) {
var limit = 3;
var thrtl = new Throttle(limit, 100);
var curr = 0;
var max = 0;
for (var i = limit * 3; i >= 0; --i) {
var as = $as();
as.sync(thrtl, function (as) {
curr += 1;
max = max < curr ? curr : max;
for (var i = limit * 3; i >= 0; --i) {
var as = $as();
as.sync(thrtl, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
// break burst execution
as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
curr -= 1;
as.success();
}, 0);
});
});
as.add(function (as) {
// break burst execution
as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
curr -= 1;
as.success();
}, 0);
});
});
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(limit);
done();
} catch (e) {
done(e);
}
});
}
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(limit);
done();
} catch (e) {
done(e);
}
});
}
as.execute();
}
});
it('should handle cancel', function (done) {
var thrtl = new Throttle(1, 20);
var as1 = $as();
as1.add(function (as) {
as.sync(thrtl, function (as) {
as.waitExternal();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
$as().add(function (as) {
as.setTimeout(10);
as.sync(thrtl, function (as) {
as.waitExternal();
});
}, function (as, err) {
if (err === 'Timeout') {
as1.cancel();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.sync(thrtl, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle errors', function (done) {
var thrtl = new Throttle(1, 10);
var as1 = $as();
var as1p;
as1.add(function (as) {
as.sync(thrtl, function (as) {
as.waitExternal();
as1p = as;
});
}, function (as, err) {
if (err === 'OK') {
as.success();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.loop(function (as) {
if (as1p) {
try {
as1p.error('OK');
} catch (e) {// ignore
}
as.execute();
as.break();
}
});
});
as.sync(thrtl, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle parallel steps', function (done) {
var thrtl = new Throttle(1, 10);
var curr = 0;
var max = 0;
var as = $as();
var p = as.parallel();
it('should handle cancel', function (done) {
var thrtl = new Throttle(1, 20);
var as1 = $as();
for (var i = 3; i >= 0; --i) {
p.add(function (as) {
as.sync(thrtl, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
curr -= 1;
});
});
});
as1.add(function (as) {
as.sync(thrtl, function (as) {
as.waitExternal();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(1);
done();
} catch (e) {
done(e);
}
});
}
}
$as().add(function (as) {
as.setTimeout(10);
as.sync(thrtl, function (as) {
as.waitExternal();
});
}, function (as, err) {
if (err === 'Timeout') {
as1.cancel();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.sync(thrtl, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
as.execute();
});
it('should have correct average throughput', function (done) {
var thrtl = new Throttle(10, 100);
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
it('should handle errors', function (done) {
var thrtl = new Throttle(1, 10);
var as1 = $as();
var as1p = void 0;
as1.add(function (as) {
as.sync(thrtl, function (as) {
as.waitExternal();
as1p = as;
});
}, function (as, err) {
if (err === 'OK') {
as.success();
} else {
done(as.state.last_exception || 'Fail');
}
}).execute();
$as().add(function (as) {
as.loop(function (as) {
if (as1p) {
try {
as1p.error('OK');
} catch (e) {
// ignore
}
as.break();
}
});
as.sync(thrtl, function (as) {
done();
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
}).execute();
});
it('should handle parallel steps', function (done) {
var thrtl = new Throttle(1, 10);
var curr = 0;
var max = 0;
var as = $as();
var p = as.parallel();
for (var i = 3; i >= 0; --i) {
p.add(function (as) {
as.sync(thrtl, function (as) {
curr += 1;
max = max < curr ? curr : max;
as.add(function (as) {
curr -= 1;
});
});
});
if (i === 0) {
as.add(function (as) {
try {
expect(max).to.equal(1);
done();
} catch (e) {
done(e);
}
});
}
}
as.execute();
});
it('should have correct average throughput', function (done) {
var thrtl = new Throttle(10, 100);
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.sync(thrtl, function (as) {
// break burst execution
as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
passed += 1;
as.success();
}, 0);
});
var passed = 0;
});
}
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.sync(thrtl, function (as) {
// break burst execution
as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
passed += 1;
as.success();
}, 0);
});
});
}
as.execute();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(50);
as.cancel();
done();
}, 450);
as.execute();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(50);
as.cancel();
done();
}, 450);
});
it('should handle queue limit', function (done) {
var thrtl = new Throttle(10, 100, 33);
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
var rejected = 0;
it('should handle queue limit', function (done) {
var thrtl = new Throttle(10, 100, 33);
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
var passed = 0;
var rejected = 0;
});
}
for (var i = 0; i < 100; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.execute();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(43);
expect(rejected).to.equal(57);
as.cancel();
done();
}, 450);
});
it('should must stop and resume reset timer', function (done) {
var thrtl = new Throttle(2, 50, 10);
$as().add(function (outer_as) {
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
var rejected = 0;
as.execute();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(43);
expect(rejected).to.equal(57);
as.cancel();
done();
}, 450);
});
it('should must stop and resume reset timer', function (done) {
var thrtl = new Throttle(2, 50, 10);
$as().add(function (outer_as) {
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
for (var i = 0; i < 3; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
var passed = 0;
var rejected = 0;
for (var i = 0; i < 3; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.execute();
as.execute();
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(3);
expect(rejected).to.equal(0);
as.cancel();
outer_as.success();
}, 75);
}).add(function (outer_as) {
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(thrtl._timer).to.be.null;
outer_as.success();
}, 100);
}).add(function (outer_as) {
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
});
var passed = 0;
var rejected = 0;
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(3);
expect(rejected).to.equal(0);
as.cancel();
outer_as.success();
}, 75);
}).add(function (outer_as) {
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(thrtl._timer).to.be.null;
outer_as.success();
}, 100);
}).add(function (outer_as) {
var as = $as();
var p = as.parallel(function (as, err) {
done(as.state.last_exception || err || 'Fail');
for (var i = 0; i < 3; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
var passed = 0;
var rejected = 0;
for (var i = 0; i < 3; ++i) {
p.add(function (as) {
as.add(function (as) {
return as.sync(thrtl, function (as) {
passed += 1;
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}, function (as, err) {
if (err === 'DefenseRejected') {
rejected += 1;
as.success();
}
});
});
}
as.execute();
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(3);
expect(rejected).to.equal(0);
as.cancel();
outer_as.success();
}, 75);
}).add(function (as) {
return done();
}).execute();
});
as.execute();
outer_as.waitExternal();
$as.ActiveAsyncTool.callLater(function () {
expect(passed).to.equal(3);
expect(rejected).to.equal(0);
as.cancel();
outer_as.success();
}, 75);
}).add(function (as) {
return done();
}).execute();
});
});
//# sourceMappingURL=throttletest.js.map

@@ -1,15 +0,13 @@

'use strict';
'use strict'; // ensure it works with frozen one
// ensure it works with frozen one
Object.freeze(Object.prototype);
var chai = require('chai');
var performance_now = require("performance-now");
//
var performance_now = require("performance-now"); //
var in_browser = typeof window !== 'undefined';
var async_steps = in_browser ? require('futoin-asyncsteps') : module.require('../lib/main-full');
var production_mode = async_steps.isProduction;
var assert = chai.assert,

@@ -22,1846 +20,1620 @@ expect = chai.expect;

describe('AsyncTool', function () {
describe('#callLater()', function () {
it("should call later", function (done) {
async_steps.AsyncTool.callLater(done);
});
it("should call later timeout", function (done) {
var t = performance_now() * 1e3;
async_steps.AsyncTool.callLater(function () {
var s = performance_now() * 1e3;
expect(s).be.greaterThan(t + 9);
done();
}, 10);
});
describe('#callLater()', function () {
it("should call later", function (done) {
async_steps.AsyncTool.callLater(done);
});
describe('#cancelCall()', function () {
it("should cancel call", function (done) {
var h = async_steps.AsyncTool.callLater(done);
async_steps.AsyncTool.cancelCall(h);
done();
});
it("should cancel call timeout", function (done) {
var h = async_steps.AsyncTool.callLater(done, 100);
async_steps.AsyncTool.cancelCall(h);
done();
});
it("should call later timeout", function (done) {
var t = performance_now() * 1e3;
async_steps.AsyncTool.callLater(function () {
var s = performance_now() * 1e3;
expect(s).be.greaterThan(t + 9);
done();
}, 10);
});
});
describe('#cancelCall()', function () {
it("should cancel call", function (done) {
var h = async_steps.AsyncTool.callLater(done);
async_steps.AsyncTool.cancelCall(h);
done();
});
it("should cancel call timeout", function (done) {
var h = async_steps.AsyncTool.callLater(done, 100);
async_steps.AsyncTool.cancelCall(h);
done();
});
});
});
describe('AsyncToolTest', function () {
describe('#callLater()', function () {
it("should call later", function (done) {
async_steps.AsyncToolTest.callLater(done);
async_steps.AsyncToolTest.nextEvent();
});
it("should call later timeout", function (done) {
async_steps.AsyncToolTest.callLater(function () {
done();
}, 100);
async_steps.AsyncToolTest.run();
});
it('should insert event', function () {
var f = function f(as) {};
async_steps.AsyncToolTest.callLater(function () {}, 100);
async_steps.AsyncToolTest.callLater(f, 10);
assert.equal(async_steps.AsyncToolTest.getEvents()[0].f, f);
async_steps.AsyncToolTest.resetEvents();
expect(async_steps.AsyncToolTest.getEvents().length).equal(0);
});
describe('#callLater()', function () {
it("should call later", function (done) {
async_steps.AsyncToolTest.callLater(done);
async_steps.AsyncToolTest.nextEvent();
});
describe('#cancelCall()', function () {
it("should cancel call", function (done) {
var h = async_steps.AsyncToolTest.callLater(done);
expect(async_steps.AsyncToolTest.hasEvents()).be.true;
async_steps.AsyncToolTest.cancelCall(h);
expect(async_steps.AsyncToolTest.hasEvents()).be.false;
done();
});
it("should cancel call timeout", function (done) {
var h = async_steps.AsyncToolTest.callLater(done, 100);
expect(async_steps.AsyncToolTest.hasEvents()).be.true;
async_steps.AsyncToolTest.cancelCall(h);
expect(async_steps.AsyncToolTest.hasEvents()).be.false;
done();
});
it("should call later timeout", function (done) {
async_steps.AsyncToolTest.callLater(function () {
done();
}, 100);
async_steps.AsyncToolTest.run();
});
});
it('should insert event', function () {
var f = function f(as) {};
describe('AsyncSteps', function () {
before(function () {
async_steps.installAsyncToolTest();
async_steps.AsyncToolTest.callLater(function () {}, 100);
async_steps.AsyncToolTest.callLater(f, 10);
assert.equal(async_steps.AsyncToolTest.getEvents()[0].f, f);
async_steps.AsyncToolTest.resetEvents();
expect(async_steps.AsyncToolTest.getEvents().length).equal(0);
});
after(function () {
async_steps.installAsyncToolTest(false);
});
describe('#cancelCall()', function () {
it("should cancel call", function (done) {
var h = async_steps.AsyncToolTest.callLater(done);
expect(async_steps.AsyncToolTest.hasEvents()).be.true;
async_steps.AsyncToolTest.cancelCall(h);
expect(async_steps.AsyncToolTest.hasEvents()).be.false;
done();
});
beforeEach(function (done) {
this.as = async_steps();
// reset burst counter
try {
async_steps.AsyncToolTest.resetEvents();
async_steps().add(break_burst).add(function (as) {
return done();
}).execute();
async_steps.AsyncToolTest.run();
} catch (e) {
console.log(e);
}
it("should cancel call timeout", function (done) {
var h = async_steps.AsyncToolTest.callLater(done, 100);
expect(async_steps.AsyncToolTest.hasEvents()).be.true;
async_steps.AsyncToolTest.cancelCall(h);
expect(async_steps.AsyncToolTest.hasEvents()).be.false;
done();
});
});
});
describe('AsyncSteps', function () {
before(function () {
async_steps.installAsyncToolTest();
});
after(function () {
async_steps.installAsyncToolTest(false);
});
beforeEach(function (done) {
this.as = async_steps(); // reset burst counter
function assertNoEvents() {
expect(async_steps.AsyncToolTest.getEvents().length).equal(0);
try {
async_steps.AsyncToolTest.resetEvents();
async_steps().add(break_burst).add(function (as) {
return done();
}).execute();
async_steps.AsyncToolTest.run();
} catch (e) {
console.log(e);
}
});
function assertHasEvents() {
expect(async_steps.AsyncToolTest.getEvents().length).be.above(0);
}
function assertNoEvents() {
expect(async_steps.AsyncToolTest.getEvents().length).equal(0);
}
var break_burst = function break_burst(as) {
as.waitExternal();
async_steps.AsyncToolTest.callLater(function () {
as.state && as.success();
}, 0);
};
function assertHasEvents() {
expect(async_steps.AsyncToolTest.getEvents().length).be.above(0);
}
describe('#add()', function () {
it("should add steps sequentially", function () {
var as = this.as;
var break_burst = function break_burst(as) {
as.waitExternal();
async_steps.AsyncToolTest.callLater(function () {
as.state && as.success();
}, 0);
};
as.add(function (as) {
as.success();
}, function (as, err) {
as.success();
}).add(function (as) {
as.success();
});
expect(as._queue.length).equal(2);
expect(as._queue[0][0]).be.instanceof(Function);
expect(as._queue[0][1]).be.instanceof(Function);
expect(as._queue[1][0]).be.instanceof(Function);
assert.isUndefined(as._queue[1][1]);
describe('#add()', function () {
it("should add steps sequentially", function () {
var as = this.as;
as.add(function (as) {
as.success();
}, function (as, err) {
as.success();
}).add(function (as) {
as.success();
});
expect(as._queue.length).equal(2);
expect(as._queue[0][0]).be.instanceof(Function);
expect(as._queue[0][1]).be.instanceof(Function);
expect(as._queue[1][0]).be.instanceof(Function);
assert.isUndefined(as._queue[1][1]);
});
it("should call steps and errors in correct order", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.state.order.push('1');
as.add(function (as) {
as.state.order.push('1_1');
as.error("MyError");
}, function (as, err) {
as.state.order.push('1_1e');
expect(err).eql("MyError");
as.success('1_1e');
});
it("should call steps and errors in correct order", function () {
var as = this.as;
as.state.order = [];
as.add(function (as, val) {
as.state.order.push('1_2');
expect(val).eql('1_1e');
as.error("MyError2");
}, function (as, err) {
as.state.order.push('1_2e');
expect(err).eql("MyError2");
as.success('1_2e');
}).add(function (as, val) {
as.state.order.push('1_3');
expect(val).eql('1_2e');
as.success('1_3', 'yes');
}, function (as, err) {
as.state.order.push('1_3e');
expect(err).eql("MyError2");
as.success();
});
}, function (as, err) {
as.state.order.push('1e');
as.success();
}).add(function (as, val1, val2) {
as.state.order.push('2');
expect(val1).eql("1_3");
expect(val2).eql("yes");
as.success();
}).add(function (as) {
as.state.order.push('3');
}, function (as, err) {
as.state.order.push('3e');
expect(err).eql("InternalError");
as.success();
});
as.add(function (as) {
as.state.order.push('4');
as.add(function (as) {
as.state.order.push('4_1');
as.add(function (as) {
as.state.order.push('4_2');
});
});
}, function (as, err) {
as.state.order.push('4e');
expect(err).eql("InternalError");
as.success();
});
as.add(function (as) {
as.state.order.push('5');
as.add(function (as) {
as.state.order.push('5_1');
as.add(function (as) {
as.state.order.push('5_2');
expect(undefined).eql("InternalError");
}, function (as, err) {
as.state.order.push('5_2e');
as.add(function (as) {
as.state.order.push('1');
as.add(function (as) {
as.state.order.push('1_1');
as.error("MyError");
}, function (as, err) {
as.state.order.push('1_1e');
expect(err).eql("MyError");
as.success('1_1e');
});
as.add(function (as, val) {
as.state.order.push('1_2');
expect(val).eql('1_1e');
as.error("MyError2");
}, function (as, err) {
as.state.order.push('1_2e');
expect(err).eql("MyError2");
as.success('1_2e');
}).add(function (as, val) {
as.state.order.push('1_3');
expect(val).eql('1_2e');
as.success('1_3', 'yes');
}, function (as, err) {
as.state.order.push('1_3e');
expect(err).eql("MyError2");
as.success();
});
as.state.order.push('5_3');
expect(err).eql("InternalError");
}, function (as, err) {
as.state.order.push('1e');
as.success();
}).add(function (as, val1, val2) {
as.state.order.push('2');
expect(val1).eql("1_3");
expect(val2).eql("yes");
as.success();
}).add(function (as) {
as.state.order.push('3');
}, function (as, err) {
as.state.order.push('3e');
expect(err).eql("InternalError");
as.success();
as.state.order.push('5_3e');
});
as.add(function (as) {
as.state.order.push('4');
as.add(function (as) {
as.state.order.push('4_1');
as.add(function (as) {
as.state.order.push('4_2');
});
});
}, function (as, err) {
as.state.order.push('4e');
expect(err).eql("InternalError");
as.success();
});
as.add(function (as) {
as.state.order.push('5');
as.add(function (as) {
as.state.order.push('5_1');
as.add(function (as) {
as.state.order.push('5_2');
expect(undefined).eql("InternalError");
}, function (as, err) {
as.state.order.push('5_2e');
as.add(function (as) {
as.state.order.push('5_3');
expect(err).eql("InternalError");
}, function (as, err) {
as.state.order.push('5_3e');
});
});
}, function (as, err) {
as.state.order.push('5_1e');
});
}, function (as, err) {
as.state.order.push('5e');
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '1_1', '1_1e', '1_2', '1_2e', '1_3', '2', '3' /*, '3e'*/
, '4', '4_1', '4_2' /*, '4e'*/
, '5', '5_1', '5_2', '5_2e', '5_3', '5_3e', '5_1e', '5e']);
});
}, function (as, err) {
as.state.order.push('5_1e');
});
if (!production_mode) {
it('should fail on add in execution', function () {
var as = this.as;
as.add(function (as) {
as.waitExternal();
});
as.execute();
assert.throws(function () {
as.add(function (as) {});
}, 'InternalError');
async_steps.AsyncToolTest.run();
});
it('should fail on invalid step func', function () {
var as = this.as;
assert.throws(function () {
as.add(function () {});
}, 'InternalError');
as.add(function (as) {});
as.add(function (as, val) {});
as.cancel();
});
it('should fail on invalid error handler', function () {
var as = this.as;
assert.throws(function () {
as.add(function (as) {}, function () {});
}, 'InternalError');
assert.throws(function () {
as.add(function (as) {}, function (as) {});
}, 'InternalError');
assert.throws(function () {
as.add(function (as) {}, function (as, error, val) {});
}, 'InternalError');
as.add(function (as) {}, function (as, error) {});
as.cancel();
});
}
}, function (as, err) {
as.state.order.push('5e');
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '1_1', '1_1e', '1_2', '1_2e', '1_3', '2', '3'
/*, '3e'*/
, '4', '4_1', '4_2'
/*, '4e'*/
, '5', '5_1', '5_2', '5_2e', '5_3', '5_3e', '5_1e', '5e']);
});
describe('#parallel()', function () {
it("should add steps sequentially", function () {
var as = this.as;
as.parallel(function (as, err) {
as.success();
});
as.parallel();
as.add(function (as) {
as.success();
});
expect(as._queue.length).equal(3);
expect(as._queue[0][0]).be.instanceof(Function);
expect(as._queue[0][1]).be.instanceof(Function);
expect(as._queue[1][0]).be.instanceof(Function);
assert.isUndefined(as._queue[1][1]);
as.execute();
async_steps.AsyncToolTest.run();
if (!production_mode) {
it('should fail on add in execution', function () {
var as = this.as;
as.add(function (as) {
as.waitExternal();
});
it("should run in parallel", function () {
var as = this.as;
as.state.order = [];
as.parallel(function (as, err) {
console.dir(as);
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 6, 7]);
as.execute();
assert.throws(function () {
as.add(function (as) {});
}, 'InternalError');
async_steps.AsyncToolTest.run();
});
it('should fail on invalid step func', function () {
var as = this.as;
assert.throws(function () {
as.add(function () {});
}, 'InternalError');
as.add(function (as) {});
as.add(function (as, val) {});
as.cancel();
});
it('should fail on invalid error handler', function () {
var as = this.as;
assert.throws(function () {
as.add(function (as) {}, function () {});
}, 'InternalError');
assert.throws(function () {
as.add(function (as) {}, function (as) {});
}, 'InternalError');
assert.throws(function () {
as.add(function (as) {}, function (as, error, val) {});
}, 'InternalError');
as.add(function (as) {}, function (as, error) {});
as.cancel();
});
}
});
describe('#parallel()', function () {
it("should add steps sequentially", function () {
var as = this.as;
as.parallel(function (as, err) {
as.success();
});
as.parallel();
as.add(function (as) {
as.success();
});
expect(as._queue.length).equal(3);
expect(as._queue[0][0]).be.instanceof(Function);
expect(as._queue[0][1]).be.instanceof(Function);
expect(as._queue[1][0]).be.instanceof(Function);
assert.isUndefined(as._queue[1][1]);
as.execute();
async_steps.AsyncToolTest.run();
});
it("should run in parallel", function () {
var as = this.as;
as.state.order = [];
as.parallel(function (as, err) {
console.dir(as);
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
it("should run in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
console.dir(err);
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 6, 7]);
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
it("should cancel on error in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
if (err === 'MyError') as.success();
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.error('MyError');
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 7]);
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
it("should cancel on cancel in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
console.dir(err);
if (err === 'MyError') as.success();
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
expect(as.state.order).eql([1, 2, 3]);
// burst
async_steps.AsyncToolTest.nextEvent();
async_steps.AsyncToolTest.nextEvent();
async_steps.AsyncToolTest.nextEvent();
// step 4
async_steps.AsyncToolTest.nextEvent();
as.cancel();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4]);
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 6, 7]);
});
it("should run in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
console.dir(err);
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
it("should not loose error_info (bug #1)", function () {
var as = this.as;
as.add(function (as) {
as.parallel(function (as, err) {
expect(err).equal("MyError");
expect(as.state.error_info).equal("MyInfo");
}).add(function (as) {}).add(function (as) {
as.error("MyError", "MyInfo");
}).add(function (as) {});
});
as.add(function (as) {
expect(false).be.true;
});
as.execute();
async_steps.AsyncToolTest.run();
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 6, 7]);
});
it("should cancel on error in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
if (err === 'MyError') as.success();
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.error('MyError');
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4, 5, 7]);
});
describe('#success()', function () {
it('should work', function () {
var as = this.as;
as.state.second_called = false;
as.add(break_burst, function (as, error) {
expect(error).equal("Does not work");
}).add(function (as) {
as.state.second_called = true;
as.success();
});
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents();
// burst
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
it("should cancel on cancel in parallel (inner)", function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.parallel(function (as, err) {
console.dir(err);
if (err === 'MyError') as.success();
}).add(function (as) {
as.state.order.push(1);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(4);
as.success();
});
}).add(function (as) {
as.state.order.push(2);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(5);
as.success();
});
}).add(function (as) {
as.state.order.push(3);
as.add(break_burst);
as.add(function (as) {
as.state.order.push(6);
as.success();
});
});
});
as.add(function (as) {
as.state.order.push(7);
as.success();
});
as.execute();
expect(as.state.order).eql([1, 2, 3]); // burst
it('should work in onerror', function () {
var as = this.as;
async_steps.AsyncToolTest.nextEvent();
async_steps.AsyncToolTest.nextEvent();
async_steps.AsyncToolTest.nextEvent(); // step 4
as.state.second_called = false;
as.add(function (as) {
as.add(break_burst);
as.add(function (as) {
return as.error(false);
});
}, function (as, error) {
as.success('Value1', 'Value2');
}).add(function (as, val1, val2) {
as.state.second_called = true;
expect(val1).equal('Value1');
expect(val2).equal('Value2');
as.success();
});
async_steps.AsyncToolTest.nextEvent();
as.cancel();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql([1, 2, 3, 4]);
});
it("should not loose error_info (bug #1)", function () {
var as = this.as;
as.add(function (as) {
as.parallel(function (as, err) {
expect(err).equal("MyError");
expect(as.state.error_info).equal("MyInfo");
}).add(function (as) {}).add(function (as) {
as.error("MyError", "MyInfo");
}).add(function (as) {});
});
as.add(function (as) {
expect(false).be.true;
});
as.execute();
async_steps.AsyncToolTest.run();
});
});
describe('#success()', function () {
it('should work', function () {
var as = this.as;
as.state.second_called = false;
as.add(break_burst, function (as, error) {
expect(error).equal("Does not work");
}).add(function (as) {
as.state.second_called = true;
as.success();
});
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents(); // burst
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents();
// burst
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
});
it('should work in onerror', function () {
var as = this.as;
as.state.second_called = false;
as.add(function (as) {
as.add(break_burst);
as.add(function (as) {
return as.error(false);
});
}, function (as, error) {
as.success('Value1', 'Value2');
}).add(function (as, val1, val2) {
as.state.second_called = true;
expect(val1).equal('Value1');
expect(val2).equal('Value2');
as.success();
});
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents(); // burst
it('should work in depth', function () {
var as = this.as;
as.state.second_called = false;
as.add(function (as) {
as.add(function (as) {
as.success();
});
}, function (as, error) {
console.dir(as);
expect(error).equal("Does not work");
});
as.add(break_burst);
as.add(function (as) {
as.state.second_called = true;
as.success();
});
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents();
// burst
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
});
it('should work in depth', function () {
var as = this.as;
as.state.second_called = false;
as.add(function (as) {
as.add(function (as) {
as.success();
});
}, function (as, error) {
console.dir(as);
expect(error).equal("Does not work");
});
as.add(break_burst);
as.add(function (as) {
as.state.second_called = true;
as.success();
});
as.execute();
expect(as.state.second_called).be.false;
assertHasEvents(); // burst
it('should fail on invalid success', function () {
var as = this.as;
assert.throws(function () {
as._handle_success();
}, 'InternalError');
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
});
it('should fail on invalid success', function () {
var as = this.as;
assert.throws(function () {
as._handle_success();
}, 'InternalError');
});
it('should disables timeout', function () {
var as = this.as;
as.add(function (as) {
as.setTimeout(1000);
as.success();
});
as.execute();
assertNoEvents();
});
it('should fail on success with inner steps', function () {
var as = this.as;
as.state.executed = false;
as.add(function (as) {
as.add(function (as) {
as.error('MyError');
});
as.success();
}, function (as, err) {
as.state.executed = true;
expect(err).be.equal('InternalError');
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
});
it('should be possible to make async success', function () {
var as = this.as;
it('should disables timeout', function () {
var as = this.as;
var _this = this;
as.add(function (as) {
as.setTimeout(1000);
as.success();
});
as.execute();
assertNoEvents();
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
as.success();
});
as.waitExternal();
}, function (as, err) {
as.state.myerror = true;
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute(); // async success
it('should fail on success with inner steps', function () {
var as = this.as;
async_steps.AsyncToolTest.nextEvent();
expect(as.state.executed).be.false;
assertHasEvents(); // continue
as.state.executed = false;
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
});
it('should ignore unexpected success', function () {
var as = this.as;
as.add(function (as) {
as.add(function (as) {
as.error('MyError');
});
as.success();
}, function (as, err) {
as.state.executed = true;
expect(err).be.equal('InternalError');
});
var _this = this;
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
var root_as = as;
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
if (production_mode) {
try {
as.success();
throw new Error('Fail');
} catch (e) {
expect(e.message).not.equal('Fail');
}
} else {
assert.throws(function () {
as.success();
}, Error, 'InternalError');
}
});
as.success();
}, function (as, err) {
console.log(err);
as.state.myerror = true;
});
as.add(break_burst);
as.add(function (as) {
as.state.executed = true;
as.success();
}, function (as, err) {
console.dir(err);
});
as.execute();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent(); // burst
it('should be possible to make async success', function () {
var as = this.as;
var _this = this;
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
as.success();
});
as.waitExternal();
}, function (as, err) {
as.state.myerror = true;
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
// async success
async_steps.AsyncToolTest.nextEvent();
expect(as.state.executed).be.false;
assertHasEvents();
// continue
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
async_steps.AsyncToolTest.nextEvent();
expect(as.state.executed).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
});
});
describe('#successStep()', function () {
it('should work', function () {
var as = this.as;
as.state.second_called = false;
as.successStep('a', 'b', 'c');
as.add(function (as, a, b, c) {
expect(a).equal('a');
expect(b).equal('b');
expect(c).equal('c');
as.successStep('abc');
as.add(function (as, abc) {
expect(abc).to.equal('abc');
});
as.add(break_burst);
as.add(function (as) {
return as.successStep();
});
as.successStep(1, 2, 3);
}, function (as, error) {
console.log(as.state.last_exception);
expect(error).equal("Does not work");
}).add(function (as, a, b, c) {
expect([a, b, c]).to.eql([1, 2, 3]);
as.state.second_called = true;
as.success();
});
as.successStep();
as.execute(); // first step + burst break;
it('should ignore unexpected success', function () {
var as = this.as;
var _this = this;
var root_as = as;
expect(as.state.second_called).be.false;
assertHasEvents(); // burst async complete
as.state.myerror = false;
as.state.executed = false;
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
expect(as.state.second_called).be.false; // continue to end
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
if (production_mode) {
try {
as.success();
throw new Error('Fail');
} catch (e) {
expect(e.message).not.equal('Fail');
}
} else {
assert.throws(function () {
as.success();
}, Error, 'InternalError');
}
});
as.success();
}, function (as, err) {
console.log(err);
as.state.myerror = true;
});
as.add(break_burst);
as.add(function (as) {
as.state.executed = true;
as.success();
}, function (as, err) {
console.dir(err);
});
as.execute();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
// burst
async_steps.AsyncToolTest.nextEvent();
expect(as.state.executed).be.false;
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
});
});
describe('#error()', function () {
it('should throw error', function () {
var as = this.as;
assert.isUndefined(as.state.error_info);
assert.throws(function () {
as.error("MyError");
}, Error, "MyError");
assert.isUndefined(as.state.error_info);
assert.throws(function () {
as.error("MyError", 'My Info');
}, Error, "MyError");
expect(as.state.error_info).equal('My Info');
});
it('should be possible to change error code', function () {
var as = this.as;
as.add(function (as) {
as.add(function (as) {
as.error('Orig');
}, function (as, err) {
expect(err).eql('Orig');
as.error('Changed');
});
}, function (as, err) {
expect(err).eql('Changed');
});
as.execute();
async_steps.AsyncToolTest.run();
});
describe('#successStep()', function () {
it('should work', function () {
var as = this.as;
it('should be possible to make async error', function () {
var as = this.as;
as.state.second_called = false;
as.successStep('a', 'b', 'c');
as.add(function (as, a, b, c) {
expect(a).equal('a');
expect(b).equal('b');
expect(c).equal('c');
var _this = this;
as.successStep('abc');
as.add(function (as, abc) {
expect(abc).to.equal('abc');
});
as.add(break_burst);
as.add(function (as) {
return as.successStep();
});
as.successStep(1, 2, 3);
}, function (as, error) {
console.log(as.state.last_exception);
expect(error).equal("Does not work");
}).add(function (as, a, b, c) {
expect([a, b, c]).to.eql([1, 2, 3]);
as.state.second_called = true;
as.success();
});
as.successStep();
as.execute();
// first step + burst break;
expect(as.state.second_called).be.false;
assertHasEvents();
// burst async complete
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
expect(as.state.second_called).be.false;
// continue to end
async_steps.AsyncToolTest.nextEvent();
expect(as.state.second_called).be.true;
assertNoEvents();
as.state.myerror = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
try {
as.error('MyError');
} catch (e) {// pass
}
});
as.waitExternal();
}, function (as, err) {
as.state.myerror = err === 'MyError';
}).add(function (as) {
as.success();
});
as.execute();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.true;
});
describe('#error()', function () {
it('should throw error', function () {
var as = this.as;
it('should be possible to make async error in execute', function () {
var as = this.as;
assert.isUndefined(as.state.error_info);
var _this = this;
assert.throws(function () {
as.error("MyError");
}, Error, "MyError");
var root_as = as;
as.state.myerror = false;
as.state.executed = false;
as.add(break_burst, function (as, err) {
as.state.myerror = err === 'MyError';
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
assert.isUndefined(as.state.error_info);
try {
as.error('MyError');
} catch (e) {// pass
}
assert.throws(function () {
as.error("MyError", 'My Info');
}, Error, "MyError");
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.true;
expect(as.state.executed).be.false;
});
it('should ignore unexpected error', function () {
var as = this.as;
expect(as.state.error_info).equal('My Info');
});
var _this = this;
it('should be possible to change error code', function () {
var as = this.as;
as.add(function (as) {
as.add(function (as) {
as.error('Orig');
}, function (as, err) {
expect(err).eql('Orig');
as.error('Changed');
});
}, function (as, err) {
expect(err).eql('Changed');
});
as.execute();
async_steps.AsyncToolTest.run();
});
it('should be possible to make async error', function () {
var as = this.as;
var _this = this;
as.state.myerror = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
try {
as.error('MyError');
} catch (e) {
// pass
}
});
as.waitExternal();
}, function (as, err) {
as.state.myerror = err === 'MyError';
}).add(function (as) {
as.success();
});
as.execute();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.true;
});
it('should be possible to make async error in execute', function () {
var as = this.as;
var _this = this;
var root_as = as;
as.state.myerror = false;
as.state.executed = false;
as.add(break_burst, function (as, err) {
as.state.myerror = err === 'MyError';
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
var root_as = as;
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
if (production_mode) {
try {
as.error('MyError');
as.error('MyError');
} catch (e) {
// pass
expect(e.message).not.equal('MyError');
}
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.true;
expect(as.state.executed).be.false;
} else {
assert.throws(function () {
as.error('MyError');
}, Error, 'InternalError');
}
});
as.success();
}, function (as, err) {
as.state.myerror = err === 'MyError';
});
as.add(break_burst);
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
});
});
describe('#setTimeout()', function () {
it('should properly timeout, calling cancel', function (done) {
var done_wrap = function done_wrap(order) {
try {
expect(order).eql(['1', '2', '3', '4']);
done();
} catch (e) {
done(e);
}
};
it('should ignore unexpected error', function () {
var as = this.as;
var _this = this;
var root_as = as;
var as = new async_steps.AsyncSteps(null, async_steps.AsyncTool);
as.state.order = [];
as.add(function (as) {
as.state.order.push('1');
as.setTimeout(20);
as.setTimeout(20); // reset
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
async_steps.AsyncToolTest.callLater(function () {
if (production_mode) {
try {
as.error('MyError');
} catch (e) {
expect(e.message).not.equal('MyError');
}
} else {
assert.throws(function () {
as.error('MyError');
}, Error, 'InternalError');
}
});
as.success();
}, function (as, err) {
as.state.myerror = err === 'MyError';
});
as.add(break_burst);
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertHasEvents();
async_steps.AsyncToolTest.nextEvent();
assertNoEvents();
expect(as.state.myerror).be.false;
expect(as.state.executed).be.true;
as.add(function (as) {
as.state.order.push('2');
as.setTimeout(5);
});
as.setCancel(function (as) {
as.state.order.push('3');
});
}, function (as, err) {
as.state.order.push('4');
expect(err).equal('Timeout');
assert.isUndefined(as.state.error_info);
done_wrap(as.state.order);
});
as.execute();
});
describe('#setTimeout()', function () {
it('should properly timeout, calling cancel', function (done) {
var done_wrap = function done_wrap(order) {
try {
expect(order).eql(['1', '2', '3', '4']);
done();
} catch (e) {
done(e);
}
};
var as = new async_steps.AsyncSteps(null, async_steps.AsyncTool);
as.state.order = [];
as.add(function (as) {
as.state.order.push('1');
as.setTimeout(20);
as.setTimeout(20); // reset
as.add(function (as) {
as.state.order.push('2');
as.setTimeout(5);
});
as.setCancel(function (as) {
as.state.order.push('3');
});
}, function (as, err) {
as.state.order.push('4');
expect(err).equal('Timeout');
assert.isUndefined(as.state.error_info);
done_wrap(as.state.order);
});
describe('#setCancel()', function () {
it('should cancel in reverse order silently', function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.state.order.push('1');
as.add(function (as) {
as.state.order.push('2');
as.setCancel(function (as) {
as.state.order.push('2c');
});
as.add(function (as) {
as.state.order.push('3');
as.setCancel(function (as) {
as.state.order.push('3c');
});
as.execute();
});
});
as.setCancel(function (as) {
as.state.order.push('1c');
});
}, function (as, err) {
as.state.order.push('e');
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '2', '3']);
as.cancel();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '2', '3', '3c', '2c', '1c']);
});
describe('#setCancel()', function () {
it('should cancel in reverse order silently', function () {
var as = this.as;
as.state.order = [];
as.add(function (as) {
as.state.order.push('1');
as.add(function (as) {
as.state.order.push('2');
as.setCancel(function (as) {
as.state.order.push('2c');
});
as.add(function (as) {
as.state.order.push('3');
as.setCancel(function (as) {
as.state.order.push('3c');
});
});
});
as.setCancel(function (as) {
as.state.order.push('1c');
});
}, function (as, err) {
as.state.order.push('e');
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '2', '3']);
as.cancel();
async_steps.AsyncToolTest.run();
expect(as.state.order).eql(['1', '2', '3', '3c', '2c', '1c']);
});
describe('#copyFrom()', function () {
beforeEach(function () {
this.as = async_steps();
});
it('should copy steps and state', function () {
var as = this.as;
as.state.old_v = false;
as.state.executed = false;
as.state.parallel1 = false;
as.state.parallel2 = false;
var model_as = async_steps();
model_as.state.new_v = true;
model_as.state.old_v = true;
model_as.add(function (as) {}, function (as, error) {
as.success();
}).add(function (as) {
as.state.executed = true;
as.success();
});
model_as.parallel().add(function (as) {
as.state.parallel1 = true;
as.success();
}).add(function (as) {
as.state.parallel2 = true;
as.success();
});
as.copyFrom(model_as);
expect(as.state).have.property('old_v', false);
expect(as.state).have.property('new_v', true);
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
expect(as.state.parallel1).be.true;
expect(as.state.parallel2).be.true;
as.state.executed = false;
as.state.parallel1 = false;
as.state.parallel2 = false;
as.add(function (as) {
model_as.state.new_v2 = true;
as.copyFrom(model_as);
expect(as.state).have.property('old_v', false);
expect(as.state).have.property('new_v', true);
expect(as.state).have.property('new_v2', true);
var m = async_steps();
as.copyFrom(m);
m.add(function (as) {
as.success();
});
as.copyFrom(m);
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
expect(as.state.parallel1).be.true;
expect(as.state.parallel2).be.true;
});
describe('#copyFrom()', function () {
beforeEach(function () {
this.as = async_steps();
});
describe('#execute()', function () {
it('should silently exit', function () {
var as = this.as;
as.execute();
assertNoEvents();
});
it('should trigger ASP sanity check', function () {
var as = this.as;
as.state.error_code = '';
as.add(function (as) {
var oas = as;
as.add(function (as) {
oas.success();
});
}, function (as, err) {
as.state.error_code = err;
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.error_code).be.equal('InternalError');
expect(as.state.error_info).equal(production_mode ? 'Invalid success() call' : 'Invalid call (sanity check)');
});
it('should implicitly success', function () {
var as = this.as;
as.add(function (as) {
as.state.ok = true;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.ok).be.true;
});
});
describe('#cancel()', function () {
it('should cancel execution', function () {
var as = this.as;
as.add(function (as) {
as.success();
}).add(function (as) {
as.success();
});
as.execute();
as.cancel();
assertNoEvents();
});
it('should cancel timeout', function () {
var as = this.as;
as.add(function (as) {
as.setTimeout(1000);
}).add(function (as) {
as.success();
});
as.execute();
as.cancel();
assertNoEvents();
});
});
describe('#loop()', function () {
it('should complex loop', function () {
var as = this.as;
var i = 0;
var icheck = 1;
var s = [];
as.add(function (as) {
as.loop(function (as) {
s.push('OUTER');
++i;
as.loop(function (as) {
s.push('MEDIUM');
expect(i).equal(icheck);
as.loop(function (as) {
s.push('INNER1');
it('should copy steps and state', function () {
var as = this.as;
if (i > 2) {
as.break();
} else if (i == 1) {
++i;
as.continue();
}
as.state.old_v = false;
as.state.executed = false;
as.state.parallel1 = false;
as.state.parallel2 = false;
++i;
}, "INNER1");
as.loop(function (as) {
s.push('INNER2');
var model_as = async_steps();
if (i == 3) {
icheck = 4;
as.break("MEDIUM");
}
model_as.state.new_v = true;
model_as.state.old_v = true;
model_as.add(function (as) {}, function (as, error) {
as.success();
}).add(function (as) {
as.state.executed = true;
as.success();
});
model_as.parallel().add(function (as) {
as.state.parallel1 = true;
as.success();
}).add(function (as) {
as.state.parallel2 = true;
as.success();
});
as.copyFrom(model_as);
expect(as.state).have.property('old_v', false);
expect(as.state).have.property('new_v', true);
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
expect(as.state.parallel1).be.true;
expect(as.state.parallel2).be.true;
as.state.executed = false;
as.state.parallel1 = false;
as.state.parallel2 = false;
as.add(function (as) {
model_as.state.new_v2 = true;
as.copyFrom(model_as);
expect(as.state).have.property('old_v', false);
expect(as.state).have.property('new_v', true);
expect(as.state).have.property('new_v2', true);
var m = async_steps();
as.copyFrom(m);
m.add(function (as) {
as.success();
});
as.copyFrom(m);
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.executed).be.true;
expect(as.state.parallel1).be.true;
expect(as.state.parallel2).be.true;
as.break();
}, "INNER2");
as.loop(function (as) {
s.push('INNER3');
++i;
as.break("OUTER");
}, "INNER3");
}, "MEDIUM");
}, "OUTER");
}, function (as, err) {
console.dir(s);
console.dir(err + ": " + as.state.error_info);
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(s).eql(['OUTER', 'MEDIUM', 'INNER1', 'INNER1', 'INNER1', 'INNER2', 'OUTER', 'MEDIUM', 'INNER1', 'INNER2', 'INNER3']);
expect(i).equal(5);
});
it('should forward regular error', function () {
var as = this.as;
var reserr;
as.add(function (as) {
as.loop(function (as) {
as.error("MyError", 'Info');
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(reserr).equal('MyError');
expect(as.state.error_info).equal('Info');
});
describe('#execute()', function () {
it('should silently exit', function () {
var as = this.as;
it('should continue outer loop', function () {
var as = this.as;
var reserr = null;
as.add(function (as) {
var i = 0;
as.loop(function (as) {
++i;
as.execute();
assertNoEvents();
});
if (i === 3) {
as.break();
}
it('should trigger ASP sanity check', function () {
var as = this.as;
as.loop(function (as) {
++i;
as.continue("OUTER");
});
}, "OUTER");
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
});
it('should repeat count times', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.add(function (as) {
as.repeat(3, function (as) {
++i;
as.state.error_code = '';
as.add(function (as) {
var oas = as;
as.add(function (as) {
oas.success();
});
}, function (as, err) {
as.state.error_code = err;
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.error_code).be.equal('InternalError');
expect(as.state.error_info).equal(production_mode ? 'Invalid success() call' : 'Invalid call (sanity check)');
if (i == 2) {
as.continue();
}
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(3);
});
it('should repeat break', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.add(function (as) {
as.repeat(3, function (as) {
if (i == 2) {
as.break();
}
it('should implicitly success', function () {
var as = this.as;
as.add(function (as) {
as.state.ok = true;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.ok).be.true;
++i;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(2);
});
describe('#cancel()', function () {
it('should cancel execution', function () {
var as = this.as;
as.add(function (as) {
as.success();
}).add(function (as) {
as.success();
});
as.execute();
as.cancel();
assertNoEvents();
it('should repeat zero times', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.add(function (as) {
as.repeat(0, function (as) {
++i;
});
it('should cancel timeout', function () {
var as = this.as;
as.add(function (as) {
as.setTimeout(1000);
}).add(function (as) {
as.success();
});
as.execute();
as.cancel();
assertNoEvents();
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(0);
});
it('should forEach array', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.forEach([], function (as) {
++i;
});
as.add(function (as) {
as.forEach([1, 2, 3], function (as, k, v) {
assert.equal(v, k + 1);
i += v;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(6);
});
describe('#loop()', function () {
it('should complex loop', function () {
var as = this.as;
var i = 0;
var icheck = 1;
var s = [];
as.add(function (as) {
as.loop(function (as) {
s.push('OUTER');
++i;
as.loop(function (as) {
s.push('MEDIUM');
expect(i).equal(icheck);
as.loop(function (as) {
s.push('INNER1');
if (i > 2) {
as.break();
} else if (i == 1) {
++i;
as.continue();
}
++i;
}, "INNER1");
as.loop(function (as) {
s.push('INNER2');
if (i == 3) {
icheck = 4;
as.break("MEDIUM");
}
as.break();
}, "INNER2");
as.loop(function (as) {
s.push('INNER3');
++i;
as.break("OUTER");
}, "INNER3");
}, "MEDIUM");
}, "OUTER");
}, function (as, err) {
console.dir(s);
console.dir(err + ": " + as.state.error_info);
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(s).eql(['OUTER', 'MEDIUM', 'INNER1', 'INNER1', 'INNER1', 'INNER2', 'OUTER', 'MEDIUM', 'INNER1', 'INNER2', 'INNER3']);
expect(i).equal(5);
it('should forEach object', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.forEach({}, function (as) {
++i;
});
as.add(function (as) {
as.forEach({
a: 1,
b: 2,
c: 3
}, function (as, k, v) {
if (v == 1) assert.equal(k, "a");
if (v == 2) assert.equal(k, "b");
if (v == 3) assert.equal(k, "c");
i += v;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(6);
});
it('should forward regular error', function () {
var as = this.as;
var reserr;
as.add(function (as) {
as.loop(function (as) {
as.error("MyError", 'Info');
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(reserr).equal('MyError');
expect(as.state.error_info).equal('Info');
if (!in_browser) {
it('should forEach Map', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.forEach(new Map(), function (as) {
++i;
});
it('should continue outer loop', function () {
var as = this.as;
var reserr = null;
as.add(function (as) {
var i = 0;
as.loop(function (as) {
++i;
if (i === 3) {
as.break();
}
as.loop(function (as) {
++i;
as.continue("OUTER");
});
}, "OUTER");
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
as.add(function (as) {
as.forEach(new Map([['a', 1], ['b', 2], ['c', 3]]), function (as, k, v) {
if (v == 1) assert.equal(k, "a");
if (v == 2) assert.equal(k, "b");
if (v == 3) assert.equal(k, "c");
i += v;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(6);
});
}
it('should repeat count times', function () {
var as = this.as;
var reserr = null;
var i = 0;
it('should continue after break()+next error()', function () {
// Spotted bug after burst optimization.
var as = this.as;
as.add(function (as) {
as.repeat(3, function (as) {
++i;
var _this = this;
if (i == 2) {
as.continue();
}
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(3);
var root_as = as;
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
as.loop(function (as) {
return as.break();
});
it('should repeat break', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.add(function (as) {
as.repeat(3, function (as) {
if (i == 2) {
as.break();
}
++i;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(2);
as.add(function (as) {
as.error('MyError');
});
}, function (as, err) {
as.state.myerror = err === 'MyError';
as.success();
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.myerror).be.true;
expect(as.state.executed).be.true;
});
});
describe('#state()', function () {
it('should return state', function () {
var as = this.as;
expect(as.state()).equal(as.state);
});
it('should set error_info, last_exception and async_stack', function () {
var as = this.as;
it('should repeat zero times', function () {
var as = this.as;
var reserr = null;
var i = 0;
var _step_func;
as.add(function (as) {
as.repeat(0, function (as) {
++i;
});
}, function (as, err) {
reserr = err;
});
var _error_func;
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
as.add(_step_func = function step_func(as) {
if (!production_mode) {
var async_stack = as._root._exec_stack;
expect(async_stack[async_stack.length - 1]).eql(_step_func);
}
assert.equal(reserr, null);
expect(i).equal(0);
});
as.error('FirstError', 'FirstInfo');
}, _error_func = function error_func(as, err) {
try {
var state = as.state;
expect(err).equal('FirstError');
expect(state.error_info).equal('FirstInfo');
expect(state.last_exception.message).equal('FirstError');
it('should forEach array', function () {
var as = this.as;
var reserr = null;
var i = 0;
if (!production_mode) {
var async_stack = state.async_stack;
expect(async_stack[async_stack.length - 1]).eql(_error_func);
}
} catch (e) {
console.log(e);
throw e;
}
as.forEach([], function (as) {
++i;
});
as.add(function (as) {
as.forEach([1, 2, 3], function (as, k, v) {
assert.equal(v, k + 1);
i += v;
});
}, function (as, err) {
reserr = err;
});
as.error('SecondError', 'SecondInfo');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.error_info).equal('SecondInfo');
expect(as.state.last_exception.message).equal('SecondError');
});
it('should set error_info, last_exception and async_stack in async', function () {
var as = this.as;
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
var _step_func2;
assert.equal(reserr, null);
expect(i).equal(6);
});
var _error_func2;
it('should forEach object', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.add(_step_func2 = function step_func(as) {
if (!production_mode) {
var async_stack = as._root._exec_stack;
expect(async_stack[async_stack.length - 1]).eql(_step_func2);
}
as.forEach({}, function (as) {
++i;
});
as.add(function (as) {
as.forEach({
a: 1,
b: 2,
c: 3
}, function (as, k, v) {
if (v == 1) assert.equal(k, "a");
if (v == 2) assert.equal(k, "b");
if (v == 3) assert.equal(k, "c");
i += v;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(6);
as.waitExternal();
async_steps.AsyncToolTest.callImmediate(function () {
try {
as.error('FirstError', 'FirstInfo');
} catch (_) {// ignore
}
});
}, _error_func2 = function error_func(as, err) {
try {
var state = as.state;
expect(err).equal('FirstError');
expect(state.error_info).equal('FirstInfo');
expect(state.last_exception.message).equal('FirstError');
if (!in_browser) {
it('should forEach Map', function () {
var as = this.as;
var reserr = null;
var i = 0;
as.forEach(new Map(), function (as) {
++i;
});
as.add(function (as) {
as.forEach(new Map([['a', 1], ['b', 2], ['c', 3]]), function (as, k, v) {
if (v == 1) assert.equal(k, "a");
if (v == 2) assert.equal(k, "b");
if (v == 3) assert.equal(k, "c");
i += v;
});
}, function (as, err) {
reserr = err;
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
assert.equal(reserr, null);
expect(i).equal(6);
});
if (!production_mode) {
var async_stack = state.async_stack;
expect(async_stack[async_stack.length - 1]).eql(_error_func2);
}
} catch (e) {
console.log(e);
throw e;
}
it('should continue after break()+next error()', function () {
// Spotted bug after burst optimization.
var as = this.as;
var _this = this;
var root_as = as;
as.error('SecondError', 'SecondInfo');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.error_info).equal('SecondInfo');
expect(as.state.last_exception.message).equal('SecondError');
});
});
it('should support chaining', function (done) {
var as = this.as;
var empty_as = async_steps();
var model_as = async_steps();
model_as.add(function (as) {
as.state.count++;
as.add(function (as) {
as.state.count++;
}).loop(function (as) {
as.state.count++;
as.break();
}).repeat(2, function (as) {
as.state.count++;
}).forEach([1, 2], function (as) {
as.state.count++;
}).forEach({
a: 1,
b: 2
}, function (as) {
as.state.count++;
}).copyFrom(empty_as).add(function (as) {
as.state.count++;
});
}, function (as, err) {
console.dir(err + ": " + as.state.error_info);
console.log(as.state.last_exception);
});
as.add(function (as) {
as.state.count++;
}).copyFrom(model_as).loop(function (as) {
as.state.count++;
as.break();
}).repeat(2, function (as) {
as.state.count++;
}).forEach([1, 2], function (as) {
as.state.count++;
}).forEach({
a: 1,
b: 2
}, function (as) {
as.state.count++;
}).add(function (as) {
as.state.count++;
as.state.myerror = false;
as.state.executed = false;
as.add(function (as) {
as.loop(function (as) {
return as.break();
});
as.add(function (as) {
as.error('MyError');
});
}, function (as, err) {
as.state.myerror = err === 'MyError';
as.success();
});
as.add(function (as) {
as.state.executed = true;
as.success();
});
as.execute();
async_steps.AsyncToolTest.run();
expect(as.state.myerror).be.true;
expect(as.state.executed).be.true;
});
try {
expect(as.state.count).equal(19);
done();
} catch (e) {
done(e);
}
});
describe('#state()', function () {
it('should return state', function () {
var as = this.as;
as.state.count = 0;
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
});
describe('#waitExternal', function () {
it('should disable implicit #success()', function (done) {
var as = this.as;
as.add(function (as) {
as.waitExternal();
expect(as.state()).equal(as.state);
});
it('should set error_info, last_exception and async_stack', function () {
var as = this.as;
var _step_func;
var _error_func;
as.add(_step_func = function step_func(as) {
if (!production_mode) {
var async_stack = as._root._exec_stack;
expect(async_stack[async_stack.length - 1]).eql(_step_func);
}
as.error('FirstError', 'FirstInfo');
}, _error_func = function error_func(as, err) {
try {
var state = as.state;
expect(err).equal('FirstError');
expect(state.error_info).equal('FirstInfo');
expect(state.last_exception.message).equal('FirstError');
if (!production_mode) {
var async_stack = state.async_stack;
expect(async_stack[async_stack.length - 1]).eql(_error_func);
}
} catch (e) {
console.log(e);
throw e;
}
as.error('SecondError', 'SecondInfo');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.error_info).equal('SecondInfo');
expect(as.state.last_exception.message).equal('SecondError');
});
it('should set error_info, last_exception and async_stack in async', function () {
var as = this.as;
var _step_func2;
var _error_func2;
as.add(_step_func2 = function step_func(as) {
if (!production_mode) {
var async_stack = as._root._exec_stack;
expect(async_stack[async_stack.length - 1]).eql(_step_func2);
}
as.waitExternal();
async_steps.AsyncToolTest.callImmediate(function () {
try {
as.error('FirstError', 'FirstInfo');
} catch (_) {
// ignore
}
});
}, _error_func2 = function error_func(as, err) {
try {
var state = as.state;
expect(err).equal('FirstError');
expect(state.error_info).equal('FirstInfo');
expect(state.last_exception.message).equal('FirstError');
if (!production_mode) {
var async_stack = state.async_stack;
expect(async_stack[async_stack.length - 1]).eql(_error_func2);
}
} catch (e) {
console.log(e);
throw e;
}
as.error('SecondError', 'SecondInfo');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
expect(as.state.error_info).equal('SecondInfo');
expect(as.state.last_exception.message).equal('SecondError');
});
as.state.cb = function () {
try {
as.error('OK');
} catch (e) {// pass
}
};
}, function (as, err) {
if (err === 'OK') {
done();
} else {
done(as.state.last_exception);
}
});
as.add(function (as) {
done('Fail');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
as.state.cb();
async_steps.AsyncToolTest.run();
assertNoEvents();
});
it('should support chaining', function (done) {
var as = this.as;
var empty_as = async_steps();
var model_as = async_steps();
model_as.add(function (as) {
as.state.count++;
as.add(function (as) {
as.state.count++;
}).loop(function (as) {
as.state.count++;
as.break();
}).repeat(2, function (as) {
as.state.count++;
}).forEach([1, 2], function (as) {
as.state.count++;
}).forEach({
a: 1,
b: 2
}, function (as) {
as.state.count++;
}).copyFrom(empty_as).add(function (as) {
as.state.count++;
});
});
describe('#sync', function () {
it('should use sync object', function (done) {
var as = this.as;
var mutex = {
sync: function sync(as, func, onerror) {
as.add(func, onerror);
}
};
as.sync(mutex, function (as) {
as.sync(mutex, function (as) {
as.error('Wrong');
}, function (as, err) {
console.dir(err + ": " + as.state.error_info);
console.log(as.state.last_exception);
if (err === 'Wrong') {
as.error('OK');
}
});
as.add(function (as) {
as.state.count++;
}).copyFrom(model_as).loop(function (as) {
as.state.count++;
as.break();
}).repeat(2, function (as) {
as.state.count++;
}).forEach([1, 2], function (as) {
as.state.count++;
}).forEach({
a: 1,
b: 2
}, function (as) {
as.state.count++;
}).add(function (as) {
as.state.count++;
try {
expect(as.state.count).equal(19);
done();
} catch (e) {
done(e);
}
done('Fail');
});
as.state.count = 0;
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
}, function (as, err) {
if (err === 'OK') {
done();
} else {
done(as.state.last_exception);
}
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
});
});
});
describe('#waitExternal', function () {
it('should disable implicit #success()', function (done) {
var as = this.as;
as.add(function (as) {
as.waitExternal();
as.state.cb = function () {
try {
as.error('OK');
} catch (e) {
// pass
}
};
}, function (as, err) {
if (err === 'OK') {
done();
} else {
done(as.state.last_exception);
}
});
as.add(function (as) {
done('Fail');
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
as.state.cb();
async_steps.AsyncToolTest.run();
assertNoEvents();
if (typeof Promise !== 'undefined') {
describe('#await', function () {
it('should support Promise', function (done) {
var as = async_steps();
as.await(Promise.resolve(123)).add(function (as, res) {
try {
expect(res).to.equal(123);
} catch (e) {
done(e);
}
});
as.await(new Promise(function (resolve, reject) {
return setTimeout(resolve, 100);
}));
as.add(function (as) {
as.await(Promise.resolve());
as.add(function (as, res) {
try {
expect(res).to.equal(undefined);
} catch (e) {
done(e);
}
});
});
as.add(function (as) {
return done();
});
as.execute();
});
it('should handle rejected Promise', function (done) {
var as = async_steps();
var test_error = new Error('MyError');
describe('#sync', function () {
it('should use sync object', function (done) {
var as = this.as;
var mutex = {
sync: function sync(as, func, onerror) {
as.add(func, onerror);
}
};
as.sync(mutex, function (as) {
as.sync(mutex, function (as) {
as.error('Wrong');
}, function (as, err) {
if (err === 'Wrong') {
as.error('OK');
}
});
as.add(function (as) {
done('Fail');
});
}, function (as, err) {
if (err === 'OK') {
done();
} else {
done(as.state.last_exception);
}
});
as.execute();
async_steps.AsyncToolTest.run();
assertNoEvents();
try {
as.await(Promise.reject(test_error), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
expect(as.state.last_exception).to.equal(test_error);
as.success();
} catch (e) {
done(e);
}
});
});
});
} catch (e) {
done(e);
}
if (typeof Promise !== 'undefined') {
describe('#await', function () {
it('should support Promise', function (done) {
var as = async_steps();
as.await(Promise.resolve(123)).add(function (as, res) {
try {
expect(res).to.equal(123);
} catch (e) {
done(e);
}
});
as.await(new Promise(function (resolve, reject) {
return setTimeout(resolve, 100);
}));
as.add(function (as) {
as.await(Promise.resolve());
as.add(function (as, res) {
try {
expect(res).to.equal(undefined);
} catch (e) {
done(e);
}
});
});
as.add(function (as) {
return done();
});
as.execute();
as.await(new Promise(function (resolve, reject) {
return setTimeout(reject, 100);
}), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
expect(as.state.last_exception.message).to.equal('PromiseReject');
as.success();
} catch (e) {
done(e);
}
});
as.add(function (as) {
as.await(Promise.reject(), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
as.success();
} catch (e) {
done(e);
}
});
it('should handle rejected Promise', function (done) {
var as = async_steps();
var test_error = new Error('MyError');
try {
as.await(Promise.reject(test_error), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
expect(as.state.last_exception).to.equal(test_error);
as.success();
} catch (e) {
done(e);
}
});
} catch (e) {
done(e);
}
as.await(new Promise(function (resolve, reject) {
return setTimeout(reject, 100);
}), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
expect(as.state.last_exception.message).to.equal('PromiseReject');
as.success();
} catch (e) {
done(e);
}
});
as.add(function (as) {
as.await(Promise.reject(), function (as, res) {
try {
expect(res).to.equal('PromiseReject');
as.success();
} catch (e) {
done(e);
}
});
}, function (as, err) {
done(as.state.last_exception || 'Fail');
});
as.add(function (as) {
as.await(Promise.reject('SomeError'), function (as, res) {
try {
expect(res).to.equal('SomeError');
as.success();
} catch (e) {
done(e);
}
});
});
as.add(function (as) {
return done();
});
as.execute();
}, function (as, err) {
done(as.state.last_exception || 'Fail');
});
as.add(function (as) {
as.await(Promise.reject('SomeError'), function (as, res) {
try {
expect(res).to.equal('SomeError');
as.success();
} catch (e) {
done(e);
}
});
it('should handle cancel', function (done) {
var as = async_steps();
as.add(function (as) {
as.setCancel(function (as) {
return done();
});
as.add(function (as) {
as.await(new Promise(function () {}));
});
});
as.add(function (as) {
return done('Fail');
});
as.execute();
setTimeout(function () {
return as.cancel();
}, 100);
});
});
as.add(function (as) {
return done();
});
as.execute();
});
describe('#promise', function () {
it('should wrap in Promise', function (done) {
var as = async_steps();
as.add(function (as) {
as.add(function (as) {
as.success('Some result');
});
});
as.add(function (as, res) {
as.successStep(res + ' more');
});
as.promise().then(function (res) {
try {
expect(res).equal('Some result more');
done();
} catch (e) {
done(e);
}
});
it('should handle cancel', function (done) {
var as = async_steps();
as.add(function (as) {
as.setCancel(function (as) {
return done();
});
it('should handle error as Promise reject', function (done) {
var as = async_steps();
as.add(function (as) {
as.add(function (as) {
as.success('Some result');
});
});
as.add(function (as, res) {
as.error(res + ' more');
});
as.promise().catch(function (err) {
try {
expect(err.message).equal('Some result more');
done();
} catch (e) {
done(e);
}
});
as.add(function (as) {
as.await(new Promise(function () {}));
});
});
as.add(function (as) {
return done('Fail');
});
as.execute();
setTimeout(function () {
return as.cancel();
}, 100);
});
}
describe('.assertAS', function (done) {
it("should pass with valid objects", function () {
var as = async_steps();
async_steps.assertAS(as);
async_steps.assertAS(as.parallel());
});
describe('#promise', function () {
it('should wrap in Promise', function (done) {
var as = async_steps();
as.add(function (as) {
as.add(function (as) {
async_steps.assertAS(as);
async_steps.assertAS(as.parallel());
as.success('Some result');
});
});
as.add(function (as, res) {
as.successStep(res + ' more');
});
as.promise().then(function (res) {
try {
expect(res).equal('Some result more');
done();
} catch (e) {
done(e);
}
});
});
it('should handle error as Promise reject', function (done) {
var as = async_steps();
as.add(function (as) {
as.add(function (as) {
return done();
as.success('Some result');
});
});
as.add(function (as, res) {
as.error(res + ' more');
});
as.promise().catch(function (err) {
try {
expect(err.message).equal('Some result more');
done();
} catch (e) {
done(e);
}
});
});
});
}
as.execute();
describe('.assertAS', function (done) {
it("should pass with valid objects", function () {
var as = async_steps();
async_steps.assertAS(as);
async_steps.assertAS(as.parallel());
as.add(function (as) {
async_steps.assertAS(as);
async_steps.assertAS(as.parallel());
});
as.add(function (as) {
return done();
});
as.execute();
});
it("should detect errors", function (done) {
var _arr = [undefined, null, 1, 'a', {}, [], function () {}];
it("should detect errors", function (done) {
var _arr = [undefined, null, 1, 'a', {}, [], function () {}];
for (var _i = 0; _i < _arr.length; _i++) {
var v = _arr[_i];
for (var _i = 0; _i < _arr.length; _i++) {
var v = _arr[_i];
try {
async_steps.assertAS(v);
done('Fail');
return;
} catch (e) {
expect(e.message).equal('Not an instance of AsyncSteps: ' + v);
}
}
try {
async_steps.assertAS(v);
done('Fail');
return;
} catch (e) {
expect(e.message).equal("Not an instance of AsyncSteps: ".concat(v));
}
}
done();
});
it("should have exports", function () {
if ('ISync' in async_steps) {
expect(async_steps).to.have.keys(['ISync', 'Mutex', 'Throttle', 'Limiter', 'testcase', 'Errors', 'AsyncSteps', 'ActiveAsyncTool', 'AsyncTool', 'AsyncToolTest', 'FutoInError', 'assertAS', 'installAsyncToolTest', 'isProduction']);
} else {
expect(async_steps).to.have.keys(['Errors', 'AsyncSteps', 'ActiveAsyncTool', 'AsyncTool', 'AsyncToolTest', 'FutoInError', 'assertAS', 'installAsyncToolTest', 'isProduction']);
}
});
done();
});
it("should have exports", function () {
if ('ISync' in async_steps) {
expect(async_steps).to.have.keys(['ISync', 'Mutex', 'Throttle', 'Limiter', 'testcase', 'Errors', 'AsyncSteps', 'ActiveAsyncTool', 'AsyncTool', 'AsyncToolTest', 'FutoInError', 'assertAS', 'installAsyncToolTest', 'isProduction']);
} else {
expect(async_steps).to.have.keys(['Errors', 'AsyncSteps', 'ActiveAsyncTool', 'AsyncTool', 'AsyncToolTest', 'FutoInError', 'assertAS', 'installAsyncToolTest', 'isProduction']);
}
});
});
if (typeof window !== 'undefined' && window.$as) {
describe('FutoIn.AsyncSteps', function () {
it('should be set', function () {
expect(window.$as.AsyncSteps).equal(window.FutoIn.AsyncSteps);
expect(window.FutoIn.$as).equal(window.futoin.$as);
});
describe('FutoIn.AsyncSteps', function () {
it('should be set', function () {
expect(window.$as.AsyncSteps).equal(window.FutoIn.AsyncSteps);
expect(window.FutoIn.$as).equal(window.futoin.$as);
});
});
}
//# sourceMappingURL=unittest.js.map
"use strict";
/**

@@ -25,3 +24,2 @@ * @file Module's entry point and AsyncSteps class itself

var AsyncSteps = require('./AsyncSteps');
/**

@@ -41,28 +39,30 @@ * Mocha-compatible test case based on AsyncSteps.

*/
module.exports = function (func, onerror) {
return function (done) {
var _this = this;
return function (done) {
var _this = this;
var as = new AsyncSteps();
as.add(function (as) {
as.add(function (as) {
func.call(_this, as);
var as = new AsyncSteps();
as.add(function (as) {
as.add(function (as) {
func.call(_this, as);
if (onerror) {
as.add(function (as) {
as.error('NegativeTestMustThrow');
});
}
}, onerror);
}, function (as, err) {
// eslint-disable-next-line no-console
console.log('ERROR: ' + err + ' (' + as.state.error_info + ')');
done(as.state.last_exception || new Error('Generic Fail'));
});
as.add(function (as) {
return done();
});
as.execute();
};
if (onerror) {
as.add(function (as) {
as.error('NegativeTestMustThrow');
});
}
}, onerror);
}, function (as, err) {
// eslint-disable-next-line no-console
console.log("ERROR: ".concat(err, " (").concat(as.state.error_info, ")"));
done(as.state.last_exception || new Error('Generic Fail'));
});
as.add(function (as) {
return done();
});
as.execute();
};
};
//# sourceMappingURL=testcase.js.map
'use strict';
/**

@@ -24,12 +23,28 @@ * @file

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var ISync = require('./ISync');

@@ -44,15 +59,13 @@

var throttle_sync = function throttle_sync(asp, throttle, step, on_error) {
var root = asp._root;
var root = asp._root;
if (throttle._lock(asp)) {
asp._on_error = on_error;
step.apply(undefined, [asp].concat(_toConsumableArray(asp._call_args)));
} else {
asp._on_cancel = throttle._cancel_handler;
root._next_args = asp._call_args;
prev_queue(root).unshift([step, on_error]);
}
if (throttle._lock(asp)) {
asp._on_error = on_error;
step.apply(void 0, [asp].concat(_toConsumableArray(asp._call_args)));
} else {
asp._on_cancel = throttle._cancel_handler;
root._next_args = asp._call_args;
prev_queue(root).unshift([step, on_error]);
}
};
/**

@@ -62,105 +75,112 @@ * Throttling for AsyncSteps

var Throttle = function (_ISync) {
_inherits(Throttle, _ISync);
/**
* C-tor
* @param {integer} [max=1] - maximum number of simultaneous critical section entries
* @param {intger} [period_ms=1000] - time period in milliseconds
* @param {integer} [max_queue=null] - limit queue length, if set
*/
function Throttle(max) {
var period_ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e3;
var max_queue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var Throttle =
/*#__PURE__*/
function (_ISync) {
_inherits(Throttle, _ISync);
_classCallCheck(this, Throttle);
/**
* C-tor
* @param {integer} [max=1] - maximum number of simultaneous critical section entries
* @param {intger} [period_ms=1000] - time period in milliseconds
* @param {integer} [max_queue=null] - limit queue length, if set
*/
function Throttle(max) {
var _this;
var _this = _possibleConstructorReturn(this, (Throttle.__proto__ || Object.getPrototypeOf(Throttle)).call(this));
var period_ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e3;
var max_queue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
_this._max = max;
_this._current = 0;
var queue = _this._queue = [];
_this._timer = null;
_this._period_ms = period_ms;
_this._max_queue = max_queue;
_this._cancel_handler = function (asi) {
var idx = queue.indexOf(asi);
_classCallCheck(this, Throttle);
if (idx >= 0) {
queue.splice(idx, 1);
}
};
return _this;
}
_this = _possibleConstructorReturn(this, _getPrototypeOf(Throttle).call(this));
_this._max = max;
_this._current = 0;
var queue = _this._queue = [];
_this._timer = null;
_this._period_ms = period_ms;
_this._max_queue = max_queue;
_createClass(Throttle, [{
key: '_lock',
value: function _lock(asi) {
this._ensureTimer();
_this._cancel_handler = function (asi) {
var idx = queue.indexOf(asi);
if (this._current >= this._max) {
var queue = this._queue;
var max_queue = this._max_queue;
if (idx >= 0) {
queue.splice(idx, 1);
}
};
if (max_queue !== null && queue.length >= max_queue) {
asi.error(DefenseRejected, 'Throttle queue limit');
}
return _this;
}
queue.push(asi);
return false;
} else {
this._current += 1;
return true;
}
}
}, {
key: '_ensureTimer',
value: function _ensureTimer() {
var _this2 = this;
_createClass(Throttle, [{
key: "_lock",
value: function _lock(asi) {
this._ensureTimer();
if (!this._timer) {
this._timer = setInterval(function () {
_this2._resetPeriod();
}, this._period_ms);
}
if (this._current >= this._max) {
var queue = this._queue;
var max_queue = this._max_queue;
if (max_queue !== null && queue.length >= max_queue) {
asi.error(DefenseRejected, 'Throttle queue limit');
}
}, {
key: '_resetPeriod',
value: function _resetPeriod() {
this._current = 0;
var queue = this._queue;
if (!queue.length) {
clearInterval(this._timer);
this._timer = null;
return;
}
queue.push(asi);
return false;
} else {
this._current += 1;
return true;
}
}
}, {
key: "_ensureTimer",
value: function _ensureTimer() {
var _this2 = this;
var max = this._max;
var current = 0;
if (!this._timer) {
this._timer = setInterval(function () {
_this2._resetPeriod();
}, this._period_ms);
}
}
}, {
key: "_resetPeriod",
value: function _resetPeriod() {
this._current = 0;
var queue = this._queue;
while (queue.length && current < max) {
var other_as = queue.shift();
if (!queue.length) {
clearInterval(this._timer);
this._timer = null;
return;
}
if (other_as.state) {
++current;
var other_root = other_as._root;
other_root._handle_success(other_root._next_args);
}
}
var max = this._max;
var current = 0;
this._current = current;
}
}, {
key: 'sync',
value: function sync(as, step, onerror) {
var _this3 = this;
while (queue.length && current < max) {
var other_as = queue.shift();
as.add(function (as) {
throttle_sync(as, _this3, step, onerror);
});
if (other_as.state) {
++current;
var other_root = other_as._root;
other_root._handle_success(other_root._next_args);
}
}]);
}
return Throttle;
this._current = current;
}
}, {
key: "sync",
value: function sync(as, step, onerror) {
var _this3 = this;
as.add(function (as) {
throttle_sync(as, _this3, step, onerror);
});
}
}]);
return Throttle;
}(ISync);

@@ -167,0 +187,0 @@

{
"name": "futoin-asyncsteps",
"version": "2.3.2",
"version": "2.3.3",
"description": "Mimic traditional threads in single threaded event loop",

@@ -53,12 +53,13 @@ "main": "lib/main-full.js",

"devDependencies": {
"@futoin/optihelp": "^1.1.1",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.7.0",
"chai": "^4.1.2",
"eslint": "^5.3.0",
"@babel/core": "^7.2.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.2.3",
"@futoin/optihelp": "^1.2.0",
"babel-loader": "^8.0.5",
"chai": "^4.2.0",
"eslint": "^5.12.0",
"grunt": "^1.0.3",
"grunt-babel": "^7.0.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-babel": "^8.0.0",
"grunt-contrib-connect": "^2.0.0",
"grunt-eslint": "^21.0.0",

@@ -69,6 +70,6 @@ "grunt-jsdoc-to-markdown": "^4.0.0",

"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^3.1.2",
"grunt-webpack": "^3.1.3",
"istanbul": "^0.4.5",
"mocha": "^5.2.0",
"webpack": "^4.16.5"
"webpack": "^4.28.4"
},

@@ -75,0 +76,0 @@ "dependencies": {

@@ -1391,3 +1391,3 @@

## $as_test(func, [onerror]) ⇒ <code>function</code>
## $as\_test(func, [onerror]) ⇒ <code>function</code>
Mocha-compatible test case based on AsyncSteps.

@@ -1394,0 +1394,0 @@

Sorry, the diff of this file is too big to display

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

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

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

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

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc