Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

threads

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

threads - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

4

CHANGELOG.md
# threads.js - Changelog
## 0.8.1
- Bug fix: Some outdated transpiled files were published as `v0.8.0`
## 0.8.0

@@ -4,0 +8,0 @@

@@ -432,6 +432,32 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./defaults":[function(require,module,exports){

Job.prototype.executeOn = function executeOn(thread) {
var _thread$once$once$run, _thread$once$once;
var _this2 = this,
_thread$on$once$once$,
_thread$on$once$once;
(_thread$once$once$run = (_thread$once$once = thread.once('message', this.emit.bind(this, 'done')).once('error', this.emit.bind(this, 'error'))).run.apply(_thread$once$once, this.runArgs)).send.apply(_thread$once$once$run, this.sendArgs);
var onProgress = function onProgress() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return _this2.emit.apply(_this2, ['progress'].concat(args));
};
var onMessage = function onMessage() {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
_this2.emit.apply(_this2, ['done'].concat(args));
thread.removeListener('progress', onProgress);
};
var onError = function onError() {
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
_this2.emit.apply(_this2, ['error'].concat(args));
thread.removeListener('progress', onProgress);
};
(_thread$on$once$once$ = (_thread$on$once$once = thread.on('progress', onProgress).once('message', onMessage).once('error', onError)).run.apply(_thread$on$once$once, this.runArgs)).send.apply(_thread$on$once$once$, this.sendArgs);
this.thread = thread;

@@ -443,3 +469,3 @@ this.emit('threadChanged');

