parallel-es
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,424 +0,2 @@ | ||
(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["parallel-es"] = factory(); | ||
else | ||
root["parallel-es"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // identity function for calling harmory imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // define getter function for harmory exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 45); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ((function(modules) { | ||
// Check all modules for deduplicated modules | ||
for(var i in modules) { | ||
if(Object.prototype.hasOwnProperty.call(modules, i)) { | ||
switch(typeof modules[i]) { | ||
case "function": break; | ||
case "object": | ||
// Module can be created from a template | ||
modules[i] = (function(_m) { | ||
var args = _m.slice(1), fn = modules[_m[0]]; | ||
return function (a,b,c) { | ||
fn.apply(this, [a,b,c].concat(args)); | ||
}; | ||
}(modules[i])); | ||
break; | ||
default: | ||
// Module is a copy of another module | ||
modules[i] = modules[modules[i]]; | ||
break; | ||
} | ||
} | ||
} | ||
return modules; | ||
}([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Represents a function call | ||
*/ | ||
class FunctionCall { | ||
constructor(func, params) { | ||
this.func = func; | ||
this.params = params; | ||
} | ||
static create(func, ...args) { | ||
return new FunctionCall(func, args); | ||
} | ||
/** | ||
* Creates a function call for a function with with many arguments | ||
* @param func the function to call | ||
* @param params the parameters to pass | ||
* @returns the function call | ||
*/ | ||
static createUnchecked(func, ...params) { | ||
return new FunctionCall(func, params); | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = FunctionCall; | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = functionId; | ||
/* harmony export (immutable) */ exports["b"] = isFunctionId; | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Creates a function id | ||
* @param namespace the namespace of the id | ||
* @param id the unique id for this namespace | ||
* @returns the function id | ||
*/ | ||
function functionId(namespace, id) { | ||
return { | ||
_______isFunctionId: true, | ||
identifier: `${namespace}-${id}` | ||
}; | ||
} | ||
/** | ||
* Tests if the given object is a function id | ||
* @param obj the object to test for | ||
* @returns true if the object is a function id | ||
*/ | ||
function isFunctionId(obj) { | ||
return !!obj && obj._______isFunctionId === true; | ||
} | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__parallel__ = __webpack_require__(14); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__parallel___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__parallel__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__chain_parallel_chain__ = __webpack_require__(9); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__chain_parallel_chain___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__chain_parallel_chain__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__parallel_environment__ = __webpack_require__(10); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__parallel_environment___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__parallel_environment__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__parallel_job__ = __webpack_require__(11); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__parallel_job___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__parallel_job__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__parallel_options__ = __webpack_require__(13); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__parallel_options___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__parallel_options__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__scheduling_parallel_job_scheduler__ = __webpack_require__(15); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__scheduling_parallel_job_scheduler___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5__scheduling_parallel_job_scheduler__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__parallel_operation__ = __webpack_require__(12); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__parallel_operation___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__parallel_operation__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__stream_parallel_stream__ = __webpack_require__(16); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__stream_parallel_stream___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__stream_parallel_stream__); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_0__parallel__, "IParallel")) __webpack_require__.d(exports, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__parallel__["IParallel"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_1__chain_parallel_chain__, "IParallelChain")) __webpack_require__.d(exports, "b", function() { return __WEBPACK_IMPORTED_MODULE_1__chain_parallel_chain__["IParallelChain"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_2__parallel_environment__, "IParallelTaskEnvironment")) __webpack_require__.d(exports, "c", function() { return __WEBPACK_IMPORTED_MODULE_2__parallel_environment__["IParallelTaskEnvironment"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_2__parallel_environment__, "IParallelEnvironment")) __webpack_require__.d(exports, "d", function() { return __WEBPACK_IMPORTED_MODULE_2__parallel_environment__["IParallelEnvironment"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_3__parallel_job__, "IParallelJob")) __webpack_require__.d(exports, "e", function() { return __WEBPACK_IMPORTED_MODULE_3__parallel_job__["IParallelJob"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_4__parallel_options__, "IParallelOptions")) __webpack_require__.d(exports, "f", function() { return __WEBPACK_IMPORTED_MODULE_4__parallel_options__["IParallelOptions"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_4__parallel_options__, "IDefaultInitializedParallelOptions")) __webpack_require__.d(exports, "g", function() { return __WEBPACK_IMPORTED_MODULE_4__parallel_options__["IDefaultInitializedParallelOptions"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_5__scheduling_parallel_job_scheduler__, "IParallelJobScheduler")) __webpack_require__.d(exports, "h", function() { return __WEBPACK_IMPORTED_MODULE_5__scheduling_parallel_job_scheduler__["IParallelJobScheduler"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_6__parallel_operation__, "IParallelOperation")) __webpack_require__.d(exports, "i", function() { return __WEBPACK_IMPORTED_MODULE_6__parallel_operation__["IParallelOperation"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_6__parallel_operation__, "ISerializedParallelOperation")) __webpack_require__.d(exports, "j", function() { return __WEBPACK_IMPORTED_MODULE_6__parallel_operation__["ISerializedParallelOperation"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__stream_parallel_stream__, "IParallelStream")) __webpack_require__.d(exports, "k", function() { return __WEBPACK_IMPORTED_MODULE_7__stream_parallel_stream__["IParallelStream"]; }); | ||
/***/ }, | ||
/* 3 */, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Serializer for function calls | ||
*/ | ||
class FunctionCallSerializer { | ||
/** | ||
* Creates a new instances that uses the given function registry to lookup the unique id of a function | ||
* @param functionRegistry the registry for function lookup | ||
*/ | ||
constructor(functionRegistry) { | ||
this.functionRegistry = functionRegistry; | ||
} | ||
/** | ||
* Serializes a call to the given function and using the passed parameters | ||
* @param call the function call to serialize | ||
* @returns a serialized representation of a call to the passed function using the given parameters | ||
*/ | ||
serializeFunctionCall(call) { | ||
const funcId = this.functionRegistry.getOrSetId(call.func); | ||
return { | ||
______serializedFunctionCall: true, | ||
functionId: funcId, | ||
parameters: call.params | ||
}; | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = FunctionCallSerializer; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_parallel__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_task_task_definition__ = __webpack_require__(17); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_task_task_definition___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__common_task_task_definition__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_task_task__ = __webpack_require__(18); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_task_task___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__common_task_task__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_function_function_defintion__ = __webpack_require__(8); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_function_function_defintion___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__common_function_function_defintion__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_function_function_id__ = __webpack_require__(1); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__common_function_function_call__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__common_function_serialized_function_call__ = __webpack_require__(6); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__common_function_function_call_serializer__ = __webpack_require__(4); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__common_thread_pool_thread_pool__ = __webpack_require__(19); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__common_thread_pool_thread_pool___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__common_thread_pool_thread_pool__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__ = __webpack_require__(2); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__common_parallel__["a"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_1__common_task_task_definition__, "ITaskDefinition")) __webpack_require__.d(exports, "b", function() { return __WEBPACK_IMPORTED_MODULE_1__common_task_task_definition__["ITaskDefinition"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_2__common_task_task__, "ITask")) __webpack_require__.d(exports, "c", function() { return __WEBPACK_IMPORTED_MODULE_2__common_task_task__["ITask"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_3__common_function_function_defintion__, "IFunctionDefinition")) __webpack_require__.d(exports, "d", function() { return __WEBPACK_IMPORTED_MODULE_3__common_function_function_defintion__["IFunctionDefinition"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "e", function() { return __WEBPACK_IMPORTED_MODULE_4__common_function_function_id__["IFunctionId"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "f", function() { return __WEBPACK_IMPORTED_MODULE_4__common_function_function_id__["b"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "g", function() { return __WEBPACK_IMPORTED_MODULE_5__common_function_function_call__["a"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "h", function() { return __WEBPACK_IMPORTED_MODULE_6__common_function_serialized_function_call__["ISerializedFunctionCall"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "i", function() { return __WEBPACK_IMPORTED_MODULE_6__common_function_serialized_function_call__["a"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(exports, "j", function() { return __WEBPACK_IMPORTED_MODULE_7__common_function_function_call_serializer__["a"]; }); | ||
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_8__common_thread_pool_thread_pool__, "IThreadPool")) __webpack_require__.d(exports, "k", function() { return __WEBPACK_IMPORTED_MODULE_8__common_thread_pool_thread_pool__["IThreadPool"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "l", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["b"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "m", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["c"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "n", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["d"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "o", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["e"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "p", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["f"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "q", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["g"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "r", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["h"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "s", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["i"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "t", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["j"]; }); | ||
/* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "u", function() { return __WEBPACK_IMPORTED_MODULE_9__common_parallel_index__["k"]; }); | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = isSerializedFunctionCall; | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Tests if the given object is a serialized function call | ||
* @param potentialFunc a potentially serialized function call | ||
* @returns {boolean} true if it is a serialized function call, false otherwise | ||
*/ | ||
function isSerializedFunctionCall(potentialFunc) { | ||
return !!potentialFunc && potentialFunc.______serializedFunctionCall === true; | ||
} | ||
/***/ }, | ||
/* 7 */, | ||
/* 8 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* @module parallel | ||
*/ | ||
/** needed, typedoc issue */ | ||
/***/ }, | ||
/* 10 */ | ||
9, | ||
/* 11 */ | ||
9, | ||
/* 12 */ | ||
/***/ function(module, exports) { | ||
/***/ }, | ||
/* 13 */ | ||
9, | ||
/* 14 */ | ||
9, | ||
/* 15 */ | ||
9, | ||
/* 16 */ | ||
9, | ||
/* 17 */ | ||
8, | ||
/* 18 */ | ||
8, | ||
/* 19 */ | ||
9, | ||
/* 20 */, | ||
/* 21 */, | ||
/* 22 */, | ||
/* 23 */, | ||
/* 24 */, | ||
/* 25 */, | ||
/* 26 */, | ||
/* 27 */, | ||
/* 28 */, | ||
/* 29 */, | ||
/* 30 */, | ||
/* 31 */, | ||
/* 32 */, | ||
/* 33 */, | ||
/* 34 */, | ||
/* 35 */, | ||
/* 36 */, | ||
/* 37 */, | ||
/* 38 */, | ||
/* 39 */, | ||
/* 40 */, | ||
/* 41 */, | ||
/* 42 */, | ||
/* 43 */, | ||
/* 44 */, | ||
/* 45 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__shared__ = __webpack_require__(5); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallel", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["a"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ITaskDefinition", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["b"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ITask", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["c"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IFunctionDefinition", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["d"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IFunctionId", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["e"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "isFunctionId", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["f"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "FunctionCall", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["g"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ISerializedFunctionCall", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["h"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "isSerializedFunctionCall", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["i"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "FunctionCallSerializer", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["j"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IThreadPool", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["k"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelChain", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["l"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelTaskEnvironment", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["m"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelEnvironment", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["n"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelJob", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["o"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelOptions", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["p"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IDefaultInitializedParallelOptions", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["q"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelJobScheduler", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["r"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelOperation", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["s"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ISerializedParallelOperation", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["t"]; }); | ||
/* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IParallelStream", function() { return __WEBPACK_IMPORTED_MODULE_0__shared__["u"]; }); | ||
/***/ } | ||
/******/ ]))) | ||
}); | ||
; | ||
(function(e,f){'object'==typeof exports&&'object'==typeof module?module.exports=f():'function'==typeof define&&define.amd?define([],f):'object'==typeof exports?exports['parallel-es']=f():e['parallel-es']=f()})(this,function(){return function(d){function e(g){if(f[g])return f[g].exports;var h=f[g]={i:g,l:!1,exports:{}};return d[g].call(h.exports,h,h.exports,e),h.l=!0,h.exports}var f={};return e.m=d,e.c=f,e.i=function(g){return g},e.d=function(g,h,j){Object.defineProperty(g,h,{configurable:!1,enumerable:!0,get:j})},e.n=function(g){var h=g&&g.__esModule?function(){return g['default']}:function(){return g};return e.d(h,'a',h),h},e.o=function(g,h){return Object.prototype.hasOwnProperty.call(g,h)},e.p='',e(e.s=45)}(function(d){for(var e in d)if(Object.prototype.hasOwnProperty.call(d,e))switch(typeof d[e]){case'function':break;case'object':d[e]=function(f){var g=f.slice(1),h=d[f[0]];return function(j,k,l){h.apply(this,[j,k,l].concat(g))}}(d[e]);break;default:d[e]=d[d[e]];}return d}([function(d,e){'use strict';class f{constructor(g,h){this.func=g,this.params=h}static create(g,...h){return new f(g,h)}static createUnchecked(g,...h){return new f(g,h)}}e.a=f},function(d,e){'use strict';e.a=function(g,h){return{_______isFunctionId:!0,identifier:`${g}-${h}`}},e.b=function(g){return!!g&&!0===g._______isFunctionId}},function(d,e,f){'use strict';var g=f(14);f.n(g);var h=f(9);f.n(h);var j=f(10);f.n(j);var k=f(11);f.n(k);var l=f(13);f.n(l);var m=f(15);f.n(m);var n=f(12);f.n(n);var o=f(16);f.n(o),f.o(g,'IParallel')&&f.d(e,'a',function(){return g.IParallel}),f.o(h,'IParallelChain')&&f.d(e,'b',function(){return h.IParallelChain}),f.o(j,'IParallelTaskEnvironment')&&f.d(e,'c',function(){return j.IParallelTaskEnvironment}),f.o(j,'IParallelEnvironment')&&f.d(e,'d',function(){return j.IParallelEnvironment}),f.o(k,'IParallelJob')&&f.d(e,'e',function(){return k.IParallelJob}),f.o(l,'IParallelOptions')&&f.d(e,'f',function(){return l.IParallelOptions}),f.o(l,'IDefaultInitializedParallelOptions')&&f.d(e,'g',function(){return l.IDefaultInitializedParallelOptions}),f.o(m,'IParallelJobScheduler')&&f.d(e,'h',function(){return m.IParallelJobScheduler}),f.o(n,'IParallelOperation')&&f.d(e,'i',function(){return n.IParallelOperation}),f.o(n,'ISerializedParallelOperation')&&f.d(e,'j',function(){return n.ISerializedParallelOperation}),f.o(o,'IParallelStream')&&f.d(e,'k',function(){return o.IParallelStream})},,function(d,e){'use strict';e.a=class{constructor(g){this.functionRegistry=g}serializeFunctionCall(g){const h=this.functionRegistry.getOrSetId(g.func);return{______serializedFunctionCall:!0,functionId:h,parameters:g.params}}}},function(d,e,f){'use strict';var g=f(2),h=f(17);f.n(h);var j=f(18);f.n(j);var k=f(8);f.n(k);var l=f(1),m=f(0),n=f(6),o=f(4),p=f(19);f.n(p);var q=f(2);f.d(e,'a',function(){return g.a}),f.o(h,'ITaskDefinition')&&f.d(e,'b',function(){return h.ITaskDefinition}),f.o(j,'ITask')&&f.d(e,'c',function(){return j.ITask}),f.o(k,'IFunctionDefinition')&&f.d(e,'d',function(){return k.IFunctionDefinition}),f.d(e,'e',function(){return l.IFunctionId}),f.d(e,'f',function(){return l.b}),f.d(e,'g',function(){return m.a}),f.d(e,'h',function(){return n.ISerializedFunctionCall}),f.d(e,'i',function(){return n.a}),f.d(e,'j',function(){return o.a}),f.o(p,'IThreadPool')&&f.d(e,'k',function(){return p.IThreadPool}),f.d(e,'l',function(){return q.b}),f.d(e,'m',function(){return q.c}),f.d(e,'n',function(){return q.d}),f.d(e,'o',function(){return q.e}),f.d(e,'p',function(){return q.f}),f.d(e,'q',function(){return q.g}),f.d(e,'r',function(){return q.h}),f.d(e,'s',function(){return q.i}),f.d(e,'t',function(){return q.j}),f.d(e,'u',function(){return q.k})},function(d,e){'use strict';e.a=function(g){return!!g&&!0===g.______serializedFunctionCall}},,function(){},function(){},9,9,function(){},9,9,9,9,8,8,9,,,,,,,,,,,,,,,,,,,,,,,,,,function(d,e,f){'use strict';var g=f(5);f.d(e,'IParallel',function(){return g.a}),f.d(e,'ITaskDefinition',function(){return g.b}),f.d(e,'ITask',function(){return g.c}),f.d(e,'IFunctionDefinition',function(){return g.d}),f.d(e,'IFunctionId',function(){return g.e}),f.d(e,'isFunctionId',function(){return g.f}),f.d(e,'FunctionCall',function(){return g.g}),f.d(e,'ISerializedFunctionCall',function(){return g.h}),f.d(e,'isSerializedFunctionCall',function(){return g.i}),f.d(e,'FunctionCallSerializer',function(){return g.j}),f.d(e,'IThreadPool',function(){return g.k}),f.d(e,'IParallelChain',function(){return g.l}),f.d(e,'IParallelTaskEnvironment',function(){return g.m}),f.d(e,'IParallelEnvironment',function(){return g.n}),f.d(e,'IParallelJob',function(){return g.o}),f.d(e,'IParallelOptions',function(){return g.p}),f.d(e,'IDefaultInitializedParallelOptions',function(){return g.q}),f.d(e,'IParallelJobScheduler',function(){return g.r}),f.d(e,'IParallelOperation',function(){return g.s}),f.d(e,'ISerializedParallelOperation',function(){return g.t}),f.d(e,'IParallelStream',function(){return g.u})}]))});; | ||
//# sourceMappingURL=node.parallel-es6.js.map |
@@ -1,948 +0,2 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // identity function for calling harmory imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // define getter function for harmory exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 17); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["b"] = toIterator; | ||
/* harmony export (immutable) */ exports["a"] = toArray; | ||
/* unused harmony export flattenArray */ | ||
/* unused harmony export concatInPlace */ | ||
/** | ||
* Creates an iterator that iterates over the given array | ||
* @param data the array | ||
* @param T element type | ||
* @returns the iterator | ||
*/ | ||
function toIterator(data) { | ||
return data[Symbol.iterator](); | ||
} | ||
/** | ||
* Converts the given iterator to an array | ||
* @param iterator the iterator that is to be converted into an array | ||
* @param T element type | ||
* @returns {T[]} the array representation of the given iterator | ||
*/ | ||
function toArray(iterator) { | ||
const result = []; | ||
let current; | ||
/* tslint:disable:no-conditional-assignment */ | ||
while (!(current = iterator.next()).done) { | ||
result.push(current.value); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Flattens the given array. | ||
* @param deepArray the array to flatten | ||
* @param type of the array elements | ||
* @returns returns an array containing all the values contained in the sub arrays of deep array. | ||
*/ | ||
function flattenArray(deepArray) { | ||
if (deepArray.length === 0) { | ||
return []; | ||
} | ||
const [head, ...tail] = deepArray; | ||
return Array.prototype.concat.apply(head, tail); | ||
} | ||
function concatInPlace(target, toAppend) { | ||
const insertionIndex = target.length; | ||
target.length += toAppend.length; | ||
for (let i = 0; i < toAppend.length; ++i) { | ||
target[insertionIndex + i] = toAppend[i]; | ||
} | ||
return target; | ||
} | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = isSerializedFunctionCall; | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Tests if the given object is a serialized function call | ||
* @param potentialFunc a potentially serialized function call | ||
* @returns {boolean} true if it is a serialized function call, false otherwise | ||
*/ | ||
function isSerializedFunctionCall(potentialFunc) { | ||
return !!potentialFunc && potentialFunc.______serializedFunctionCall === true; | ||
} | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* unused harmony export WorkerMessageType */ | ||
/* unused harmony export initializeWorkerMessage */ | ||
/* unused harmony export scheduleTaskMessage */ | ||
/* harmony export (immutable) */ exports["c"] = requestFunctionMessage; | ||
/* unused harmony export functionResponseMessage */ | ||
/* harmony export (immutable) */ exports["f"] = workerResultMessage; | ||
/* harmony export (immutable) */ exports["e"] = functionExecutionError; | ||
/* unused harmony export stopMessage */ | ||
/* harmony export (immutable) */ exports["b"] = isScheduleTask; | ||
/* harmony export (immutable) */ exports["a"] = isInitializeMessage; | ||
/* unused harmony export isFunctionRequest */ | ||
/* harmony export (immutable) */ exports["d"] = isFunctionResponse; | ||
/* unused harmony export isWorkerResult */ | ||
/* unused harmony export isFunctionExecutionError */ | ||
/* harmony export (immutable) */ exports["g"] = isStopMesssage; | ||
/** | ||
* Message types | ||
*/ | ||
var WorkerMessageType; | ||
(function (WorkerMessageType) { | ||
/** | ||
* Sent from the worker facade to the worker slave to initialize the slave. | ||
*/ | ||
WorkerMessageType[WorkerMessageType["InitializeWorker"] = 0] = "InitializeWorker"; | ||
/** | ||
* Sent from the worker facade to the worker slave to schedule a new task on the slave. | ||
*/ | ||
WorkerMessageType[WorkerMessageType["ScheduleTask"] = 1] = "ScheduleTask"; | ||
/** | ||
* Send from the worker slave to the worker thread to request the definition of a function needed to execute a scheduled task | ||
*/ | ||
WorkerMessageType[WorkerMessageType["FunctionRequest"] = 2] = "FunctionRequest"; | ||
/** | ||
* Send from the worker thread to the worker slave as response to a {@link WorkerMessageType.FunctionRequest}. Includes | ||
* the definitions of all requested functions | ||
*/ | ||
WorkerMessageType[WorkerMessageType["FunctionResponse"] = 3] = "FunctionResponse"; | ||
/** | ||
* Sent from the worker slave to the worker thread containing the computed result | ||
*/ | ||
WorkerMessageType[WorkerMessageType["WorkerResult"] = 4] = "WorkerResult"; | ||
/** | ||
* Sent from the worker slave to the worker thread for the case an error occurred during the evaluation of the scheduled task. | ||
*/ | ||
WorkerMessageType[WorkerMessageType["FunctionExecutionError"] = 5] = "FunctionExecutionError"; | ||
/** | ||
* Sent from the worker thread to the worker slave to request the slave to terminate. | ||
*/ | ||
WorkerMessageType[WorkerMessageType["Stop"] = 6] = "Stop"; | ||
})(WorkerMessageType || (WorkerMessageType = {})); | ||
/** | ||
* Creates an initialize worker message | ||
* @param id the unique id of the worker | ||
* @returns the initialize worker message | ||
*/ | ||
function initializeWorkerMessage(id) { | ||
return { type: WorkerMessageType.InitializeWorker, workerId: id }; | ||
} | ||
/** | ||
* Creates a message to schedule the given task on a worker slave | ||
* @param task the task to schedule | ||
* @returns the schedule message | ||
*/ | ||
function scheduleTaskMessage(task) { | ||
return { task, type: WorkerMessageType.ScheduleTask }; | ||
} | ||
/** | ||
* Creates an {@link IFunctionRequest} message that requests the given function ids from the worker thread | ||
* @param functionId the id of a function to request | ||
* @param otherFunctionIds additional ids to request from the worker slave | ||
* @returns the function request message | ||
*/ | ||
function requestFunctionMessage(functionId, ...otherFunctionIds) { | ||
return { functionIds: [functionId, ...otherFunctionIds], type: WorkerMessageType.FunctionRequest }; | ||
} | ||
/** | ||
* Creates a function response message containing the passed function definitions | ||
* @param functions the function definitions to respond to the worker slave | ||
* @returns the function response message | ||
*/ | ||
function functionResponseMessage(functions, ...missingFunctionIds) { | ||
return { functions, missingFunctions: missingFunctionIds, type: WorkerMessageType.FunctionResponse }; | ||
} | ||
/** | ||
* Creates a worker result message for the given result | ||
* @param result the computed result for the scheduled task | ||
* @returns the message | ||
*/ | ||
function workerResultMessage(result) { | ||
return { result, type: WorkerMessageType.WorkerResult }; | ||
} | ||
/** | ||
* Creates a function execution error message containing the given error | ||
* @param error the error object thrown by the task computation | ||
* @returns the message | ||
*/ | ||
function functionExecutionError(error) { | ||
let errorObject = {}; | ||
for (const prop of Object.getOwnPropertyNames(error)) { | ||
errorObject[prop] = JSON.stringify(error[prop]); | ||
} | ||
return { error: errorObject, type: WorkerMessageType.FunctionExecutionError }; | ||
} | ||
/** | ||
* Creates a stop message | ||
* @returns the message | ||
*/ | ||
function stopMessage() { | ||
return { type: WorkerMessageType.Stop }; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IScheduleTaskMessage} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IScheduleTaskMessage} | ||
*/ | ||
function isScheduleTask(message) { | ||
return message.type === WorkerMessageType.ScheduleTask; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IInitializeWorkerMessage} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IInitializeWorkerMessage} | ||
*/ | ||
function isInitializeMessage(message) { | ||
return message.type === WorkerMessageType.InitializeWorker; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IFunctionRequest} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IFunctionRequest} | ||
*/ | ||
function isFunctionRequest(message) { | ||
return message.type === WorkerMessageType.FunctionRequest; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IFunctionResponse} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IFunctionResponse} | ||
*/ | ||
function isFunctionResponse(message) { | ||
return message.type === WorkerMessageType.FunctionResponse; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IWorkerResultMessage} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IWorkerResultMessage} | ||
*/ | ||
function isWorkerResult(message) { | ||
return message.type === WorkerMessageType.WorkerResult; | ||
} | ||
/** | ||
* Tests if the given message is an {@link IFunctionExecutionError} message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is an {@link IFunctionExecutionError} | ||
*/ | ||
function isFunctionExecutionError(message) { | ||
return message.type === WorkerMessageType.FunctionExecutionError; | ||
} | ||
/** | ||
* Tests if the given message is a stop message | ||
* @param message the message to test | ||
* @returns {boolean} {@code true} if the message is a stop message | ||
*/ | ||
function isStopMesssage(message) { | ||
return message.type === WorkerMessageType.Stop; | ||
} | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_worker_worker_messages__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__browser_worker_slave_states__ = __webpack_require__(6); | ||
/** | ||
* Worker thread endpoint executed in the web worker thread. | ||
* Executes the tasks assigned by the thread pool via the {@link BrowserWorkerThread}. | ||
*/ | ||
class BrowserWorkerSlave { | ||
constructor(functionCache) { | ||
this.functionCache = functionCache; | ||
/** | ||
* The unique id of the slave instance | ||
*/ | ||
this.id = Number.NaN; | ||
this.state = new __WEBPACK_IMPORTED_MODULE_1__browser_worker_slave_states__["a" /* DefaultBrowserWorkerSlaveState */](this); | ||
} | ||
/** | ||
* Changes the state of the slave to the new state | ||
* @param state the new state to assign | ||
*/ | ||
changeState(state) { | ||
this.state = state; | ||
this.state.enter(); | ||
} | ||
/** | ||
* Executed when the slave receives a message from the ui-thread | ||
* @param event the received message | ||
*/ | ||
onMessage(event) { | ||
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__common_worker_worker_messages__["g" /* isStopMesssage */])(event.data)) { | ||
close(); | ||
} | ||
else if (!this.state.onMessage(event)) { | ||
throw new Error(`Message with type ${event.data.type} cannot be handled by slave ${this}`); | ||
} | ||
} | ||
postMessage(message) { | ||
postMessage(message); | ||
} | ||
toString() { | ||
return `BrowserSlave { id: ${this.id}, state: '${this.state.name}' }`; | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = BrowserWorkerSlave; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_simple_map__ = __webpack_require__(16); | ||
/** | ||
* Cache used by each worker slave to cache the received functions. | ||
* Caching the functions has the advantage that function only is serialized, transmitted and deserialized once. This also | ||
* has the advantage, that the function instance stays the same and therefore can be optimized by the runtime system. | ||
*/ | ||
class SlaveFunctionLookupTable { | ||
constructor() { | ||
this.cache = new __WEBPACK_IMPORTED_MODULE_0__util_simple_map__["a" /* SimpleMap */](); | ||
} | ||
/** | ||
* Resolves the funciton with the givne id | ||
* @param id the id of the function to resolve | ||
* @returns the resolved function or undefined if not known | ||
*/ | ||
getFunction(id) { | ||
return this.cache.get(id.identifier); | ||
} | ||
/** | ||
* Registers a new function in the cache | ||
* @param definition the definition of the function to register | ||
* @returns the registered function | ||
*/ | ||
registerFunction(definition) { | ||
const f = Function.apply(null, [...definition.argumentNames, definition.body]); | ||
this.cache.set(definition.id.identifier, f); | ||
return f; | ||
} | ||
registerStaticFunction(id, func) { | ||
if (this.has(id)) { | ||
throw new Error(`The given function id '${id.identifier}' is already used by another function registration, the id needs to be unique.`); | ||
} | ||
this.cache.set(id.identifier, func); | ||
} | ||
/** | ||
* Tests if the cache contains a function with the given id | ||
* @param id the id of the function to test for existence | ||
* @returns true if the cache contains a function with the given id | ||
*/ | ||
has(id) { | ||
return this.cache.has(id.identifier); | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = SlaveFunctionLookupTable; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__ = __webpack_require__(12); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_identity__ = __webpack_require__(15); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__filter_iterator__ = __webpack_require__(9); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__map_iterator__ = __webpack_require__(10); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__parallel_job_executor__ = __webpack_require__(11); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__range_iterator__ = __webpack_require__(13); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__reduce_iterator__ = __webpack_require__(14); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_arrays__ = __webpack_require__(0); | ||
/* harmony export (immutable) */ exports["a"] = registerStaticParallelFunctions; | ||
/** | ||
* Registers the static parallel functions | ||
* @param lookupTable the table into which the function should be registered | ||
*/ | ||
function registerStaticParallelFunctions(lookupTable) { | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].IDENTITY, __WEBPACK_IMPORTED_MODULE_1__util_identity__["a" /* identity */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].FILTER, __WEBPACK_IMPORTED_MODULE_2__filter_iterator__["a" /* filterIterator */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].MAP, __WEBPACK_IMPORTED_MODULE_3__map_iterator__["a" /* mapIterator */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].PARALLEL_JOB_EXECUTOR, __WEBPACK_IMPORTED_MODULE_4__parallel_job_executor__["a" /* parallelJobExecutor */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].RANGE, __WEBPACK_IMPORTED_MODULE_5__range_iterator__["a" /* rangeIterator */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].REDUCE, __WEBPACK_IMPORTED_MODULE_6__reduce_iterator__["a" /* reduceIterator */]); | ||
lookupTable.registerStaticFunction(__WEBPACK_IMPORTED_MODULE_0__parallel_worker_functions__["a" /* ParallelWorkerFunctionIds */].TO_ITERATOR, __WEBPACK_IMPORTED_MODULE_7__util_arrays__["b" /* toIterator */]); | ||
} | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_function_function_call_deserializer__ = __webpack_require__(7); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__ = __webpack_require__(2); | ||
/** | ||
* State of the browser worker slave. | ||
*/ | ||
class BrowserWorkerSlaveState { | ||
constructor(name, slave) { | ||
this.name = name; | ||
this.slave = slave; | ||
} | ||
/** | ||
* Executed when the slave changes its state to this state. | ||
*/ | ||
enter() { | ||
// intentionally empty | ||
} | ||
/** | ||
* Executed whenever the slave receives a message from the ui-thread while being in this state | ||
* @param event the received message | ||
* @returns {boolean} true if the state has handled the message, false otherwise | ||
*/ | ||
onMessage(event) { return false; } | ||
} | ||
/* unused harmony export BrowserWorkerSlaveState */ | ||
/** | ||
* Initial state of a slave. The slave is waiting for the initialization message. | ||
*/ | ||
class DefaultBrowserWorkerSlaveState extends BrowserWorkerSlaveState { | ||
constructor(slave) { | ||
super("Default", slave); | ||
} | ||
onMessage(event) { | ||
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["a" /* isInitializeMessage */])(event.data)) { | ||
this.slave.id = event.data.workerId; | ||
this.slave.changeState(new IdleBrowserWorkerSlaveState(this.slave)); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = DefaultBrowserWorkerSlaveState; | ||
/** | ||
* The slave is waiting for work from the ui-thread. | ||
*/ | ||
class IdleBrowserWorkerSlaveState extends BrowserWorkerSlaveState { | ||
constructor(slave) { | ||
super("Idle", slave); | ||
} | ||
onMessage(event) { | ||
if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["b" /* isScheduleTask */])(event.data)) { | ||
return false; | ||
} | ||
const task = event.data.task; | ||
const missingFunctions = task.usedFunctionIds.filter(id => !this.slave.functionCache.has(id)); | ||
if (missingFunctions.length === 0) { | ||
this.slave.changeState(new ExecuteFunctionBrowserWorkerSlaveState(this.slave, task)); | ||
} | ||
else { | ||
const [head, ...tail] = missingFunctions; | ||
this.slave.postMessage(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["c" /* requestFunctionMessage */])(head, ...tail)); | ||
this.slave.changeState(new WaitingForFunctionDefinitionBrowserWorkerSlaveState(this.slave, task)); | ||
} | ||
return true; | ||
} | ||
} | ||
/* unused harmony export IdleBrowserWorkerSlaveState */ | ||
/** | ||
* The slave is waiting for the definition of the requested function that is needed to execute the assigned task. | ||
*/ | ||
class WaitingForFunctionDefinitionBrowserWorkerSlaveState extends BrowserWorkerSlaveState { | ||
constructor(slave, task) { | ||
super("WaitingForFunctionDefinition", slave); | ||
this.task = task; | ||
} | ||
onMessage(event) { | ||
const message = event.data; | ||
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["d" /* isFunctionResponse */])(message)) { | ||
if (message.missingFunctions.length > 0) { | ||
const identifiers = message.missingFunctions.map(functionId => functionId.identifier).join(", "); | ||
this.slave.postMessage(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["e" /* functionExecutionError */])(new Error(`The function ids [${identifiers}] could not be resolved by slave ${this.slave.id}.`))); | ||
this.slave.changeState(new IdleBrowserWorkerSlaveState(this.slave)); | ||
} | ||
else { | ||
for (const definition of message.functions) { | ||
this.slave.functionCache.registerFunction(definition); | ||
} | ||
this.slave.changeState(new ExecuteFunctionBrowserWorkerSlaveState(this.slave, this.task)); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
/* unused harmony export WaitingForFunctionDefinitionBrowserWorkerSlaveState */ | ||
/** | ||
* The slave is executing the function | ||
*/ | ||
class ExecuteFunctionBrowserWorkerSlaveState extends BrowserWorkerSlaveState { | ||
constructor(slave, task) { | ||
super("Executing", slave); | ||
this.task = task; | ||
} | ||
enter() { | ||
const functionDeserializer = new __WEBPACK_IMPORTED_MODULE_0__common_function_function_call_deserializer__["a" /* FunctionCallDeserializer */](this.slave.functionCache); | ||
try { | ||
const main = functionDeserializer.deserializeFunctionCall(this.task.main); | ||
const result = main({ functionCallDeserializer: functionDeserializer }); | ||
this.slave.postMessage(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["f" /* workerResultMessage */])(result)); | ||
} | ||
catch (error) { | ||
this.slave.postMessage(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_worker_worker_messages__["e" /* functionExecutionError */])(error)); | ||
} | ||
this.slave.changeState(new IdleBrowserWorkerSlaveState(this.slave)); | ||
} | ||
} | ||
/* unused harmony export ExecuteFunctionBrowserWorkerSlaveState */ | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__serialized_function_call__ = __webpack_require__(1); | ||
/** | ||
* Deserializer for a {@link ISerializedFunctionCall}. | ||
*/ | ||
class FunctionCallDeserializer { | ||
/** | ||
* Creates a new deserializer that uses the given function lookup table to retrieve the function for a given id | ||
* @param functionLookupTable the lookup table to use | ||
*/ | ||
constructor(functionLookupTable) { | ||
this.functionLookupTable = functionLookupTable; | ||
} | ||
/** | ||
* Deserializes the function call into a function | ||
* @param functionCall the function call to deserialize | ||
* @param deserializeParams indicator if the parameters passed to the serialized function should be deserailized too | ||
* @returns a function that can be called with additional parameters (the params from the serialized function calls are prepended to the passed parameters) | ||
*/ | ||
deserializeFunctionCall(functionCall, deserializeParams = false) { | ||
const func = this.functionLookupTable.getFunction(functionCall.functionId); | ||
if (!func) { | ||
throw new Error(`The function with the id ${functionCall.functionId.identifier} could not be retrieved while deserializing the function call. Is the function correctly registered?`); | ||
} | ||
let params = functionCall.parameters || []; | ||
if (deserializeParams) { | ||
params = params.map(param => { | ||
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__serialized_function_call__["a" /* isSerializedFunctionCall */])(param)) { | ||
return this.deserializeFunctionCall(param); | ||
} | ||
return param; | ||
}); | ||
} | ||
return function (...additionalParams) { | ||
return func.apply(undefined, params.concat(additionalParams)); | ||
}; | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = FunctionCallDeserializer; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = functionId; | ||
/* unused harmony export isFunctionId */ | ||
/** | ||
* @module parallel | ||
*/ | ||
/** */ | ||
/** | ||
* Creates a function id | ||
* @param namespace the namespace of the id | ||
* @param id the unique id for this namespace | ||
* @returns the function id | ||
*/ | ||
function functionId(namespace, id) { | ||
return { | ||
_______isFunctionId: true, | ||
identifier: `${namespace}-${id}` | ||
}; | ||
} | ||
/** | ||
* Tests if the given object is a function id | ||
* @param obj the object to test for | ||
* @returns true if the object is a function id | ||
*/ | ||
function isFunctionId(obj) { | ||
return !!obj && obj._______isFunctionId === true; | ||
} | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = filterIterator; | ||
/** | ||
* Returns a new iterator that only contains all elements for which the given predicate returns true | ||
* @param iterator the iterator to filter | ||
* @param predicate the predicate to use for filtering the elements | ||
* @param env the environment of the job | ||
* @param T type of the elements to filter | ||
* @returns an iterator only containing the elements where the predicate is true | ||
*/ | ||
function filterIterator(iterator, predicate, env) { | ||
return { | ||
next() { | ||
let current; | ||
/* tslint:disable:no-conditional-assignment */ | ||
while (!(current = iterator.next()).done) { | ||
if (predicate(current.value, env)) { | ||
return current; | ||
} | ||
} | ||
return current; | ||
} | ||
}; | ||
} | ||
/***/ }, | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = mapIterator; | ||
/** | ||
* Performs the map operation | ||
* @param iterator the iterator of the previous step | ||
* @param iteratee the iteratee to apply to each element in the iterator | ||
* @param env the environment of the job | ||
* @param T the type of the input elements | ||
* @param TResult the type of the returned element of the iteratee | ||
* @returns a new iterator where each element has been mapped using the iteratee | ||
*/ | ||
function mapIterator(iterator, iteratee, env) { | ||
return { | ||
next() { | ||
const result = iterator.next(); | ||
if (result.done) { | ||
return { done: true }; | ||
} | ||
return { | ||
done: result.done, | ||
value: iteratee(result.value, env) | ||
}; | ||
} | ||
}; | ||
} | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_arrays__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__function_serialized_function_call__ = __webpack_require__(1); | ||
/* harmony export (immutable) */ exports["a"] = parallelJobExecutor; | ||
function createTaskEnvironment(definition, functionCallDeserializer) { | ||
let taskEnvironment = {}; | ||
for (const environment of definition.environments) { | ||
let currentEnvironment; | ||
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__function_serialized_function_call__["a" /* isSerializedFunctionCall */])(environment)) { | ||
currentEnvironment = functionCallDeserializer.deserializeFunctionCall(environment)(); | ||
} | ||
else { | ||
currentEnvironment = environment; | ||
} | ||
Object.assign(taskEnvironment, currentEnvironment); | ||
} | ||
return Object.assign({}, { taskIndex: definition.taskIndex, valuesPerTask: definition.valuesPerTask }, taskEnvironment); | ||
} | ||
/** | ||
* Main coordination function for any operation performed using {@link IParallel}. | ||
* @param definition the definition of the operation to performed | ||
* @param options options passed from the thread pool | ||
* @param T type of the elements created by the generator | ||
* @param TResult type of the resulting elements | ||
* @returns the result of the operation from this worker | ||
*/ | ||
function parallelJobExecutor(definition, { functionCallDeserializer }) { | ||
const environment = createTaskEnvironment(definition, functionCallDeserializer); | ||
const generatorFunction = functionCallDeserializer.deserializeFunctionCall(definition.generator, true); | ||
let iterator = generatorFunction(environment); | ||
for (const operation of definition.operations) { | ||
const iteratorFunction = functionCallDeserializer.deserializeFunctionCall(operation.iterator); | ||
const iteratee = functionCallDeserializer.deserializeFunctionCall(operation.iteratee); | ||
iterator = iteratorFunction(iterator, iteratee, environment); | ||
} | ||
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__util_arrays__["a" /* toArray */])(iterator); | ||
} | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__function_function_id__ = __webpack_require__(8); | ||
const ParallelWorkerFunctionIds = { | ||
FILTER: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 0), | ||
IDENTITY: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 1), | ||
MAP: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 2), | ||
PARALLEL_JOB_EXECUTOR: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 3), | ||
RANGE: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 4), | ||
REDUCE: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 5), | ||
TIMES: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 6), | ||
TO_ITERATOR: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__function_function_id__["a" /* functionId */])("parallel", 7) | ||
}; | ||
/* harmony export (immutable) */ exports["a"] = ParallelWorkerFunctionIds; | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = rangeIterator; | ||
/** | ||
* Generator function that creates an iterator containing all elements in the range [start, end) with a step size of step. | ||
* @param start start value of the range (inclusive) | ||
* @param end end value of the range (exclusive) | ||
* @param step step size between two values | ||
* @returns iterator with the values [start, end) | ||
*/ | ||
function rangeIterator(start, end, step) { | ||
const distance = end - start; | ||
let length = Math.max(Math.floor(distance / (step || 1)), 0); | ||
let next = start; | ||
return { | ||
next() { | ||
let current = next; | ||
next = next + step; | ||
if (length-- !== 0) { | ||
return { done: false, value: current }; | ||
} | ||
return { done: true }; | ||
} | ||
}; | ||
} | ||
/***/ }, | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_arrays__ = __webpack_require__(0); | ||
/* harmony export (immutable) */ exports["a"] = reduceIterator; | ||
/** | ||
* Reduces the elements of the given iterator to a single value by applying the given iteratee to each element | ||
* @param defaultValue a default value that is as accumulator or for the case that the iterator is empty | ||
* @param iterator the iterator with the values to reduce | ||
* @param iteratee iteratee that is applied for each element. The iteratee is passed the accumulated value (sum of all previous values) | ||
* and the current element and has to return a new accumulated value. | ||
* @param env the environment of the job | ||
* @param T type of the elements to process | ||
* @param TResult type of the reduced value | ||
* @returns an array with a single value, the reduced value | ||
*/ | ||
function reduceIterator(defaultValue, iterator, iteratee, env) { | ||
let accumulatedValue = defaultValue; | ||
let current; | ||
/* tslint:disable:no-conditional-assignment */ | ||
while (!(current = iterator.next()).done) { | ||
accumulatedValue = iteratee(accumulatedValue, current.value, env); | ||
} | ||
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__util_arrays__["b" /* toIterator */])([accumulatedValue]); | ||
} | ||
/***/ }, | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (immutable) */ exports["a"] = identity; | ||
/** | ||
* identity function. Returns the passed in value | ||
* @param element the value to return | ||
* @param T type of the element | ||
*/ | ||
function identity(element) { | ||
return element; | ||
} | ||
/***/ }, | ||
/* 16 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* A very simple implementation of a map. Do not use with complex objects as Key. | ||
* @param K type of the key | ||
* @param V type of the value | ||
*/ | ||
class SimpleMap { | ||
constructor() { | ||
this.data = {}; | ||
} | ||
/** | ||
* Gets the value for the given key if available | ||
* @param key the key to look up | ||
* @returns the looked up value or undefined if the map does not contain any value associated with the given key | ||
*/ | ||
get(key) { | ||
const internalKey = this.toInternalKey(key); | ||
return this.has(key) ? this.data[internalKey] : undefined; | ||
} | ||
/** | ||
* Tests if the map contains value stored by the given key | ||
* @param key the key | ||
* @returns true if the map contains a value by the given key, false otherwise | ||
*/ | ||
has(key) { | ||
return this.hasOwnProperty.call(this.data, this.toInternalKey(key)); | ||
} | ||
/** | ||
* Sets the value for the given key. If the map already contains a value stored by the given key, then this value is | ||
* overridden | ||
* @param key the key | ||
* @param value the value to associate with the given key | ||
*/ | ||
set(key, value) { | ||
this.data[this.toInternalKey(key)] = value; | ||
} | ||
/** | ||
* Clears all values from the map | ||
*/ | ||
clear() { | ||
this.data = {}; | ||
} | ||
toInternalKey(key) { | ||
return `@${key}`; | ||
} | ||
} | ||
/* harmony export (immutable) */ exports["a"] = SimpleMap; | ||
/***/ }, | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__browser_worker_slave__ = __webpack_require__(3); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_function_slave_function_lookup_table__ = __webpack_require__(4); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_parallel_slave_register_parallel_worker_functions__ = __webpack_require__(5); | ||
const slaveFunctionLookupTable = new __WEBPACK_IMPORTED_MODULE_1__common_function_slave_function_lookup_table__["a" /* SlaveFunctionLookupTable */](); | ||
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__common_parallel_slave_register_parallel_worker_functions__["a" /* registerStaticParallelFunctions */])(slaveFunctionLookupTable); | ||
/** @preserve WORKER_SLAVE_STATIC_FUNCTIONS_PLACEHOLDER */ | ||
const slave = new __WEBPACK_IMPORTED_MODULE_0__browser_worker_slave__["a" /* BrowserWorkerSlave */](slaveFunctionLookupTable); | ||
onmessage = function () { | ||
slave.onMessage.apply(slave, arguments); | ||
}; | ||
/***/ } | ||
/******/ ]); | ||
(function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.i=function(d){return d},b.d=function(d,e,g){Object.defineProperty(d,e,{configurable:!1,enumerable:!0,get:g})},b.n=function(d){var e=d&&d.__esModule?function(){return d['default']}:function(){return d};return b.d(e,'a',e),e},b.o=function(d,e){return Object.prototype.hasOwnProperty.call(d,e)},b.p='',b(b.s=17)})([function(a,b){'use strict';b.b=function(d){return d[Symbol.iterator]()},b.a=function(d){const e=[];for(let g;!(g=d.next()).done;)e.push(g.value);return e}},function(a,b){'use strict';b.a=function(d){return!!d&&!0===d.______serializedFunctionCall}},function(a,b){'use strict';b.c=function(e,...g){return{functionIds:[e,...g],type:c.FunctionRequest}},b.f=function(e){return{result:e,type:c.WorkerResult}},b.e=function(e){let g={};for(const h of Object.getOwnPropertyNames(e))g[h]=JSON.stringify(e[h]);return{error:g,type:c.FunctionExecutionError}},b.b=function(e){return e.type===c.ScheduleTask},b.a=function(e){return e.type===c.InitializeWorker},b.d=function(e){return e.type===c.FunctionResponse},b.g=function(e){return e.type===c.Stop};var c;(function(d){d[d.InitializeWorker=0]='InitializeWorker',d[d.ScheduleTask=1]='ScheduleTask',d[d.FunctionRequest=2]='FunctionRequest',d[d.FunctionResponse=3]='FunctionResponse',d[d.WorkerResult=4]='WorkerResult',d[d.FunctionExecutionError=5]='FunctionExecutionError',d[d.Stop=6]='Stop'})(c||(c={}))},function(a,b,c){'use strict';var d=c(2),e=c(6);b.a=class{constructor(h){this.functionCache=h,this.id=Number.NaN,this.state=new e.a(this)}changeState(h){this.state=h,this.state.enter()}onMessage(h){if(c.i(d.g)(h.data))close();else if(!this.state.onMessage(h))throw new Error(`Message with type ${h.data.type} cannot be handled by slave ${this}`)}postMessage(h){postMessage(h)}toString(){return`BrowserSlave { id: ${this.id}, state: '${this.state.name}' }`}}},function(a,b,c){'use strict';var d=c(16);b.a=class{constructor(){this.cache=new d.a}getFunction(g){return this.cache.get(g.identifier)}registerFunction(g){const h=Function.apply(null,[...g.argumentNames,g.body]);return this.cache.set(g.id.identifier,h),h}registerStaticFunction(g,h){if(this.has(g))throw new Error(`The given function id '${g.identifier}' is already used by another function registration, the id needs to be unique.`);this.cache.set(g.identifier,h)}has(g){return this.cache.has(g.identifier)}}},function(a,b,c){'use strict';var d=c(12),e=c(15),g=c(9),h=c(10),j=c(11),k=c(13),l=c(14),m=c(0);b.a=function(o){o.registerStaticFunction(d.a.IDENTITY,e.a),o.registerStaticFunction(d.a.FILTER,g.a),o.registerStaticFunction(d.a.MAP,h.a),o.registerStaticFunction(d.a.PARALLEL_JOB_EXECUTOR,j.a),o.registerStaticFunction(d.a.RANGE,k.a),o.registerStaticFunction(d.a.REDUCE,l.a),o.registerStaticFunction(d.a.TO_ITERATOR,m.b)}},function(a,b,c){'use strict';var d=c(7),e=c(2);class g{constructor(l,m){this.name=l,this.slave=m}enter(){}onMessage(){return!1}}b.a=class extends g{constructor(m){super('Default',m)}onMessage(m){return!!c.i(e.a)(m.data)&&(this.slave.id=m.data.workerId,this.slave.changeState(new h(this.slave)),!0)}};class h extends g{constructor(l){super('Idle',l)}onMessage(l){if(!c.i(e.b)(l.data))return!1;const m=l.data.task,n=m.usedFunctionIds.filter(o=>!this.slave.functionCache.has(o));if(0===n.length)this.slave.changeState(new k(this.slave,m));else{const[o,...p]=n;this.slave.postMessage(c.i(e.c)(o,...p)),this.slave.changeState(new j(this.slave,m))}return!0}}class j extends g{constructor(l,m){super('WaitingForFunctionDefinition',l),this.task=m}onMessage(l){const m=l.data;if(c.i(e.d)(m)){if(0<m.missingFunctions.length){const n=m.missingFunctions.map(o=>o.identifier).join(', ');this.slave.postMessage(c.i(e.e)(new Error(`The function ids [${n}] could not be resolved by slave ${this.slave.id}.`))),this.slave.changeState(new h(this.slave))}else{for(const n of m.functions)this.slave.functionCache.registerFunction(n);this.slave.changeState(new k(this.slave,this.task))}return!0}return!1}}class k extends g{constructor(l,m){super('Executing',l),this.task=m}enter(){const l=new d.a(this.slave.functionCache);try{const m=l.deserializeFunctionCall(this.task.main),n=m({functionCallDeserializer:l});this.slave.postMessage(c.i(e.f)(n))}catch(m){this.slave.postMessage(c.i(e.e)(m))}this.slave.changeState(new h(this.slave))}}},function(a,b,c){'use strict';var d=c(1);b.a=class{constructor(g){this.functionLookupTable=g}deserializeFunctionCall(g,h=!1){const j=this.functionLookupTable.getFunction(g.functionId);if(!j)throw new Error(`The function with the id ${g.functionId.identifier} could not be retrieved while deserializing the function call. Is the function correctly registered?`);let k=g.parameters||[];return h&&(k=k.map(l=>{return c.i(d.a)(l)?this.deserializeFunctionCall(l):l})),function(...l){return j.apply(void 0,k.concat(l))}}}},function(a,b){'use strict';b.a=function(d,e){return{_______isFunctionId:!0,identifier:`${d}-${e}`}}},function(a,b){'use strict';b.a=function(d,e,g){return{next(){let h;for(;!(h=d.next()).done;)if(e(h.value,g))return h;return h}}}},function(a,b){'use strict';b.a=function(d,e,g){return{next(){const h=d.next();return h.done?{done:!0}:{done:h.done,value:e(h.value,g)}}}}},function(a,b,c){'use strict';function d(h,j){let k={};for(const l of h.environments){let m;m=c.i(g.a)(l)?j.deserializeFunctionCall(l)():l,Object.assign(k,m)}return Object.assign({},{taskIndex:h.taskIndex,valuesPerTask:h.valuesPerTask},k)}var e=c(0),g=c(1);b.a=function(j,{functionCallDeserializer:k}){const l=d(j,k),m=k.deserializeFunctionCall(j.generator,!0);let n=m(l);for(const o of j.operations){const p=k.deserializeFunctionCall(o.iterator),q=k.deserializeFunctionCall(o.iteratee);n=p(n,q,l)}return c.i(e.a)(n)}},function(a,b,c){'use strict';var d=c(8);const e={FILTER:c.i(d.a)('parallel',0),IDENTITY:c.i(d.a)('parallel',1),MAP:c.i(d.a)('parallel',2),PARALLEL_JOB_EXECUTOR:c.i(d.a)('parallel',3),RANGE:c.i(d.a)('parallel',4),REDUCE:c.i(d.a)('parallel',5),TIMES:c.i(d.a)('parallel',6),TO_ITERATOR:c.i(d.a)('parallel',7)};b.a=e},function(a,b){'use strict';b.a=function(d,e,g){let h=Math.max(Math.floor((e-d)/(g||1)),0),j=d;return{next(){let k=j;return j=j+g,0==h--?{done:!0}:{done:!1,value:k}}}}},function(a,b,c){'use strict';var d=c(0);b.a=function(g,h,j,k){let l=g,m;for(;!(m=h.next()).done;)l=j(l,m.value,k);return c.i(d.b)([l])}},function(a,b){'use strict';b.a=function(d){return d}},function(a,b){'use strict';b.a=class{constructor(){this.data={}}get(d){const e=this.toInternalKey(d);return this.has(d)?this.data[e]:void 0}has(d){return this.hasOwnProperty.call(this.data,this.toInternalKey(d))}set(d,e){this.data[this.toInternalKey(d)]=e}clear(){this.data={}}toInternalKey(d){return`@${d}`}}},function(a,b,c){'use strict';var d=c(3),e=c(4),g=c(5);const slaveFunctionLookupTable=new e.a;c.i(g.a)(slaveFunctionLookupTable);/** @preserve WORKER_SLAVE_STATIC_FUNCTIONS_PLACEHOLDER */const h=new d.a(slaveFunctionLookupTable);onmessage=function(){h.onMessage.apply(h,arguments)}}]); | ||
//# sourceMappingURL=worker-slave.parallel-es6.js.map |
{ | ||
"name": "parallel-es", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Simple parallelization for EcmaScript", | ||
@@ -43,2 +43,4 @@ "main": "./dist/node.parallel.js", | ||
"babel-runtime": "6.18.0", | ||
"babili": "0.0.8", | ||
"babili-webpack-plugin": "0.0.6", | ||
"compression-webpack-plugin": "0.3.2", | ||
@@ -45,0 +47,0 @@ "copyfiles": "^1.0.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
2142200
34
8780