UNPKG

futoin-asyncsteps

Version:

Mimic traditional threads in single threaded event loop

84 lines (67 loc) 98.4 kB
/* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["futoin-asyncsteps"] = factory(); else root["$as"] = factory(); })(self, () => { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./es5/AsyncSteps.js": /*!***************************!*\ !*** ./es5/AsyncSteps.js ***! \***************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\n/**\n * @file Module's entry point and AsyncSteps class itself\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @module futoin-asyncsteps\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar AsyncTool = __webpack_require__(/*! ./lib/AsyncTool */ \"./es5/lib/AsyncTool.js\");\nvar _require = __webpack_require__(/*! ./Errors */ \"./es5/Errors.js\"),\n InternalError = _require.InternalError;\nvar AsyncStepProtector = __webpack_require__(/*! ./lib/AsyncStepProtector */ \"./es5/lib/AsyncStepProtector.js\");\nvar ParallelStep = __webpack_require__(/*! ./lib/ParallelStep */ \"./es5/lib/ParallelStep.js\");\nvar _require2 = __webpack_require__(/*! ./lib/common */ \"./es5/lib/common.js\"),\n isProduction = _require2.isProduction,\n checkFunc = _require2.checkFunc,\n checkOnError = _require2.checkOnError,\n noop = _require2.noop,\n _loop = _require2.loop,\n _repeat = _require2.repeat,\n _forEach = _require2.forEach,\n as_await = _require2.as_await,\n EMPTY_ARRAY = _require2.EMPTY_ARRAY,\n newExecStack = _require2.newExecStack;\nvar sanityCheck = isProduction ? noop : function (as) {\n if (as._stack.length > 0) {\n as.error(InternalError, \"Top level add in execution\");\n }\n};\nvar sanityCheckAdd = isProduction ? noop : function (as, func, onerror) {\n sanityCheck(as);\n checkFunc(as, func);\n checkOnError(as, onerror);\n};\n\n// This small trick has a huge speedup result (75-90%)\nvar EXEC_BURST = 100;\nvar g_curr_burst = EXEC_BURST;\n// avoid another AsyncSteps instance continuation\nvar g_burst_owner = null;\nvar post_execute_cb = function post_execute_cb(asi) {\n asi._post_exec = noop;\n asi._execute();\n};\n\n/**\n * Root AsyncStep implementation\n */\nvar AsyncSteps = /*#__PURE__*/function () {\n function AsyncSteps() {\n var _this = this;\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var async_tool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AsyncTool;\n _classCallCheck(this, AsyncSteps);\n if (state === null) {\n state = function state() {\n return this.state;\n };\n }\n this.state = state;\n this._queue = [];\n this._stack = [];\n this._exec_stack = newExecStack();\n this._in_exec = false;\n this._post_exec = noop;\n this._exec_event = null;\n this._next_args = EMPTY_ARRAY;\n this._async_tool = async_tool;\n\n // ---\n var callImmediate = async_tool.callImmediate;\n var event_execute_cb = function event_execute_cb() {\n g_curr_burst = EXEC_BURST;\n g_burst_owner = _this;\n _this._exec_event = null;\n _this._execute();\n };\n this._scheduleExecute = function () {\n if (--g_curr_burst <= 0 || !_this._in_exec || g_burst_owner !== _this) {\n _this._exec_event = callImmediate(event_execute_cb);\n } else if (_this._in_exec) {\n _this._post_exec = post_execute_cb;\n }\n };\n }\n\n /**\n * Add sub-step. Can be called multiple times.\n * @param {ExecFunc} func - function defining non-blocking step execution\n * @param {ErrorFunc=} onerror - Optional, provide error handler\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#add\n */\n return _createClass(AsyncSteps, [{\n key: \"add\",\n value: function add(func, onerror) {\n sanityCheckAdd(this, func, onerror);\n this._queue.push([func, onerror]);\n return this;\n }\n\n /**\n * Creates a step internally and returns specialized AsyncSteps interfaces all steps\n * of which are executed in quasi-parallel.\n * @param {ErrorFunc=} onerror - Optional, provide error handler\n * @returns {AsyncSteps} interface for parallel step adding\n * @alias AsyncSteps#parallel\n */\n }, {\n key: \"parallel\",\n value: function parallel(onerror) {\n sanityCheck(this);\n checkOnError(this, onerror);\n var p = new ParallelStep(this, this);\n this._queue.push([function (as) {\n p.executeParallel(as);\n }, onerror]);\n return p;\n }\n\n /* globals ISync */\n\n /**\n * Add sub-step with synchronization against supplied object.\n * @param {ISync} object - Mutex, Throttle or other type of synchronization implementation.\n * @param {ExecFunc} func - function defining non-blocking step execution\n * @param {ErrorFunc=} onerror - Optional, provide error handler\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#sync\n */\n }, {\n key: \"sync\",\n value: function sync(object, func, onerror) {\n sanityCheckAdd(this, func, onerror);\n object.sync(this, func, onerror);\n return this;\n }\n\n /**\n * Set error and throw to abort execution.\n *\n * **NOTE: If called outside of AsyncSteps stack (e.g. by external event), make sure you catch the exception**\n * @param {string} name - error message, expected to be identifier \"InternalError\"\n * @param {string=} error_info - optional descriptive message assigned to as.state.error_info\n * @throws {Error}\n * @alias AsyncSteps#error\n */\n }, {\n key: \"error\",\n value: function error(name, error_info) {\n this.state.error_info = error_info;\n var e = new Error(name);\n if (!this._in_exec) {\n this.state.last_exception = e;\n this._handle_error(name);\n }\n throw e;\n }\n\n /**\n * Copy steps and not yet defined state variables from \"model\" AsyncSteps instance\n * @param {AsyncSteps} other - model instance, which must get be executed\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#copyFrom\n */\n }, {\n key: \"copyFrom\",\n value: function copyFrom(other) {\n this._queue.push.apply(this._queue, other._queue);\n var os = other.state;\n var s = this.state;\n for (var k in os) {\n if (!(k in s)) {\n s[k] = os[k];\n }\n }\n return this;\n }\n\n /**\n * @private\n * @param {Array} [args] List of success() args\n */\n }, {\n key: \"_handle_success\",\n value: function _handle_success() {\n var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;\n var stack = this._stack;\n if (!stack.length) {\n this.error(InternalError, 'Invalid success completion');\n }\n this._next_args = args;\n for (var asp = stack[stack.length - 1];;) {\n var limit_event = asp._limit_event;\n if (limit_event) {\n this._async_tool.cancelCall(limit_event);\n asp._limit_event = null;\n }\n asp._cleanup(); // aid GC\n stack.pop();\n\n // ---\n if (!stack.length) {\n break;\n }\n asp = stack[stack.length - 1];\n if (asp._queue.length) {\n break;\n }\n }\n if (stack.length || this._queue.length) {\n this._scheduleExecute();\n }\n }\n\n /**\n * @private\n * @param {string} [name] Error to handle\n */\n }, {\n key: \"_handle_error\",\n value: function _handle_error(name) {\n if (this._exec_event) {\n this.cancel();\n return;\n }\n this._next_args = EMPTY_ARRAY;\n var stack = this._stack;\n var exec_stack = this._exec_stack;\n this.state.async_stack = exec_stack;\n var orig_in_exec = this._in_exec;\n var cleanup = true;\n while (stack.length) {\n var asp = stack[stack.length - 1];\n var limit_event = asp._limit_event;\n var on_cancel = asp._on_cancel;\n var on_error = asp._on_error;\n if (limit_event) {\n this._async_tool.cancelCall(limit_event);\n asp._limit_event = null;\n }\n if (on_cancel) {\n on_cancel.call(null, asp);\n asp._on_cancel = null;\n }\n if (on_error) {\n var slen = stack.length;\n asp._queue = null; // suppress non-empty queue for success() in onerror\n asp._on_error = null; // do no repeat\n exec_stack.push(on_error);\n try {\n this._in_exec = true;\n on_error.call(null, asp, name);\n if (slen !== stack.length) {\n cleanup = false;\n break; // override with success()\n }\n if (asp._queue !== null) {\n cleanup = false;\n this._scheduleExecute();\n break;\n }\n } catch (e) {\n this.state.last_exception = e;\n name = e.message;\n } finally {\n this._in_exec = orig_in_exec;\n }\n }\n asp._cleanup(); // aid GC\n stack.pop();\n }\n if (cleanup) {\n // Clear queue on finish\n this._queue = [];\n } else if (!orig_in_exec) {\n this._post_exec(this);\n }\n }\n\n /**\n * Use only on root AsyncSteps instance. Abort execution of AsyncSteps instance in progress.\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#cancel\n */\n }, {\n key: \"cancel\",\n value: function cancel() {\n this._next_args = EMPTY_ARRAY;\n var exec_event = this._exec_event;\n if (exec_event) {\n this._async_tool.cancelImmediate(exec_event);\n this._exec_event = null;\n }\n var stack = this._stack;\n var async_tool = this._async_tool;\n while (stack.length) {\n var asp = stack.pop();\n var limit_event = asp._limit_event;\n var on_cancel = asp._on_cancel;\n if (limit_event) {\n async_tool.cancelCall(limit_event);\n asp._limit_event = null;\n }\n if (on_cancel) {\n on_cancel.call(null, asp);\n asp._on_cancel = null;\n }\n asp._cleanup(); // aid GC\n }\n\n // Clear queue on finish\n this._queue = [];\n return this;\n }\n\n /**\n * Start execution of AsyncSteps using AsyncTool\n *\n * It must not be called more than once until cancel/complete (instance can be re-used)\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#execute\n */\n }, {\n key: \"execute\",\n value: function execute() {\n var prev_owner = g_burst_owner;\n g_burst_owner = this;\n this._execute();\n g_burst_owner = prev_owner;\n return this;\n }\n }, {\n key: \"_execute\",\n value: function _execute() {\n var stack = this._stack;\n var q;\n if (stack.length) {\n q = stack[stack.length - 1]._queue;\n } else {\n q = this._queue;\n }\n if (!q.length) {\n return;\n }\n var curr = q.shift();\n var func = curr[0];\n this._exec_stack.push(func);\n var next_args = this._next_args;\n var na_len = next_args.length;\n var asp = new AsyncStepProtector(this, curr[1], next_args);\n stack.push(asp);\n try {\n var oc = stack.length;\n this._in_exec = true;\n if (!na_len) {\n func(asp);\n } else {\n this._next_args = EMPTY_ARRAY;\n func.apply(void 0, [asp].concat(_toConsumableArray(next_args)));\n }\n if (oc === stack.length) {\n if (asp._queue !== null) {\n this._scheduleExecute();\n } else if (!asp._on_cancel && !asp._limit_event) {\n // Implicit success\n this._handle_success(this._next_args);\n }\n }\n } catch (e) {\n this.state.last_exception = e;\n this._handle_error(e.message);\n } finally {\n this._in_exec = false;\n }\n this._post_exec(this);\n }\n\n /**\n * Optimized success() which performs burst execution\n * @param {Array} [args] List of success() args\n * @private\n */\n }, {\n key: \"_burst_success\",\n value: function _burst_success() {\n var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;\n try {\n this._in_exec = true;\n g_burst_owner = this;\n this._handle_success(args);\n } catch (e) {\n this.state.last_exception = e;\n this._handle_error(e.message);\n } finally {\n this._in_exec = false;\n }\n this._post_exec(this);\n }\n\n /**\n * It is just a subset of *ExecFunc*\n * @callback LoopFunc\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @alias loop_callback\n * @see ExecFunc\n */\n\n /**\n * Execute loop until *as.break()* or *as.error()* is called\n * @param {LoopFunc} func - loop body\n * @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#loop\n */\n }, {\n key: \"loop\",\n value: function loop(func, label) {\n sanityCheckAdd(this, func);\n _loop(this, this, func, label);\n return this;\n }\n\n /**\n * It is just a subset of *ExecFunc*\n * @callback RepeatFunc\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @param {number} i - current iteration starting from 0\n * @alias repeat_callback\n * @see ExecFunc\n */\n\n /**\n * Call *func(as, i)* for *count* times\n * @param {number} count - how many times to call the *func*\n * @param {RepeatFunc} func - loop body\n * @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#repeat\n */\n }, {\n key: \"repeat\",\n value: function repeat(count, func, label) {\n sanityCheckAdd(this, func);\n _repeat(this, this, count, func, label);\n return this;\n }\n\n /**\n * It is just a subset of *ExecFunc*\n * @callback ForEachFunc\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @param {number|string} key - key ID or name\n * @param {*} value - value associated with key\n * @alias foreach_callback\n * @see ExecFunc\n */\n\n /**\n * For each *map* or *list* element call *func( as, key, value )*\n * @param {number} map_or_list - map or list to iterate over\n * @param {ForEachFunc} func - loop body\n * @param {string=} label - optional label to use for *as.break()* and *as.continue()* in inner loops\n * @returns {AsyncSteps} self\n * @alias AsyncSteps#forEach\n */\n }, {\n key: \"forEach\",\n value: function forEach(map_or_list, func, label) {\n sanityCheckAdd(this, func);\n _forEach(this, this, map_or_list, func, label);\n return this;\n }\n\n /**\n * Shortcut for `this.add( ( as ) => as.success( ...args ) )`\n * @param {...any} [args] - argument to pass, if any\n * @alias AsyncSteps#successStep\n * @returns {AsyncSteps} self\n */\n }, {\n key: \"successStep\",\n value: function successStep() {\n var _this2 = this;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n sanityCheck(this);\n var queue = this._queue;\n if (queue.length > 0) {\n queue.push([function () {\n _this2._handle_success(args);\n }, undefined]);\n } else {\n this._next_args = args;\n }\n return this;\n }\n\n /**\n * Integrate a promise as a step.\n * @param {Promise} promise - promise to add as a step\n * @param {Function} [onerror] error handler to check\n * @alias AsyncSteps#await\n * @returns {AsyncSteps} self\n */\n }, {\n key: \"await\",\n value: function _await(promise, onerror) {\n sanityCheck(this);\n as_await(this, this, promise, onerror);\n return this;\n }\n\n /**\n * Execute AsyncSteps with Promise interface\n * @alias AsyncSteps#promise\n * @returns {Promise} - promise wrapper for AsyncSteps\n */\n }, {\n key: \"promise\",\n value: function promise() {\n var _this3 = this;\n sanityCheck(this);\n return new Promise(function (resolve, reject) {\n var q = _this3._queue;\n _this3._queue = [[function (as) {\n as._queue = q;\n }, function (as, err) {\n reject(new Error(err));\n }], [function (as, res) {\n resolve(res);\n }, undefined]];\n g_burst_owner = _this3;\n _this3._execute();\n });\n }\n\n /**\n * Create a new instance of AsyncSteps for independent execution\n * @alias AsyncSteps#newInstance\n * @returns {AsyncSteps} new instance\n */\n }, {\n key: \"newInstance\",\n value: function newInstance() {\n return new AsyncSteps(null, this._async_tool);\n }\n\n /**\n * Not standard API for assertion with multiple instances of the module.\n * @private\n * @returns {boolean} true\n */\n }, {\n key: \"isAsyncSteps\",\n value: function isAsyncSteps() {\n return true;\n }\n }]);\n}();\n/**\n * **execute_callback** as defined in **FTN12: FutoIn AsyncSteps** specification. Function must have\n * non-blocking body calling: *as.success()* or *as.error()* or *as.add()/as.parallel()*.\n * @callback ExecFunc\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @param {...*} [val] - any result values passed to the previous as.success() call\n * @alias execute_callback\n */\n/**\n * **error_callback** as defined in **FTN12: FutoIn AsyncSteps** specification.\n * Function can:\n *\n * - do nothing,\n * - override error message with `as.error( new_error )`,\n * - continue execution with `as.success()`.\n * @callback ErrorFunc\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @param {string} err - error message\n * @alias error_callback\n */\n/**\n * **cancel_callback** as defined in **FTN12: FutoIn AsyncSteps** specification.\n * @callback CancelFunc\n * It must be used to cancel any external processing to avoid invalidated AsyncSteps object use.\n * @param {AsyncSteps} as - the only valid reference to AsyncSteps with required level of protection\n * @alias cancel_callback\n */\n/**\n * Get AsyncSteps state object.\n *\n * **Note: There is a JS-specific improvement: as.state === as.state()**\n *\n * The are the following pre-defined state variables:\n *\n * - **error_info** - error description, if provided to *as.error()*\n * - **last_exception** - the last exception caught\n * - **async_stack** - array of references to executed step handlers in current stack\n * @returns {object}\n * @alias AsyncSteps#state\n */\nmodule.exports = AsyncSteps;\n//# sourceMappingURL=AsyncSteps.js.map\n\n\n//# sourceURL=webpack://$as/./es5/AsyncSteps.js?"); /***/ }), /***/ "./es5/Errors.js": /*!***********************!*\ !*** ./es5/Errors.js ***! \***********************/ /***/ ((module) => { "use strict"; eval("\n\n/**\n * @file\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nvar error_list = ['ConnectError', 'CommError', 'UnknownInterface', 'NotSupportedVersion', 'NotImplemented', 'Unauthorized', 'InternalError', 'InvokerError', 'InvalidRequest', 'DefenseRejected', 'PleaseReauth', 'SecurityError', 'Timeout', 'LoopBreak', 'LoopCont'];\n\n/**\n * List of standard FutoIn Core errors. It may static get extended in runtime.\n * @namespace FutoInErrors\n */\nvar Errors = /*#__PURE__*/_createClass(function Errors() {\n _classCallCheck(this, Errors);\n});\n/**\n * Connection error before request is sent.\n * Must be generated on Invoker side\n * @constant {string} ConnectError\n * @memberof FutoInErrors\n */\n/**\n * Communication error at any stage after request is sent\n * and before response is received.\n * Must be generated on Invoker side\n * @constant {string} CommError\n * @memberof FutoInErrors\n */\n/**\n * Unknown interface requested.\n * Must be generated only on Executor side\n * @constant {string} UnknownInterface\n * @memberof FutoInErrors\n */\n/**\n * Not supported interface version.\n * Must be generated only on Executor side\n * @constant {string} NotSupportedVersion\n * @memberof FutoInErrors\n */\n/**\n * In case interface function is not implemented on Executor side\n * Must be generated on Executor side\n * @constant {string} NotImplemented\n * @memberof FutoInErrors\n */\n/**\n * Security policy on Executor side does not allow to\n * access interface or specific function.\n * Must be generated only on Executor side\n * @constant {string} Unauthorized\n * @memberof FutoInErrors\n */\n/**\n * Unexpected internal error on Executor side, including internal CommError.\n * Must be generated only on Executor side\n * @constant {string} InternalError\n * @memberof FutoInErrors\n */\n/**\n * Unexpected internal error on Invoker side, not related to CommError.\n * Must be generated only on Invoker side\n * @constant {string} InvokerError\n * @memberof FutoInErrors\n */\n/**\n * Invalid data is passed as FutoIn request.\n * Must be generated only on Executor side\n * @constant {string} InvalidRequest\n * @memberof FutoInErrors\n */\n/**\n * Defense system has triggered rejection\n * Must be generated on Executor side, but also possible to be triggered on Invoker\n * @constant {string} DefenseRejected\n * @memberof FutoInErrors\n */\n/**\n * Executor requests re-authorization\n * Must be generated only on Executor side\n * @constant {string} PleaseReauth\n * @memberof FutoInErrors\n */\n/**\n * 'sec' request section has invalid data or not SecureChannel\n * Must be generated only on Executor side\n * @constant {string} SecurityError\n * @memberof FutoInErrors\n */\n/**\n * Timeout occurred in any stage\n * Must be used only internally and should never travel in request message\n * @constant {string} Timeout\n * @memberof FutoInErrors\n */\n/**\n * Loop Break called\n * Must not be used directly.\n * @constant {string} LoopBreak\n * @private\n * @memberof FutoInErrors\n */\n/**\n * Loop Continue called\n * Must not be used directly.\n * @constant {string} LoopCont\n * @private\n * @memberof FutoInErrors\n */\nerror_list.forEach(function (v) {\n return Object.defineProperty(Errors, v, {\n enumerable: true,\n value: v\n });\n});\nmodule.exports = Errors;\n//# sourceMappingURL=Errors.js.map\n\n\n//# sourceURL=webpack://$as/./es5/Errors.js?"); /***/ }), /***/ "./es5/ISync.js": /*!**********************!*\ !*** ./es5/ISync.js ***! \**********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\n/**\n * @file\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar _require = __webpack_require__(/*! ./Errors */ \"./es5/Errors.js\"),\n NotImplemented = _require.NotImplemented;\n\n/**\n * Base interface for synchronization primitives\n * @class\n */\nvar ISync = /*#__PURE__*/function () {\n function ISync() {\n _classCallCheck(this, ISync);\n }\n return _createClass(ISync, [{\n key: \"sync\",\n value: function sync(as, _func, _onerror) {\n as.error(NotImplemented, '#sync() API');\n }\n }]);\n}();\nmodule.exports = ISync;\n//# sourceMappingURL=ISync.js.map\n\n\n//# sourceURL=webpack://$as/./es5/ISync.js?"); /***/ }), /***/ "./es5/Limiter.js": /*!************************!*\ !*** ./es5/Limiter.js ***! \************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\n/**\n * @file\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar ISync = __webpack_require__(/*! ./ISync */ \"./es5/ISync.js\");\nvar Mutex = __webpack_require__(/*! ./Mutex */ \"./es5/Mutex.js\");\nvar Throttle = __webpack_require__(/*! ./Throttle */ \"./es5/Throttle.js\");\n\n/**\n * Limiter - complex processing limit for AsyncSteps\n */\nvar Limiter = /*#__PURE__*/function (_ISync) {\n /**\n * C-tor\n * @param {object} [options] - option map\n * @param {number} [options.concurrent] - maximum concurrent flows\n * @param {number} [options.max_queue] - maximum queued\n * @param {number} [options.rate] - maximum entries in period\n * @param {number} [options.period_ms] - period length\n * @param {number} [options.burst] - maximum queue for rate limiting\n */\n function Limiter() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, Limiter);\n _this = _callSuper(this, Limiter);\n _this._mutex = new Mutex(options.concurrent || 1, options.max_queue || 0);\n _this._throttle = new Throttle(options.rate || 1, options.period_ms || 1000, options.burst || 0);\n return _this;\n }\n _inherits(Limiter, _ISync);\n return _createClass(Limiter, [{\n key: \"sync\",\n value: function sync(as, step, onerror) {\n var _this2 = this;\n as.sync(this._mutex, function (as) {\n as._root._next_args = as._call_args;\n as.sync(_this2._throttle, step, onerror);\n });\n }\n }]);\n}(ISync);\nmodule.exports = Limiter;\n//# sourceMappingURL=Limiter.js.map\n\n\n//# sourceURL=webpack://$as/./es5/Limiter.js?"); /***/ }), /***/ "./es5/Mutex.js": /*!**********************!*\ !*** ./es5/Mutex.js ***! \**********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\n/**\n * @file\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar ISync = __webpack_require__(/*! ./ISync */ \"./es5/ISync.js\");\nvar _require = __webpack_require__(/*! ./Errors */ \"./es5/Errors.js\"),\n DefenseRejected = _require.DefenseRejected;\nvar mtx_sync = function mtx_sync(asp, mtx, step, on_error) {\n var root = asp._root;\n var release_step = function release_step(asi) {\n mtx._release(root);\n root._handle_success(asi._call_args);\n };\n asp._on_cancel = mtx._release_handler;\n asp._queue = [[function (asi) {\n if (mtx._lock(asp, root)) {\n root._handle_success(asp._call_args);\n } else {\n asi.waitExternal();\n asi._call_args = asp._call_args;\n }\n }, undefined], [step, on_error], [release_step, undefined]];\n};\n\n/**\n * Mutual exclusion mechanism for AsyncSteps\n */\nvar Mutex = /*#__PURE__*/function (_ISync) {\n /**\n * C-tor\n * @param {number} [max] - maximum number of simultaneous critical section entries\n * @param {?number} [max_queue] - limit queue length, if set\n */\n function Mutex() {\n var _this;\n var max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var max_queue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n _classCallCheck(this, Mutex);\n _this = _callSuper(this, Mutex);\n _this._max = max;\n _this._locked = 0;\n _this._owners = new WeakMap();\n _this._queue = [];\n _this._max_queue = max_queue;\n _this._release_handler = function (asi) {\n _this._release(asi._root);\n };\n return _this;\n }\n _inherits(Mutex, _ISync);\n return _createClass(Mutex, [{\n key: \"_lock\",\n value: function _lock(asi, root) {\n var owners = this._owners;\n var owned = owners.get(root);\n if (owned) {\n owners.set(root, owned + 1);\n return true;\n } else if (this._locked >= this._max) {\n var queue = this._queue;\n var max_queue = this._max_queue;\n if (max_queue !== null && queue.length >= max_queue) {\n root.error(DefenseRejected, 'Mutex queue limit');\n }\n queue.push(asi);\n return false;\n } else {\n this._locked += 1;\n owners.set(root, 1);\n return true;\n }\n }\n }, {\n key: \"_release\",\n value: function _release(root) {\n var owners = this._owners;\n var owned = owners.get(root);\n if (owned) {\n if (owned > 1) {\n owners.set(root, owned - 1);\n return;\n }\n owners[\"delete\"](root);\n this._locked -= 1;\n var queue = this._queue;\n while (queue.length) {\n var other_as = queue.shift();\n if (other_as.state) {\n var other_root = other_as._root;\n this._lock(other_as, other_root);\n other_root._handle_success(other_as._call_args);\n break;\n }\n }\n } else {\n var idx = this._queue.indexOf(root);\n if (idx >= 0) {\n this._queue.splice(idx, 1);\n }\n }\n }\n }, {\n key: \"sync\",\n value: function sync(as, step, onerror) {\n var _this2 = this;\n as.add(function (as) {\n mtx_sync(as, _this2, step, onerror);\n });\n }\n }]);\n}(ISync);\nmodule.exports = Mutex;\n//# sourceMappingURL=Mutex.js.map\n\n\n//# sourceURL=webpack://$as/./es5/Mutex.js?"); /***/ }), /***/ "./es5/Throttle.js": /*!*************************!*\ !*** ./es5/Throttle.js ***! \*************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\n/**\n * @file\n * @author Andrey Galkin <andrey@futoin.org>\n *\n *\n * Copyright 2014-2017 FutoIn Project (https://futoin.org)\n * Copyright 2014-2017 Andrey Galkin <andrey@futoin.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nvar ISync = __webpack_require__(/*! ./ISync */ \"./es5/ISync.js\");\nvar _require = __webpack_require__(/*! ./Errors */ \"./es5/Errors.js\"),\n DefenseRejected = _require.DefenseRejected;\nvar _require2 = __webpack_require__(/*! ./lib/common */ \"./es5/lib/common.js\"),\n prev_queue = _require2.prev_queue;\nvar throttle_sync = function throttle_sync(asp, throttle, step, on_error) {\n var root = asp._root;\n if (throttle._lock(asp)) {\n asp._on_erro