Job.prototype.promise = function promise() {
var _this2 = this;
var _this3 = this;

@@ -449,8 +475,8 @@ // Always return a promise

// If the thread isn't set, listen for the threadChanged event
if (!_this2.thread) {
_this2.once('threadChanged', function () {
resolve(_this2.thread.promise());
if (!_this3.thread) {
_this3.once('threadChanged', function () {
resolve(_this3.thread.promise());
});
} else {
resolve(_this2.thread.promise());
resolve(_this3.thread.promise());
}

@@ -457,0 +483,0 @@ });

2

dist/threads.browser.min.js

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

require=function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({"./defaults":[function(e,t,n){"use strict";n.__esModule=!0,n.default={pool:{size:navigator.hardwareConcurrency||8}}},{}],"./worker":[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){return e&&t?"/"===e.charAt(e.length-1)||"/"===t.charAt(0)?e+t:e+"/"+t:e+t}function u(e){var t=(0,v.getConfig)().basepath.web;return t?a(t,e):e}function c(e){return Array.prototype.slice.call(e)}function f(e){if(e.stack)console.error(e.stack);else if(e.message&&e.filename&&e.lineno){var t=e.filename.match(/^data:text\/javascript/)&&e.filename.length>50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=e("eventemitter3"),h=r(p),d=e("./slave-code-uri"),y=r(d),v=e("../config");if("object"!==l(window.Worker)&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var g=function(e){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];o(this,t);var s=i(this,e.call(this));return s.currentRunnable=null,s.currentImportScripts=[],s.initWorker(),s.worker.addEventListener("message",s.handleMessage.bind(s)),s.worker.addEventListener("error",s.handleError.bind(s)),n&&s.run(n,r),s}return s(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(y.default)}catch(t){var e=(0,v.getConfig)().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(e)}},t.prototype.run=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.alreadyInitializedToRun(e,t)?this:("function"==typeof e?this.runMethod(e,t):this.runScripts(e,t),this.currentRunnable=e,this.currentImportScripts=t,this)},t.prototype.runMethod=function(e,t){var n=e.toString(),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(","),o=n.substring(n.indexOf("{")+1,n.lastIndexOf("}"));this.worker.postMessage({initByMethod:!0,method:{args:r,body:o},scripts:t.map(u)})},t.prototype.runScripts=function(e,t){if(!e)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:t.concat([e]).map(u)})},t.prototype.send=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.worker.postMessage({doRun:!0,param:e},t),this},t.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},t.prototype.promise=function(){var e=this;return new Promise(function(t,n){var r=void 0,o=void 0;r=function(n){e.removeListener("error",o),t(n)},o=function(t){e.removeListener("message",r),n(t)},e.once("message",r).once("error",o)})},t.prototype.alreadyInitializedToRun=function(e,t){var n=this.currentRunnable===e,r=this.currentImportScripts===t||0===t.length&&0===this.currentImportScripts.length;return n&&r},t.prototype.handleMessage=function(e){if(e.data.error)this.handleError(e.data.error);else if(e.data.progress)this.handleProgress(e.data.progress);else{var t=c(e.data.response);this.emit.apply(this,["message"].concat(t)),this.emit.apply(this,["done"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||f(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h.default);n.default=g},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],1:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./index"),s=r(i);"object"===("undefined"==typeof window?"undefined":o(window))&&(window.thread=s.default),"function"==typeof define?define([],function(){return s.default}):"object"===("undefined"==typeof t?"undefined":o(t))&&(t.exports=s.default)},{"./index":3}],2:[function(e,t,n){"use strict";function r(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];Object.keys(t).forEach(function(o){var i=t[o],a=n.concat([o]);if("object"===("undefined"==typeof i?"undefined":s(i))){if("undefined"!=typeof e[o]&&"object"!==s(e[o]))throw new Error("Expected config property not to be an object: "+a.join("."));r(e[o],i,a)}else{if("object"===s(e[o]))throw new Error("Expected config property to be an object: "+a.join("."));e[o]=i}})}function o(){return u.get()}function i(){return u.set.apply(u,arguments)}n.__esModule=!0;var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n.getConfig=o,n.setConfig=i;var a={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},u={get:function(){return a},set:function(e){if("object"!==("undefined"==typeof e?"undefined":s(e)))throw new Error("Expected config object.");r(a,e)}};n.default=u},{}],3:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new p.default(e,t)}n.__esModule=!0,n.Pool=n.defaults=n.config=void 0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),c=e("./pool"),f=r(c),l=e("./worker"),p=r(l);n.config=s.default,n.defaults=u.default,n.Pool=f.default,n.default={config:s.default,defaults:u.default,Pool:f.default,spawn:o,Worker:p.default}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a=e("eventemitter3"),u=r(a),c=function(e){function t(n){o(this,t);var r=i(this,e.call(this));return r.pool=n,r.thread=null,r.runArgs=[],r.sendArgs=[],n.emit("newJob",r),r}return s(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this},t.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.sendArgs=t,this.emit("readyToRun"),this},t.prototype.executeOn=function(e){var t,n;return(t=(n=e.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(t,this.sendArgs),this.thread=e,this.emit("threadChanged"),this},t.prototype.promise=function(){var e=this;return new Promise(function(t){e.thread?t(e.thread.promise()):e.once("threadChanged",function(){t(e.thread.promise())})})},t.prototype.destroy=function(){this.removeAllListeners(),delete this.runArgs,delete this.sendArgs},t}(u.default);n.default=c},{eventemitter3:8}],5:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a=e("eventemitter3"),u=r(a),c=e("./job"),f=r(c),l=e("./defaults"),p=r(l),h=e("./"),d=function(e){function t(n){o(this,t);var r=i(this,e.call(this));return r.threads=t.spawn(n||p.default.pool.size),r.idleThreads=r.threads.slice(),r.jobQueue=[],r.runArgs=[],r.on("newJob",function(e){return r.handleNewJob(e)}),r.on("threadAvailable",function(){return r.dequeue()}),r}return s(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.runArgs=t,this},t.prototype.send=function(){var e;if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var t=new f.default(this);return(e=t.run.apply(t,this.runArgs)).send.apply(e,arguments)},t.prototype.killAll=function(){this.threads.forEach(function(e){e.kill()})},t.prototype.queueJob=function(e){this.jobQueue.push(e),this.dequeue()},t.prototype.dequeue=function(){var e=this;if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),n=this.idleThreads.shift();t.once("done",function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.handleJobSuccess.apply(e,[n,t].concat(o))}).once("error",function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.handleJobError.apply(e,[n,t].concat(o))}),t.executeOn(n)}},t.prototype.handleNewJob=function(e){var t=this;e.once("readyToRun",function(){return t.queueJob(e)})},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e,t)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e,t)},t.prototype.handleJobDone=function(e,t){var n=this;t.destroy(),this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){n.emit("finished")},0)},t}(u.default);n.default=d,d.spawn=function(e){for(var t=[],n=0;n<e;n++)t.push((0,h.spawn)());return t}},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:8}],6:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}n.__esModule=!0;var o=e("./slave-code"),i=r(o),s="data:text/javascript;charset=utf-8,"+encodeURI(i.default),a=window.createBlobURL||window.createObjectURL;if(!a){var u=window.URL||window.webkitURL;if(!u)throw new Error("No Blob creation implementation found.");a=u.createObjectURL}if("function"==typeof window.BlobBuilder&&"function"==typeof a){var c=new window.BlobBuilder;c.append(i.default),s=a(c.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var f=new window.Blob([i.default],{type:"text/javascript"});s=a(f)}n.default=s},{"./slave-code":7}],7:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nself.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n var args = Array.prototype.slice.call(arguments, 0);\n this.postMessage({ response : args });\n}\n\nfunction handlerProgress(progress) {\n this.postMessage({ progress : progress });\n}\n\nfunction handlerError(error) {\n // Need to clone error manually to avoid DataCloneError, since errors cannot be send\n var cloned = {\n message: error.message,\n name: error.name,\n stack: error.stack\n };\n this.postMessage({ error : cloned });\n}\n\nfunction handlerDoneTransfer() {\n var args = Array.prototype.slice.call(arguments);\n var lastArg = args.pop();\n\n if (!(lastArg instanceof Array) && this.console) {\n console.error('Expected 2nd parameter of <doneCallback>.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nfunction isPromise (thing) {\n return thing && typeof thing.then === 'function';\n}\n\nself.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && typeof importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n importScripts.apply(null, scripts);\n }\n\n if (event.data.initByMethod) {\n var method = event.data.method;\n this.module.exports = Function.apply(null, method.args.concat(method.body));\n\n if (scripts && scripts.length > 0) {\n importScripts.apply(null, scripts);\n }\n }\n\n if (event.data.doRun) {\n var handler = this.module.exports;\n\n if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n var preparedHandlerDone = handlerDone.bind(this);\n preparedHandlerDone.transfer = handlerDoneTransfer.bind(this);\n\n var returned = handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n\n if (isPromise(returned)) {\n returned.then(preparedHandlerDone, handlerError.bind(this));\n }\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(){this._events=new r,this._eventsCount=0}var s=Object.prototype.hasOwnProperty,a="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(a=!1)),i.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)s.call(e,t)&&n.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},i.prototype.listeners=function(e,t){var n=a?a+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},i.prototype.emit=function(e,t,n,r,o,i){var s=a?a+e:e;if(!this._events[s])return!1;var u,c,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,n),!0;case 4:return f.fn.call(f.context,t,n,r),!0;case 5:return f.fn.call(f.context,t,n,r,o),!0;case 6:return f.fn.call(f.context,t,n,r,o,i),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var p,h=f.length;for(c=0;c<h;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,n);break;case 4:f[c].fn.call(f[c].context,t,n,r);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];f[c].fn.apply(f[c].context,u)}}return!0},i.prototype.on=function(e,t,n){var r=new o(t,n||this),i=a?a+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.once=function(e,t,n){var r=new o(t,n||this,(!0)),i=a?a+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.removeListener=function(e,t,n,o){var i=a?a+e:e;if(!this._events[i])return this;if(!t)return 0===--this._eventsCount?this._events=new r:delete this._events[i],this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||n&&s.context!==n||(0===--this._eventsCount?this._events=new r:delete this._events[i]);else{for(var u=0,c=[],f=s.length;u<f;u++)(s[u].fn!==t||o&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:0===--this._eventsCount?this._events=new r:delete this._events[i]}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&(0===--this._eventsCount?this._events=new r:delete this._events[t])):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prototype.setMaxListeners=function(){return this},i.prefixed=a,i.EventEmitter=i,"undefined"!=typeof t&&(t.exports=i)},{}],9:[function(e,t,n){(function(e){!function(e,n,r){n[e]=n[e]||r(),"undefined"!=typeof t&&t.exports?t.exports=n[e]:"function"==typeof define&&define.amd&&define(function(){return n[e]})}("Promise","undefined"!=typeof e?e:this,function(){"use strict";function e(e,t){p.add(e,t),l||(l=d(p.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function n(){for(var e=0;e<this.chain.length;e++)r(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function r(e,n,r){var o,i;try{n===!1?r.reject(e.msg):(o=n===!0?e.msg:n.call(void 0,e.msg),o===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=t(o))?i.call(o,r.resolve,r.reject):r.resolve(o))}catch(e){r.reject(e)}}function o(r){var s,u=this;if(!u.triggered){u.triggered=!0,u.def&&(u=u.def);try{(s=t(r))?e(function(){var e=new a(u);try{s.call(r,function(){o.apply(e,arguments)},function(){i.apply(e,arguments)})}catch(t){i.call(e,t)}}):(u.msg=r,u.state=1,u.chain.length>0&&e(n,u))}catch(e){i.call(new a(u),e)}}}function i(t){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=t,r.state=2,r.chain.length>0&&e(n,r))}function s(e,t,n,r){for(var o=0;o<t.length;o++)!function(o){e.resolve(t[o]).then(function(e){n(o,e)},r)}(o)}function a(e){this.def=e,this.triggered=!1}function u(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function c(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var r=new u(this);this.then=function(t,o){var i={success:"function"!=typeof t||t,failure:"function"==typeof o&&o};return i.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");i.resolve=e,i.reject=t}),r.chain.push(i),0!==r.state&&e(n,r),i.promise},this.catch=function(e){return this.then(void 0,e)};try{t.call(void 0,function(e){o.call(r,e)},function(e){i.call(r,e)})}catch(e){i.call(r,e)}}var f,l,p,h=Object.prototype.toString,d="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),f=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch(e){f=function(e,t,n){return e[t]=n,e}}p=function(){function e(e,t){this.fn=e,this.self=t,this.next=void 0}var t,n,r;return{add:function(o,i){r=new e(o,i),n?n.next=r:t=r,n=r,r=void 0},drain:function(){var e=t;for(t=n=l=void 0;e;)e.fn.call(e.self),e=e.next}}}();var y=f({},"constructor",c,!1);return c.prototype=y,f(y,"__NPO__",0,!1),f(c,"resolve",function(e){var t=this;return e&&"object"==typeof e&&1===e.__NPO__?e:new t(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),f(c,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),f(c,"all",function(e){var t=this;return"[object Array]"!=h.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");var o=e.length,i=Array(o),a=0;s(t,e,function(e,t){i[e]=t,++a===o&&n(i)},r)})}),f(c,"race",function(e){var t=this;return"[object Array]"!=h.call(e)?t.reject(TypeError("Not an array")):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");s(t,e,function(e,t){n(t)},r)})}),c})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);
require=function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({"./defaults":[function(e,t,n){"use strict";n.__esModule=!0,n.default={pool:{size:navigator.hardwareConcurrency||8}}},{}],"./worker":[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){return e&&t?"/"===e.charAt(e.length-1)||"/"===t.charAt(0)?e+t:e+"/"+t:e+t}function u(e){var t=(0,v.getConfig)().basepath.web;return t?a(t,e):e}function c(e){return Array.prototype.slice.call(e)}function f(e){if(e.stack)console.error(e.stack);else if(e.message&&e.filename&&e.lineno){var t=e.filename.match(/^data:text\/javascript/)&&e.filename.length>50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=e("eventemitter3"),h=r(p),d=e("./slave-code-uri"),y=r(d),v=e("../config");if("object"!==l(window.Worker)&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var g=function(e){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];o(this,t);var s=i(this,e.call(this));return s.currentRunnable=null,s.currentImportScripts=[],s.initWorker(),s.worker.addEventListener("message",s.handleMessage.bind(s)),s.worker.addEventListener("error",s.handleError.bind(s)),n&&s.run(n,r),s}return s(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(y.default)}catch(t){var e=(0,v.getConfig)().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(e)}},t.prototype.run=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.alreadyInitializedToRun(e,t)?this:("function"==typeof e?this.runMethod(e,t):this.runScripts(e,t),this.currentRunnable=e,this.currentImportScripts=t,this)},t.prototype.runMethod=function(e,t){var n=e.toString(),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(","),o=n.substring(n.indexOf("{")+1,n.lastIndexOf("}"));this.worker.postMessage({initByMethod:!0,method:{args:r,body:o},scripts:t.map(u)})},t.prototype.runScripts=function(e,t){if(!e)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:t.concat([e]).map(u)})},t.prototype.send=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.worker.postMessage({doRun:!0,param:e},t),this},t.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},t.prototype.promise=function(){var e=this;return new Promise(function(t,n){var r=void 0,o=void 0;r=function(n){e.removeListener("error",o),t(n)},o=function(t){e.removeListener("message",r),n(t)},e.once("message",r).once("error",o)})},t.prototype.alreadyInitializedToRun=function(e,t){var n=this.currentRunnable===e,r=this.currentImportScripts===t||0===t.length&&0===this.currentImportScripts.length;return n&&r},t.prototype.handleMessage=function(e){if(e.data.error)this.handleError(e.data.error);else if(e.data.progress)this.handleProgress(e.data.progress);else{var t=c(e.data.response);this.emit.apply(this,["message"].concat(t)),this.emit.apply(this,["done"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||f(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h.default);n.default=g},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],1:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./index"),s=r(i);"object"===("undefined"==typeof window?"undefined":o(window))&&(window.thread=s.default),"function"==typeof define?define([],function(){return s.default}):"object"===("undefined"==typeof t?"undefined":o(t))&&(t.exports=s.default)},{"./index":3}],2:[function(e,t,n){"use strict";function r(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];Object.keys(t).forEach(function(o){var i=t[o],a=n.concat([o]);if("object"===("undefined"==typeof i?"undefined":s(i))){if("undefined"!=typeof e[o]&&"object"!==s(e[o]))throw new Error("Expected config property not to be an object: "+a.join("."));r(e[o],i,a)}else{if("object"===s(e[o]))throw new Error("Expected config property to be an object: "+a.join("."));e[o]=i}})}function o(){return u.get()}function i(){return u.set.apply(u,arguments)}n.__esModule=!0;var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n.getConfig=o,n.setConfig=i;var a={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},u={get:function(){return a},set:function(e){if("object"!==("undefined"==typeof e?"undefined":s(e)))throw new Error("Expected config object.");r(a,e)}};n.default=u},{}],3:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new p.default(e,t)}n.__esModule=!0,n.Pool=n.defaults=n.config=void 0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),c=e("./pool"),f=r(c),l=e("./worker"),p=r(l);n.config=s.default,n.defaults=u.default,n.Pool=f.default,n.default={config:s.default,defaults:u.default,Pool:f.default,spawn:o,Worker:p.default}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a=e("eventemitter3"),u=r(a),c=function(e){function t(n){o(this,t);var r=i(this,e.call(this));return r.pool=n,r.thread=null,r.runArgs=[],r.sendArgs=[],n.emit("newJob",r),r}return s(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this},t.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.sendArgs=t,this.emit("readyToRun"),this},t.prototype.executeOn=function(e){var t,n,r=this,o=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.emit.apply(r,["progress"].concat(t))},i=function(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];r.emit.apply(r,["done"].concat(n)),e.removeListener("progress",o)},s=function(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];r.emit.apply(r,["error"].concat(n)),e.removeListener("progress",o)};return(t=(n=e.on("progress",o).once("message",i).once("error",s)).run.apply(n,this.runArgs)).send.apply(t,this.sendArgs),this.thread=e,this.emit("threadChanged"),this},t.prototype.promise=function(){var e=this;return new Promise(function(t){e.thread?t(e.thread.promise()):e.once("threadChanged",function(){t(e.thread.promise())})})},t.prototype.destroy=function(){this.removeAllListeners(),delete this.runArgs,delete this.sendArgs},t}(u.default);n.default=c},{eventemitter3:8}],5:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.__esModule=!0;var a=e("eventemitter3"),u=r(a),c=e("./job"),f=r(c),l=e("./defaults"),p=r(l),h=e("./"),d=function(e){function t(n){o(this,t);var r=i(this,e.call(this));return r.threads=t.spawn(n||p.default.pool.size),r.idleThreads=r.threads.slice(),r.jobQueue=[],r.runArgs=[],r.on("newJob",function(e){return r.handleNewJob(e)}),r.on("threadAvailable",function(){return r.dequeue()}),r}return s(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.runArgs=t,this},t.prototype.send=function(){var e;if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var t=new f.default(this);return(e=t.run.apply(t,this.runArgs)).send.apply(e,arguments)},t.prototype.killAll=function(){this.threads.forEach(function(e){e.kill()})},t.prototype.queueJob=function(e){this.jobQueue.push(e),this.dequeue()},t.prototype.dequeue=function(){var e=this;if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),n=this.idleThreads.shift();t.once("done",function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.handleJobSuccess.apply(e,[n,t].concat(o))}).once("error",function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.handleJobError.apply(e,[n,t].concat(o))}),t.executeOn(n)}},t.prototype.handleNewJob=function(e){var t=this;e.once("readyToRun",function(){return t.queueJob(e)})},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e,t)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e,t)},t.prototype.handleJobDone=function(e,t){var n=this;t.destroy(),this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){n.emit("finished")},0)},t}(u.default);n.default=d,d.spawn=function(e){for(var t=[],n=0;n<e;n++)t.push((0,h.spawn)());return t}},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:8}],6:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}n.__esModule=!0;var o=e("./slave-code"),i=r(o),s="data:text/javascript;charset=utf-8,"+encodeURI(i.default),a=window.createBlobURL||window.createObjectURL;if(!a){var u=window.URL||window.webkitURL;if(!u)throw new Error("No Blob creation implementation found.");a=u.createObjectURL}if("function"==typeof window.BlobBuilder&&"function"==typeof a){var c=new window.BlobBuilder;c.append(i.default),s=a(c.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var f=new window.Blob([i.default],{type:"text/javascript"});s=a(f)}n.default=s},{"./slave-code":7}],7:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nself.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n var args = Array.prototype.slice.call(arguments, 0);\n this.postMessage({ response : args });\n}\n\nfunction handlerProgress(progress) {\n this.postMessage({ progress : progress });\n}\n\nfunction handlerError(error) {\n // Need to clone error manually to avoid DataCloneError, since errors cannot be send\n var cloned = {\n message: error.message,\n name: error.name,\n stack: error.stack\n };\n this.postMessage({ error : cloned });\n}\n\nfunction handlerDoneTransfer() {\n var args = Array.prototype.slice.call(arguments);\n var lastArg = args.pop();\n\n if (!(lastArg instanceof Array) && this.console) {\n console.error('Expected 2nd parameter of <doneCallback>.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nfunction isPromise (thing) {\n return thing && typeof thing.then === 'function';\n}\n\nself.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && typeof importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n importScripts.apply(null, scripts);\n }\n\n if (event.data.initByMethod) {\n var method = event.data.method;\n this.module.exports = Function.apply(null, method.args.concat(method.body));\n\n if (scripts && scripts.length > 0) {\n importScripts.apply(null, scripts);\n }\n }\n\n if (event.data.doRun) {\n var handler = this.module.exports;\n\n if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n var preparedHandlerDone = handlerDone.bind(this);\n preparedHandlerDone.transfer = handlerDoneTransfer.bind(this);\n\n var returned = handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n\n if (isPromise(returned)) {\n returned.then(preparedHandlerDone, handlerError.bind(this));\n }\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(){this._events=new r,this._eventsCount=0}var s=Object.prototype.hasOwnProperty,a="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(a=!1)),i.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)s.call(e,t)&&n.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},i.prototype.listeners=function(e,t){var n=a?a+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},i.prototype.emit=function(e,t,n,r,o,i){var s=a?a+e:e;if(!this._events[s])return!1;var u,c,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,n),!0;case 4:return f.fn.call(f.context,t,n,r),!0;case 5:return f.fn.call(f.context,t,n,r,o),!0;case 6:return f.fn.call(f.context,t,n,r,o,i),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var p,h=f.length;for(c=0;c<h;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,n);break;case 4:f[c].fn.call(f[c].context,t,n,r);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];f[c].fn.apply(f[c].context,u)}}return!0},i.prototype.on=function(e,t,n){var r=new o(t,n||this),i=a?a+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.once=function(e,t,n){var r=new o(t,n||this,(!0)),i=a?a+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.removeListener=function(e,t,n,o){var i=a?a+e:e;if(!this._events[i])return this;if(!t)return 0===--this._eventsCount?this._events=new r:delete this._events[i],this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||n&&s.context!==n||(0===--this._eventsCount?this._events=new r:delete this._events[i]);else{for(var u=0,c=[],f=s.length;u<f;u++)(s[u].fn!==t||o&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:0===--this._eventsCount?this._events=new r:delete this._events[i]}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&(0===--this._eventsCount?this._events=new r:delete this._events[t])):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prototype.setMaxListeners=function(){return this},i.prefixed=a,i.EventEmitter=i,"undefined"!=typeof t&&(t.exports=i)},{}],9:[function(e,t,n){(function(e){!function(e,n,r){n[e]=n[e]||r(),"undefined"!=typeof t&&t.exports?t.exports=n[e]:"function"==typeof define&&define.amd&&define(function(){return n[e]})}("Promise","undefined"!=typeof e?e:this,function(){"use strict";function e(e,t){p.add(e,t),l||(l=d(p.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function n(){for(var e=0;e<this.chain.length;e++)r(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function r(e,n,r){var o,i;try{n===!1?r.reject(e.msg):(o=n===!0?e.msg:n.call(void 0,e.msg),o===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=t(o))?i.call(o,r.resolve,r.reject):r.resolve(o))}catch(e){r.reject(e)}}function o(r){var s,u=this;if(!u.triggered){u.triggered=!0,u.def&&(u=u.def);try{(s=t(r))?e(function(){var e=new a(u);try{s.call(r,function(){o.apply(e,arguments)},function(){i.apply(e,arguments)})}catch(t){i.call(e,t)}}):(u.msg=r,u.state=1,u.chain.length>0&&e(n,u))}catch(e){i.call(new a(u),e)}}}function i(t){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=t,r.state=2,r.chain.length>0&&e(n,r))}function s(e,t,n,r){for(var o=0;o<t.length;o++)!function(o){e.resolve(t[o]).then(function(e){n(o,e)},r)}(o)}function a(e){this.def=e,this.triggered=!1}function u(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function c(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var r=new u(this);this.then=function(t,o){var i={success:"function"!=typeof t||t,failure:"function"==typeof o&&o};return i.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");i.resolve=e,i.reject=t}),r.chain.push(i),0!==r.state&&e(n,r),i.promise},this.catch=function(e){return this.then(void 0,e)};try{t.call(void 0,function(e){o.call(r,e)},function(e){i.call(r,e)})}catch(e){i.call(r,e)}}var f,l,p,h=Object.prototype.toString,d="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),f=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch(e){f=function(e,t,n){return e[t]=n,e}}p=function(){function e(e,t){this.fn=e,this.self=t,this.next=void 0}var t,n,r;return{add:function(o,i){r=new e(o,i),n?n.next=r:t=r,n=r,r=void 0},drain:function(){var e=t;for(t=n=l=void 0;e;)e.fn.call(e.self),e=e.next}}}();var y=f({},"constructor",c,!1);return c.prototype=y,f(y,"__NPO__",0,!1),f(c,"resolve",function(e){var t=this;return e&&"object"==typeof e&&1===e.__NPO__?e:new t(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),f(c,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),f(c,"all",function(e){var t=this;return"[object Array]"!=h.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");var o=e.length,i=Array(o),a=0;s(t,e,function(e,t){i[e]=t,++a===o&&n(i)},r)})}),f(c,"race",function(e){var t=this;return"[object Array]"!=h.call(e)?t.reject(TypeError("Not an array")):new t(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");s(t,e,function(e,t){n(t)},r)})}),c})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);

@@ -64,6 +64,32 @@ 'use strict';

Job.prototype.executeOn = function executeOn(thread) {
var _thread$once$once$run, _thread$once$once;
var _this2 = this,
_thread$on$once$once$,
_thread$on$once$once;
(_thread$once$once$run = (_thread$once$once = thread.once('message', this.emit.bind(this, 'done')).once('error', this.emit.bind(this, 'error'))).run.apply(_thread$once$once, this.runArgs)).send.apply(_thread$once$once$run, this.sendArgs);
var onProgress = function onProgress() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return _this2.emit.apply(_this2, ['progress'].concat(args));
};
var onMessage = function onMessage() {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
_this2.emit.apply(_this2, ['done'].concat(args));
thread.removeListener('progress', onProgress);
};
var onError = function onError() {
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
_this2.emit.apply(_this2, ['error'].concat(args));
thread.removeListener('progress', onProgress);
};
(_thread$on$once$once$ = (_thread$on$once$once = thread.on('progress', onProgress).once('message', onMessage).once('error', onError)).run.apply(_thread$on$once$once, this.runArgs)).send.apply(_thread$on$once$once$, this.sendArgs);
this.thread = thread;

@@ -75,3 +101,3 @@ this.emit('threadChanged');

Job.prototype.promise = function promise() {
var _this2 = this;
var _this3 = this;

@@ -81,8 +107,8 @@ // Always return a promise

// If the thread isn't set, listen for the threadChanged event
if (!_this2.thread) {
_this2.once('threadChanged', function () {
resolve(_this2.thread.promise());
if (!_this3.thread) {
_this3.once('threadChanged', function () {
resolve(_this3.thread.promise());
});
} else {
resolve(_this2.thread.promise());
resolve(_this3.thread.promise());
}

@@ -89,0 +115,0 @@ });

{
"name": "threads",
"version": "0.8.0",
"version": "0.8.1",
"keywords": [

@@ -5,0 +5,0 @@ "threads",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc