From bc444d125cc117e2a74822d2d0453ff6468c3392 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 25 Aug 2015 23:53:14 +0200 Subject: [PATCH 001/224] Initial commit. Boilerplate. --- .eslintrc | 23 ++++++++ .gitignore | 1 + LICENSE | 21 ++++++++ dist/thread.browser.js | 44 ++++++++++++++++ dist/thread.browser.min.js | 1 + gulpfile.js | 52 ++++++++++++++++++ lib/genericworker.js | 1 + lib/index.js | 22 ++++++++ lib/worker.browser.js | 19 +++++++ lib/worker.js | 19 +++++++ lib/worker.node.js | 19 +++++++ package.json | 36 +++++++++++++ readme.md | 105 +++++++++++++++++++++++++++++++++++++ src/genericworker.js | 0 src/index.js | 10 ++++ src/worker.browser.js | 8 +++ src/worker.js | 1 + src/worker.node.js | 8 +++ 18 files changed, 390 insertions(+) create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 dist/thread.browser.js create mode 100644 dist/thread.browser.min.js create mode 100644 gulpfile.js create mode 100644 lib/genericworker.js create mode 100644 lib/index.js create mode 100644 lib/worker.browser.js create mode 100755 lib/worker.js create mode 100644 lib/worker.node.js create mode 100644 package.json create mode 100644 readme.md create mode 100644 src/genericworker.js create mode 100644 src/index.js create mode 100644 src/worker.browser.js create mode 120000 src/worker.js create mode 100644 src/worker.node.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..e0e3b492 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,23 @@ +{ + "ecmaFeatures" : { + "arrowFunctions" : true, + "blockBindings" : true, + "classes" : true, + "defaultParams" : true, + "destructuring" : true, + "jsx" : true, + "modules" : true, + "restParams" : true + }, + "globals" : { + "Blob" : true, + "BlobBuilder" : true + }, + "rules" : { + "global-strict" : 0, + "key-spacing" : [0, { "beforeColon": false, "afterColon": true }], + "no-console" : 1, + "no-multi-spaces" : 0, + "quotes" : [1, "single", "avoid-escape"] + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..fc5c3c25 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andy Wermke + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/dist/thread.browser.js b/dist/thread.browser.js new file mode 100644 index 00000000..c4bc1555 --- /dev/null +++ b/dist/thread.browser.js @@ -0,0 +1,44 @@ +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", + "license" : "MIT", + "main" : "lib/index.js", + "bugs" : { + "url" : "https://github.com/andywer/thread.js/issues" + }, + "repository" : { + "type" : "git", + "url" : "https://github.com/andywer/thread.js.git" + }, + "devDependencies" : { + "browserify" : "^9.0.8", + "gulp" : "^3.8.11", + "gulp-babel" : "^5.2.0", + "gulp-concat" : "^2.5.2", + "gulp-eslint" : "^0.9.0", + "gulp-uglify" : "^1.2.0", + "vinyl-source-stream" : "^1.1.0" + }, + "dependencies" : { + "eventemitter3" : "^1.1.1" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..ba277141 --- /dev/null +++ b/readme.md @@ -0,0 +1,105 @@ +# thread.js + +Javascript thread library. Uses web workers when run in browsers and clusters +when run by node.js. Also supports browsers which do not support web workers. + +- Convenience API +- For client and server use +- Use different APIs (web worker, shared worker, node cluster) transparently +- Thread pools +- example use cases +- ES6, but backwards-compatible + +-> TODO: event emitter + promise api + + +## Sample use + +```javascript +import { spawn } from 'thread.js'; +// ES5 syntax: var spawn = require('thread.js').spawn; + +const thread = spawn('/path/to/worker.js'); + +thread + .send({ hello : 'world' }) + .on('message', function(message) { + console.log('Worker sent:', message); + }) + .on('error', function(error) { + console.error('Worker errored:', error); + }) + .on('exit', function() { + console.log('Worker is terminated.'); + }); + +setTimeout(function() { + thread.kill(); +}, 1000); +``` + + +```javascript +import { spawn } from 'thread.js'; +// ES5 syntax: var spawn = require('thread.js').spawn; + +const thread = spawn(); +// spawn a SharedWorker: `spawn({ shared: true })` + +thread + .run(function(param, done) { + done(param, param + 1); + }) + .send(1) + .send(2) + .on('message', function(value, valuePlusOne) { + console.log(`${value} + 1 = ${valuePlusOne}`); + }); +``` + + +```javascript +import { Pool } from 'thread.js'; +// ES5 syntax: var Pool = require('thread.js').Pool; + +const pool = new Pool(); +const jobA = pool.run('/path/to/worker').send({ do : 'something' }); +const jobB = pool.run( + function(string, done) { + const hash = md5(string); + done(hash); + }, { + // dependencies; resolved using node's require() or the web workers importScript() + md5 : 'js-md5' + } +).send('Hash this string!'); + +jobA + .on('done', function(message) { + console.log('Job A done:', message); + }) + .on('error', function(error) { + console.error('Job A errored:', error); + }); + +pool + .on('done', function(job, message) { + console.log('Job done:', job); + }) + .on('error', function(job, error) { + console.error('Job errored:', job); + }) + .on('spawn', function(worker, job) { + console.log('Thread pool spawned a new worker:', worker); + }) + .on('kill', function(worker) { + console.log('Thread pool killed a worker:', worker); + }) + .on('finished', function() { + console.log('Everything done, shutting down the thread pool.'); + pool.destroy(); + }) + .on('destroy', function() { + console.log('Thread pool destroyed.'); + }); +``` diff --git a/src/genericworker.js b/src/genericworker.js new file mode 100644 index 00000000..e69de29b diff --git a/src/index.js b/src/index.js new file mode 100644 index 00000000..81f06c43 --- /dev/null +++ b/src/index.js @@ -0,0 +1,10 @@ + +import Worker from './worker'; + +export function spawn(url = null) { + // TODO: GenericWorker if url === null + + return new Worker(); +} + +// TODO: export Pool diff --git a/src/worker.browser.js b/src/worker.browser.js new file mode 100644 index 00000000..64d0c459 --- /dev/null +++ b/src/worker.browser.js @@ -0,0 +1,8 @@ +/*eslint-env browser*/ + +export default class Worker { + constructor() { + // TODO + console.log('Browser worker.'); + } +} diff --git a/src/worker.js b/src/worker.js new file mode 120000 index 00000000..a26f02f3 --- /dev/null +++ b/src/worker.js @@ -0,0 +1 @@ +worker.node.js \ No newline at end of file diff --git a/src/worker.node.js b/src/worker.node.js new file mode 100644 index 00000000..747e59d5 --- /dev/null +++ b/src/worker.node.js @@ -0,0 +1,8 @@ +/*eslint-env node*/ + +export default class Worker { + constructor() { + // TODO + console.log('Node worker.'); + } +} From d74c541bf20167e6c4e44f7e95cda378e90c779f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 26 Aug 2015 00:09:06 +0200 Subject: [PATCH 002/224] Update readme --- readme.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ba277141..6152fac3 100644 --- a/readme.md +++ b/readme.md @@ -10,11 +10,11 @@ when run by node.js. Also supports browsers which do not support web workers. - example use cases - ES6, but backwards-compatible --> TODO: event emitter + promise api - ## Sample use +### Basic use + ```javascript import { spawn } from 'thread.js'; // ES5 syntax: var spawn = require('thread.js').spawn; @@ -38,6 +38,10 @@ setTimeout(function() { }, 1000); ``` +### Generic worker + +Don't provide a worker script, but spawn a generic worker and provide him a +function to execute. ```javascript import { spawn } from 'thread.js'; @@ -57,6 +61,10 @@ thread }); ``` +### Thread Pool + +You can also create a thread pool that spawns a fixed no. of workers. Pass jobs +to the thread pool which it will queue and pass to the next idle worker. ```javascript import { Pool } from 'thread.js'; @@ -103,3 +111,12 @@ pool console.log('Thread pool destroyed.'); }); ``` + +## API + +You can find the API documentation in the [wiki](https://github.com/andywer/thread.js/wiki). + + +## License + +This library is published under the MIT license. See [LICENSE](https://raw.githubusercontent.com/andywer/thread.js/master/LICENSE) for details. From 70b6f7274229f0847784237694812baec2725987 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 26 Aug 2015 09:16:06 +0200 Subject: [PATCH 003/224] Update readme --- readme.md | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6152fac3..7a0e2a39 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,7 @@ setTimeout(function() { ### Generic worker Don't provide a worker script, but spawn a generic worker and provide him a -function to execute. +function to execute. This is especially useful for non-complex thread code. ```javascript import { spawn } from 'thread.js'; @@ -52,6 +52,8 @@ const thread = spawn(); thread .run(function(param, done) { + // remember that this function will be executed in the thread's context, + // so you cannot reference any value of the surrounding code done(param, param + 1); }) .send(1) @@ -112,6 +114,41 @@ pool }); ``` +### Streaming + +You can also spawn a thread for streaming purposes. The following example shows +a very simple use case where you keep feeding numbers to the background task +and it will return the minimum and maximum of all values you ever passed. + +```javascript +thread + .run(function minmax(int, done) { + if (typeof this.min === 'undefined') { + this.min = int; + this.max = int; + } else { + this.min = Math.min(this.min, int); + this.max = Math.max(this.max, int); + } + done({ min : this.min, max : this.max }}); + }) + .send(2) + .send(3) + .send(4) + .send(1) + .send(5) + .on('message', function(minmax) { + console.log('min:', minmax.min, ', max:', minmax.max); + }) + .on('done', function() { + thread.kill(); + }); +``` + +### Import scripts and data transfer + +TODO + ## API You can find the API documentation in the [wiki](https://github.com/andywer/thread.js/wiki). From 79bf366f45b929e124747ad1f879b47412b4cf10 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 26 Aug 2015 21:31:07 +0200 Subject: [PATCH 004/224] Document usage of dependencies & transferables --- readme.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 7a0e2a39..dff76d0a 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ when run by node.js. Also supports browsers which do not support web workers. - ES6, but backwards-compatible -## Sample use +## How To ### Basic use @@ -145,9 +145,29 @@ thread }); ``` -### Import scripts and data transfer +### Import scripts and transferable objects -TODO +You can also use dependencies in the spawned thread and use transferable objects +to improve performance when passing large buffers (in browser). +See [Transferable Objects: Lightning Fast!](http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast). + +```javascript +const largeArrayBuffer = new Uint8Array(1024*1024*32); // 32MB +const data = { label : 'huge thing', buffer: largeArrayBuffer.buffer }; + +thread + .run(function(param, done) { + // do something cool with this.axios + done(); + }, { + // dependencies; resolved using node's require() or the web workers importScript() + // the key will be used as key on worker's `this` object + // the value is used similar to require() or es6 import + axios : 'axios' + }) + // pass the buffers to transfer into thread context as 2nd parameter to send() + .send(data, [ largeArrayBuffer.buffer ]); +``` ## API From 746edf79625aae3ee4bf7daca781fdc3f076d4bd Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 29 Aug 2015 12:12:42 +0200 Subject: [PATCH 005/224] Implement config --- lib/config.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/index.js | 17 ++++++++++---- src/config.js | 47 ++++++++++++++++++++++++++++++++++++++ src/index.js | 8 ++++--- 4 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 lib/config.js create mode 100644 src/config.js diff --git a/lib/config.js b/lib/config.js new file mode 100644 index 00000000..2921b61a --- /dev/null +++ b/lib/config.js @@ -0,0 +1,63 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.getConfig = getConfig; +exports.setConfig = setConfig; +var configuration = { + basepath: { + node: '', + web: '' + } +}; + +function configDeepMerge(destObj, srcObj) { + var ancestorProps = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; + + Object.keys(srcObj).forEach(function (propKey) { + var srcValue = srcObj[propKey]; + var ancestorPropsAndThis = ancestorProps.concat([propKey]); + + if (typeof srcValue === 'object') { + if (typeof destObj[propKey] !== 'undefined' && typeof destObj[propKey] !== 'object') { + throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.')); + } + configDeepMerge(destObj[propKey], srcValue, ancestorPropsAndThis); + } else { + if (typeof destObj[propKey] === 'object') { + throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.')); + } + destObj[propKey] = srcValue; + } + }); +} + +var config = { + get: function get() { + return configuration; + }, + + set: function set(newConfig) { + if (typeof newConfig !== 'object') { + throw new Error('Expected config object.'); + } + + configDeepMerge(configuration, newConfig); + } +}; + +exports['default'] = config; + +function getConfig() { + return config.get(); +} + +function setConfig() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return config.set.apply(config, args); +} +//# sourceMappingURL=config.js.map \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 169df23b..bfb71d2c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,16 +7,23 @@ exports.spawn = spawn; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _config = require('./config'); + +var _config2 = _interopRequireDefault(_config); + var _worker = require('./worker'); var _worker2 = _interopRequireDefault(_worker); -function spawn() { - var url = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; +exports.config = _config2['default']; +exports.Worker = _worker2['default']; +// needed for testing - // TODO: GenericWorker if url === null +function spawn() { + var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - return new _worker2['default'](); + return new _worker2['default'](runnable); } -// TODO: export Pool \ No newline at end of file +// TODO: export Pool +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/config.js b/src/config.js new file mode 100644 index 00000000..8db8be6e --- /dev/null +++ b/src/config.js @@ -0,0 +1,47 @@ +let configuration = { + basepath : { + node : '', + web : '' + } +}; + +function configDeepMerge(destObj, srcObj, ancestorProps = []) { + Object.keys(srcObj).forEach((propKey) => { + let srcValue = srcObj[ propKey ]; + const ancestorPropsAndThis = ancestorProps.concat([ propKey ]); + + if (typeof srcValue === 'object') { + if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') { + throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.')); + } + configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis); + } else { + if (typeof destObj[ propKey ] === 'object') { + throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.')); + } + destObj[ propKey ] = srcValue; + } + }); +} + +const config = { + get: () => configuration, + + set: (newConfig) => { + if (typeof newConfig !== 'object') { + throw new Error('Expected config object.'); + } + + configDeepMerge(configuration, newConfig); + } +}; + +export default config; + +export function getConfig () { + return config.get(); +} + +export function setConfig (...args) { + return config.set.apply(config, args); +} diff --git a/src/index.js b/src/index.js index 81f06c43..cba0df04 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,12 @@ +import config from './config'; import Worker from './worker'; -export function spawn(url = null) { - // TODO: GenericWorker if url === null +export { config }; +export { Worker }; // needed for testing - return new Worker(); +export function spawn(runnable = null) { + return new Worker(runnable); } // TODO: export Pool From 9c5affa7144566c10eed9b26924114c983457007 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 29 Aug 2015 12:14:32 +0200 Subject: [PATCH 006/224] Re-implement worker code + prepare testing --- dist/thread.browser.js | 498 +++++++++++++++++++++++++++++-- dist/thread.browser.min.js | 2 +- gulpfile.js | 35 ++- lib/bundle.browser.js | 23 ++ lib/bundle.browser.js.map | 1 + lib/config.js.map | 1 + lib/genericworker.browser.js | 82 +++++ lib/index.js.map | 1 + lib/slave.node.js | 9 + lib/worker.browser.js | 57 +++- lib/worker.browser/worker.js | 121 ++++++++ lib/worker.browser/worker.js.map | 1 + lib/worker.js | 20 +- lib/worker.js.map | 1 + lib/worker.node.js | 56 +++- lib/worker.node/slave.js | 61 ++++ lib/worker.node/slave.js.map | 1 + lib/worker.node/worker.js | 121 ++++++++ lib/worker.node/worker.js.map | 1 + package.json | 52 ++-- src/bundle.browser.js | 14 + src/genericworker.js | 0 src/worker.browser.js | 8 - src/worker.browser/.eslintrc | 5 + src/worker.browser/slave.js.txt | 36 +++ src/worker.browser/worker.js | 76 +++++ src/worker.js | 10 +- src/worker.node.js | 8 - src/worker.node/.eslintrc | 5 + src/worker.node/slave.js | 58 ++++ src/worker.node/worker.js | 76 +++++ 31 files changed, 1355 insertions(+), 85 deletions(-) create mode 100644 lib/bundle.browser.js create mode 100644 lib/bundle.browser.js.map create mode 100644 lib/config.js.map create mode 100644 lib/genericworker.browser.js create mode 100644 lib/index.js.map create mode 100644 lib/slave.node.js create mode 100644 lib/worker.browser/worker.js create mode 100644 lib/worker.browser/worker.js.map mode change 100755 => 100644 lib/worker.js create mode 100644 lib/worker.js.map create mode 100644 lib/worker.node/slave.js create mode 100644 lib/worker.node/slave.js.map create mode 100644 lib/worker.node/worker.js create mode 100644 lib/worker.node/worker.js.map create mode 100644 src/bundle.browser.js delete mode 100644 src/genericworker.js delete mode 100644 src/worker.browser.js create mode 100644 src/worker.browser/.eslintrc create mode 100644 src/worker.browser/slave.js.txt create mode 100644 src/worker.browser/worker.js mode change 120000 => 100644 src/worker.js delete mode 100644 src/worker.node.js create mode 100644 src/worker.node/.eslintrc create mode 100644 src/worker.node/slave.js create mode 100644 src/worker.node/worker.js diff --git a/dist/thread.browser.js b/dist/thread.browser.js index c4bc1555..177dd684 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -1,44 +1,508 @@ 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 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"},{}],"./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("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 s(e){var t=h.getConfig().basepath.web;return t?t+"/"+e:e}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;nn;n++)t[n]=arguments[n];return u.set.apply(u,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},u={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,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]?null:arguments[0];return new a["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),u=e("./worker"),a=r(u);n.config=s["default"],n.Worker=a["default"]},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,u=new Array(s);s>o;o++)u[o]=r[o].fn;return u},o.prototype.emit=function(e,t,n,r,o,s){var u=i?i+e:e;if(!this._events||!this._events[u])return!1;var a,c,f=this._events[u],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,a=new Array(l-1);l>c;c++)a[c-1]=arguments[c];f.fn.apply(f.context,a)}else{var p,h=f.length;for(c=0;h>c;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;default:if(!a)for(p=1,a=new Array(l-1);l>p;p++)a[p-1]=arguments[p];f[c].fn.apply(f[c].context,a)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],u=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&u.push(s);else for(var a=0,c=s.length;c>a;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&u.push(s[a]);return u.length?this._events[o]=1===u.length?u[0]:u:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 3d07f403..68a9e202 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,10 @@ var babel = require('gulp-babel'); var browserify = require('browserify'); var concat = require('gulp-concat'); var eslint = require('gulp-eslint'); +var mocha = require('gulp-mocha'); var source = require('vinyl-source-stream'); +var sourcemaps = require('gulp-sourcemaps'); +var stringify = require('stringify'); var uglify = require('gulp-uglify'); @@ -23,23 +26,33 @@ gulp.task('lint', function() { }); -gulp.task('babel', function() { +gulp.task('babel-lib', function() { return gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) .pipe(babel()) + .pipe(sourcemaps.write('.')) .pipe(gulp.dest('lib/')); }); +gulp.task('babel-spec', function() { + return gulp.src('test/spec-src/**/*.js') + .pipe(babel()) + .pipe(gulp.dest('test/spec')); +}); -gulp.task('browserify', ['babel'], function() { - return browserify('./lib/index.js') - .require('./lib/worker.browser.js', { expose : './worker' }) + +gulp.task('browserify-lib', ['babel-lib'], function() { + return browserify() + .transform(stringify(['.txt'])) + .add('./lib/bundle.browser.js') + .require('./src/worker.browser/slave.js.txt', { expose : './slave.js.txt' }) + .require('./lib/worker.browser/worker.js', { expose : './worker' }) .bundle() .pipe(source('thread.browser.js')) .pipe(gulp.dest('dist/')); }); - -gulp.task('uglify', ['browserify'], function() { +gulp.task('uglify', ['browserify-lib'], function() { return gulp.src('dist/thread.browser.js') .pipe(uglify()) .pipe(concat('thread.browser.min.js')) @@ -47,6 +60,12 @@ gulp.task('uglify', ['browserify'], function() { }); -gulp.task('dist', ['lint', 'browserify', 'uglify']); +gulp.task('test', ['dist', 'babel-spec'], function() { + return gulp.src('test/spec/*.spec.js', { read: false }) + .pipe(mocha()); +}); + + +gulp.task('dist', ['lint', 'browserify-lib', 'uglify']); -gulp.task('default', ['dist']); +gulp.task('default', ['dist', 'test']); diff --git a/lib/bundle.browser.js b/lib/bundle.browser.js new file mode 100644 index 00000000..533fdcd4 --- /dev/null +++ b/lib/bundle.browser.js @@ -0,0 +1,23 @@ +/*eslint-env browser, amd, commonjs*/ +/*global module*/ + +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _index = require('./index'); + +var _index2 = _interopRequireDefault(_index); + +if (typeof window === 'object') { + window.thread = _index2['default']; +} + +if (typeof define === 'function') { + define([], function () { + return _index2['default']; + }); +} else if (typeof module === 'object') { + module.exports = _index2['default']; +} +//# sourceMappingURL=bundle.browser.js.map \ No newline at end of file diff --git a/lib/bundle.browser.js.map b/lib/bundle.browser.js.map new file mode 100644 index 00000000..12e96271 --- /dev/null +++ b/lib/bundle.browser.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["bundle.browser.js"],"names":[],"mappings":";;;;;;;qBAGsB,SAAS;;;;AAE/B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC9B,QAAM,CAAC,MAAM,qBAAY,CAAC;CAC3B;;AAED,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;AAChC,QAAM,CAAC,EAAE,EAAE,YAAW;AAAE,8BAAiB;GAAE,CAAC,CAAC;CAC9C,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AACrC,QAAM,CAAC,OAAO,qBAAY,CAAC;CAC5B","file":"bundle.browser.js","sourcesContent":["/*eslint-env browser, amd, commonjs*/\n/*global module*/\n\nimport threadLib from './index';\n\nif (typeof window === 'object') {\n window.thread = threadLib;\n}\n\nif (typeof define === 'function') {\n define([], function() { return threadLib; });\n} else if (typeof module === 'object') {\n module.exports = threadLib;\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/config.js.map b/lib/config.js.map new file mode 100644 index 00000000..85b89884 --- /dev/null +++ b/lib/config.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAAE;;AAC1D,QAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AACvC,QAAI,QAAQ,GAAG,MAAM,CAAE,OAAO,CAAE,CAAC;AACjC,QAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC,CAAC;;AAE/D,QAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAChC,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,WAAW,IAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AACvF,cAAM,IAAI,KAAK,CAAC,gDAAgD,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OACpG;AACD,qBAAe,CAAC,OAAO,CAAE,OAAO,CAAE,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;KACrE,MAAM;AACL,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AAC1C,cAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OAChG;AACD,aAAO,CAAE,OAAO,CAAE,GAAG,QAAQ,CAAC;KAC/B;GACF,CAAC,CAAC;CACJ;;AAED,IAAM,MAAM,GAAG;AACb,KAAG,EAAE;WAAM,aAAa;GAAA;;AAExB,KAAG,EAAE,aAAC,SAAS,EAAK;AAClB,QAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,YAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;;AAED,mBAAe,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;GAC3C;CACF,CAAC;;qBAEa,MAAM;;AAEd,SAAS,SAAS,GAAI;AAC3B,SAAO,MAAM,CAAC,GAAG,EAAE,CAAC;CACrB;;AAEM,SAAS,SAAS,GAAW;oCAAN,IAAI;AAAJ,QAAI;;;AAChC,SAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACvC","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set.apply(config, args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/genericworker.browser.js b/lib/genericworker.browser.js new file mode 100644 index 00000000..10752b07 --- /dev/null +++ b/lib/genericworker.browser.js @@ -0,0 +1,82 @@ +/*eslint-env browser*/ + +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _workerJs = require('./worker.js'); + +var _workerJs2 = _interopRequireDefault(_workerJs); + +var slaveCode = 'this._thread = {' + ' methodId : 0,' + ' method : function () {}' + '};' + 'this.onmessage = function (event) {' + ' if (event.data.methodId !== this._thread.methodId) {' + ' var method = event.data.method;' + ' this._thread.method = Function.apply(null, method.args.concat(method.body));' + ' this._thread.methodId = event.data.methodId;' + ' ' + ' var scripts = event.data.importScripts;' + ' if (scripts.length > 0) {' + ' if (typeof importScripts !== "function") {' + ' throw new Error("importScripts not supported.");' + ' }' + ' importScripts.apply(null, scripts);' + ' }' + ' }' + ' this._thread.method(event.data.parameter, function(result) {' + ' postMessage(result);' + ' });' + '}'; + +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode); + +var GenericWorker = (function (_Worker) { + _inherits(GenericWorker, _Worker); + + function GenericWorker() { + _classCallCheck(this, GenericWorker); + + _get(Object.getPrototypeOf(GenericWorker.prototype), 'constructor', this).call(this, slaveCodeDataUri); + this.method = null; + this.methodId = 0; + this.importScripts = []; + } + + _createClass(GenericWorker, [{ + key: 'run', + value: function run(method) { + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + if (importScripts.length === 0 && this.importScripts.length === 0) { + // eliminate the case `both are empty array, but different array instances` + importScripts = this.importScripts; + } + + if (method === this.method && importScripts === this.importScripts) { + return this; + } + + this.method = method; + this.methodId++; + + return this; + } + }, { + key: 'send', + value: function send(param) { + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + if (!this.method) { + throw new Error('Call run() on generic worker before you send().'); + } + + _get(Object.getPrototypeOf(GenericWorker.prototype), 'send', this).call(this, { + method: this.method, + methodId: this.methodId, + importScripts: this.importScripts, + param: param + }, transferables); + + return this; + } + }]); + + return GenericWorker; +})(_workerJs2['default']); + +exports['default'] = GenericWorker; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map new file mode 100644 index 00000000..0eee3a29 --- /dev/null +++ b/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;QACN,MAAM;;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\nexport { Worker }; // needed for testing\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\n// TODO: export Pool\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/slave.node.js b/lib/slave.node.js new file mode 100644 index 00000000..8836305a --- /dev/null +++ b/lib/slave.node.js @@ -0,0 +1,9 @@ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _process = require('process'); + +var _process2 = _interopRequireDefault(_process); + +_process2['default'].on('message', function (data) {}); \ No newline at end of file diff --git a/lib/worker.browser.js b/lib/worker.browser.js index b5d65250..0b21d287 100644 --- a/lib/worker.browser.js +++ b/lib/worker.browser.js @@ -6,14 +6,61 @@ Object.defineProperty(exports, '__esModule', { value: true }); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } -var Worker = function Worker() { - _classCallCheck(this, Worker); +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +if (typeof window.Worker !== 'object') { + throw new Error('Browser does not support web workers!'); +} + +var Worker = (function (_EventEmitter) { + _inherits(Worker, _EventEmitter); + + function Worker(url) { + _classCallCheck(this, Worker); + + _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + + this.worker = new Worker(url); + this.setupListeners(); + } + + _createClass(Worker, [{ + key: 'send', + value: function send(param) { + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.worker.postMessage(param, transferables); + return this; + } + }, { + key: 'kill', + value: function kill() { + this.worker.terminate(); + this.emit('exit'); + return this; + } + }, { + key: 'setupListeners', + value: function setupListeners() { + this.worker.addEventListener('message', this.emit.bind(this, 'message')); + this.worker.addEventListener('error', this.emit.bind(this, 'error')); + } + }]); - // TODO - console.log('Browser worker.'); -}; + return Worker; +})(_eventemitter32['default']); exports['default'] = Worker; module.exports = exports['default']; \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js new file mode 100644 index 00000000..dc76e990 --- /dev/null +++ b/lib/worker.browser/worker.js @@ -0,0 +1,121 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _slaveJsTxt = require('./slave.js.txt'); + +var _slaveJsTxt2 = _interopRequireDefault(_slaveJsTxt); + +var _config = require('../config'); + +if (typeof window.Worker !== 'object') { + throw new Error('Browser does not support web workers!'); +} + +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveJsTxt2['default']); + +function prependScriptUrl(scriptUrl) { + var prefix = (0, _config.getConfig)().basepath.web; + return prefix ? prefix + '/' + scriptUrl : scriptUrl; +} + +var Worker = (function (_EventEmitter) { + _inherits(Worker, _EventEmitter); + + function Worker() { + var initialScript = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + _classCallCheck(this, Worker); + + _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + + this.worker = new Worker(slaveCodeDataUri); + this.setupListeners(); + + if (initialScript) { + this.run(initialScript, importScripts); + } + } + + _createClass(Worker, [{ + key: 'run', + value: function run(toRun) { + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + if (typeof toRun === 'function') { + this.runMethod(toRun, importScripts); + } else { + this.runScripts(toRun, importScripts); + } + return this; + } + }, { + key: 'runMethod', + value: function runMethod(method, importScripts) { + this.worker.postMessage({ + initByMethod: true, + scripts: importScripts + }); + } + }, { + key: 'runScripts', + value: function runScripts(script, importScripts) { + if (!script) { + throw new Error('Must pass a function or a script URL to run().'); + } + + // attention: array for browser, single script for node + this.worker.postMessage({ + initByScripts: true, + scripts: importScripts.concat([script]).map(prependScriptUrl) + }); + } + }, { + key: 'send', + value: function send(param) { + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.worker.postMessage({ + doRun: true, + param: param + }, transferables); + return this; + } + }, { + key: 'kill', + value: function kill() { + this.worker.terminate(); + this.emit('exit'); + return this; + } + }, { + key: 'setupListeners', + value: function setupListeners() { + this.worker.addEventListener('message', this.emit.bind(this, 'message')); + this.worker.addEventListener('error', this.emit.bind(this, 'error')); + } + }]); + + return Worker; +})(_eventemitter32['default']); + +exports['default'] = Worker; +module.exports = exports['default']; +//# sourceMappingURL=../worker.browser/worker.js.map \ No newline at end of file diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map new file mode 100644 index 00000000..654c3d9d --- /dev/null +++ b/lib/worker.browser/worker.js.map @@ -0,0 +1 @@ +{"version":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B,CAAC,CAAC;KACJ;;;WAES,oBAAC,MAAM,EAAE,aAAa,EAAE;AAChC,UAAI,CAAC,MAAM,EAAE;AAAE,cAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;OAAE;;;AAGnF,UAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AACtB,qBAAa,EAAG,IAAI;AACpB,eAAO,EAAS,aAAa,CAAC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;OACvE,CAAC,CAAC;KACJ;;;WAEG,cAAC,KAAK,EAAsB;UAApB,aAAa,yDAAG,EAAE;;AAC5B,UAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AACtB,aAAK,EAAG,IAAI;AACZ,aAAK,EAAL,KAAK;OACN,EAAE,aAAa,CAAC,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;AACxB,UAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEa,0BAAG;AACf,UAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AACzE,UAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;KACtE;;;SAvDkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave.js.txt';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new Worker(slaveCodeDataUri);\n this.setupListeners();\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n this.worker.postMessage({\n initByMethod : true,\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n setupListeners() {\n this.worker.addEventListener('message', this.emit.bind(this, 'message'));\n this.worker.addEventListener('error', this.emit.bind(this, 'error'));\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.js b/lib/worker.js old mode 100755 new mode 100644 index 044ac0e4..aa06af3e --- a/lib/worker.js +++ b/lib/worker.js @@ -1,4 +1,8 @@ -/*eslint-env node*/ +/* + * This file is only a stub to make './worker' resolve the './worker.node/worker' module. + * Loading the browser worker into the browser bundle is done in the gulpfile by + * configuring a browserify override. + */ 'use strict'; @@ -6,14 +10,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var Worker = function Worker() { - _classCallCheck(this, Worker); +var _workerNodeWorker = require('./worker.node/worker'); - // TODO - console.log('Node worker.'); -}; +var _workerNodeWorker2 = _interopRequireDefault(_workerNodeWorker); -exports['default'] = Worker; -module.exports = exports['default']; \ No newline at end of file +exports['default'] = _workerNodeWorker2['default']; +module.exports = exports['default']; +//# sourceMappingURL=worker.js.map \ No newline at end of file diff --git a/lib/worker.js.map b/lib/worker.js.map new file mode 100644 index 00000000..71df0f8b --- /dev/null +++ b/lib/worker.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;gCAMmB,sBAAsB","file":"worker.js","sourcesContent":["/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nimport Worker from './worker.node/worker';\n\nexport default Worker;\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node.js b/lib/worker.node.js index 044ac0e4..ad9e7758 100644 --- a/lib/worker.node.js +++ b/lib/worker.node.js @@ -6,14 +6,60 @@ Object.defineProperty(exports, '__esModule', { value: true }); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } -var Worker = function Worker() { - _classCallCheck(this, Worker); +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _child_process = require('child_process'); + +var _child_process2 = _interopRequireDefault(_child_process); + +var _path = require('path'); + +var _path2 = _interopRequireDefault(_path); + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var Worker = (function (_EventEmitter) { + _inherits(Worker, _EventEmitter); + + function Worker(url) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + _classCallCheck(this, Worker); + + _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + + this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.node.js'), [url], options); + this.slave.on('message', this.emit.bind(this, 'message')); + this.slave.on('error', this.emit.bind(this, 'error')); + this.slave.on('exit', this.emit.bind(this, 'exit')); + } + + _createClass(Worker, [{ + key: 'send', + value: function send(param) { + this.slave.send(param); + return this; + } + }, { + key: 'kill', + value: function kill() { + this.slave.kill(); + return this; + } + }]); - // TODO - console.log('Node worker.'); -}; + return Worker; +})(_eventemitter32['default']); exports['default'] = Worker; module.exports = exports['default']; \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js new file mode 100644 index 00000000..9487b4d7 --- /dev/null +++ b/lib/worker.node/slave.js @@ -0,0 +1,61 @@ +// not using ES6 import/export syntax, since we need to require() in a handler +// what the ES6 syntax does not permit +'use strict'; + +var vm = require('vm'); + +var errorCatcherInPlace = false; +var messageHandler = function messageHandler() { + console.error('No thread logic initialized.'); // eslint-disable-line no-console +}; + +function setupErrorCatcher() { + if (errorCatcherInPlace) { + return; + } + + process.on('uncaughtException', function (error) { + process.send({ + error: { message: error.message, stack: error.stack } + }); + }); + + errorCatcherInPlace = true; +} + +function runAsSandboxedModule(code) { + var sandbox = { + Buffer: Buffer, + console: console, + clearInterval: clearInterval, + clearTimeout: clearTimeout, + module: { exports: null }, + require: require, + setInterval: setInterval, + setTimeout: setTimeout + }; + + vm.runInNewContext(code, sandbox); + return sandbox.module.exports; +} + +process.on('message', function (data) { + if (data.initByScript) { + messageHandler = require(data.script); + } + + if (data.initByMethod) { + messageHandler = runAsSandboxedModule('module.exports = ' + data.method); + } + + if (data.doRun) { + // it's a good idea to wait until first thread logic run to set this up, + // so initialization errors will be printed to console + setupErrorCatcher(); + + messageHandler(data.param, function (response) { + process.send({ response: response }); + }); + } +}); +//# sourceMappingURL=../worker.node/slave.js.map \ No newline at end of file diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map new file mode 100644 index 00000000..2330059c --- /dev/null +++ b/lib/worker.node/slave.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,UAAA,QAAQ,EAAI;AACrC,aAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAR,QAAQ,EAAE,CAAC,CAAC;KAC5B,CAAC,CAAC;GACJ;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, response => {\n process.send({ response });\n });\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js new file mode 100644 index 00000000..facc4109 --- /dev/null +++ b/lib/worker.node/worker.js @@ -0,0 +1,121 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _child_process = require('child_process'); + +var _child_process2 = _interopRequireDefault(_child_process); + +var _path = require('path'); + +var _path2 = _interopRequireDefault(_path); + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _config = require('../config'); + +var Worker = (function (_EventEmitter) { + _inherits(Worker, _EventEmitter); + + function Worker(initialRunnable) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + _classCallCheck(this, Worker); + + _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + + this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.js'), [], options); + this.slave.on('message', this.handleMessage.bind(this)); + this.slave.on('error', this.emit.bind(this, 'error')); + this.slave.on('exit', this.emit.bind(this, 'exit')); + + if (initialRunnable) { + this.run(initialRunnable); + } + } + + _createClass(Worker, [{ + key: 'run', + value: function run(toRun) { + if (typeof toRun === 'function') { + this.runMethod(toRun); + } else { + this.runScript(toRun); + } + return this; + } + }, { + key: 'runMethod', + value: function runMethod(method) { + this.slave.send({ + initByMethod: true, + method: method.toString() + }); + } + }, { + key: 'runScript', + value: function runScript(script) { + if (!script) { + throw new Error('Must pass a function or a script path to run().'); + } + + var prefixedScriptPath = _path2['default'].join((0, _config.getConfig)().basepath.node, script); + + // attention: single script for node, array for browser + this.slave.send({ + initByScript: true, + script: _path2['default'].resolve(prefixedScriptPath) + }); + } + }, { + key: 'send', + value: function send(param) { + this.slave.send({ + doRun: true, + param: param + }); + return this; + } + }, { + key: 'kill', + value: function kill() { + this.slave.kill(); + return this; + } + }, { + key: 'handleMessage', + value: function handleMessage(message) { + if (message.error) { + var error = new Error(message.error.message); + error.stack = message.error.stack; + + if (!this.listeners('error', true)) { + console.error(error.stack); // eslint-disable-line no-console + } + this.emit('error', error); + } else { + this.emit('message', message.response); + } + } + }]); + + return Worker; +})(_eventemitter32['default']); + +exports['default'] = Worker; +module.exports = exports['default']; +//# sourceMappingURL=../worker.node/worker.js.map \ No newline at end of file diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map new file mode 100644 index 00000000..771af8d1 --- /dev/null +++ b/lib/worker.node/worker.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACtD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;eAZkB,MAAM;;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AAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B;AACD,YAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;OAC3B,MAAM;AACL,YAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;OACxC;KACF;;;SAnEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.emit.bind(this, 'error'));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n if (!this.listeners('error', true)) {\n console.error(error.stack); // eslint-disable-line no-console\n }\n this.emit('error', error);\n } else {\n this.emit('message', message.response);\n }\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/package.json b/package.json index df58a86e..e9646ab7 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,42 @@ { - "name" : "thread.js", - "version" : "0.1.0", - "keywords" : [ + "name": "thread.js", + "version": "0.1.0", + "keywords": [ "thread", - "cluster", "web worker", + "cluster", + "child_process", "threadpool", "spawn", "fork", "parallel" ], - "description" : "Easy to use multi-threading library for node.js and the browser.", - "author" : "Andy Wermke ", - "license" : "MIT", - "main" : "lib/index.js", - "bugs" : { - "url" : "https://github.com/andywer/thread.js/issues" + "description": "Easy to use multi-threading library for node.js and the browser.", + "author": "Andy Wermke ", + "license": "MIT", + "main": "lib/index.js", + "bugs": { + "url": "https://github.com/andywer/thread.js/issues" }, - "repository" : { - "type" : "git", - "url" : "https://github.com/andywer/thread.js.git" + "repository": { + "type": "git", + "url": "https://github.com/andywer/thread.js.git" }, - "devDependencies" : { - "browserify" : "^9.0.8", - "gulp" : "^3.8.11", - "gulp-babel" : "^5.2.0", - "gulp-concat" : "^2.5.2", - "gulp-eslint" : "^0.9.0", - "gulp-uglify" : "^1.2.0", - "vinyl-source-stream" : "^1.1.0" + "devDependencies": { + "async": "^1.4.2", + "browserify": "^9.0.8", + "expect.js": "^0.3.1", + "gulp": "^3.8.11", + "gulp-babel": "^5.2.0", + "gulp-concat": "^2.5.2", + "gulp-eslint": "^0.9.0", + "gulp-mocha": "^2.1.3", + "gulp-uglify": "^1.2.0", + "sinon": "^1.16.1", + "stringify": "^3.1.0", + "vinyl-source-stream": "^1.1.0" }, - "dependencies" : { - "eventemitter3" : "^1.1.1" + "dependencies": { + "eventemitter3": "^1.1.1" } } diff --git a/src/bundle.browser.js b/src/bundle.browser.js new file mode 100644 index 00000000..408d3c29 --- /dev/null +++ b/src/bundle.browser.js @@ -0,0 +1,14 @@ +/*eslint-env browser, amd, commonjs*/ +/*global module*/ + +import threadLib from './index'; + +if (typeof window === 'object') { + window.thread = threadLib; +} + +if (typeof define === 'function') { + define([], function() { return threadLib; }); +} else if (typeof module === 'object') { + module.exports = threadLib; +} diff --git a/src/genericworker.js b/src/genericworker.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/worker.browser.js b/src/worker.browser.js deleted file mode 100644 index 64d0c459..00000000 --- a/src/worker.browser.js +++ /dev/null @@ -1,8 +0,0 @@ -/*eslint-env browser*/ - -export default class Worker { - constructor() { - // TODO - console.log('Browser worker.'); - } -} diff --git a/src/worker.browser/.eslintrc b/src/worker.browser/.eslintrc new file mode 100644 index 00000000..21e45029 --- /dev/null +++ b/src/worker.browser/.eslintrc @@ -0,0 +1,5 @@ +{ + "env" : { + "browser" : "true" + } +} diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt new file mode 100644 index 00000000..fae16de9 --- /dev/null +++ b/src/worker.browser/slave.js.txt @@ -0,0 +1,36 @@ +/*eslint-env worker*/ +/*eslint-disable no-console*/ +this.module = { + exports : function() { + if (console) { console.error('No thread logic initialized.'); } + } +}; + +this.onmessage = function (event) { + var scripts = event.data.scripts; + if (scripts && scripts.length > 0 && importScripts !== 'function') { + throw new Error('importScripts() not supported.'); + } + + if (event.data.initByScripts) { + this.module = { exports : {} }; + importScripts.apply(null, scripts); + } + + if (event.data.initByMethod) { + var method = event.data.method; + this.module.exports = Function.apply(null, method.args.concat(method.body)); + + if (scripts && scripts.length > 0) { + importScripts.apply(null, scripts); + } + } + + if (event.data.doRun) { + var handler = this.module.exports; + if (typeof handler !== 'function') { + throw new Error('Cannot run thread logic. No handler has been exported.'); + } + handler(event.data.param, function(response) { this.postMessage(response); }.bind(this)); + } +}; diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js new file mode 100644 index 00000000..ed14bbac --- /dev/null +++ b/src/worker.browser/worker.js @@ -0,0 +1,76 @@ +import EventEmitter from 'eventemitter3'; +import slaveCode from './slave.js.txt'; + +import { getConfig } from '../config'; + + +if (typeof window.Worker !== 'object') { + throw new Error('Browser does not support web workers!'); +} + +const slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode); + + +function prependScriptUrl(scriptUrl) { + const prefix = getConfig().basepath.web; + return prefix ? prefix + '/' + scriptUrl : scriptUrl; +} + + +export default class Worker extends EventEmitter { + constructor(initialScript = null, importScripts = []) { + super(); + + this.worker = new Worker(slaveCodeDataUri); + this.setupListeners(); + + if (initialScript) { + this.run(initialScript, importScripts); + } + } + + run(toRun, importScripts = []) { + if (typeof toRun === 'function') { + this.runMethod(toRun, importScripts); + } else { + this.runScripts(toRun, importScripts); + } + return this; + } + + runMethod(method, importScripts) { + this.worker.postMessage({ + initByMethod : true, + scripts : importScripts + }); + } + + runScripts(script, importScripts) { + if (!script) { throw new Error('Must pass a function or a script URL to run().'); } + + // attention: array for browser, single script for node + this.worker.postMessage({ + initByScripts : true, + scripts : importScripts.concat([ script ]).map(prependScriptUrl) + }); + } + + send(param, transferables = []) { + this.worker.postMessage({ + doRun : true, + param + }, transferables); + return this; + } + + kill() { + this.worker.terminate(); + this.emit('exit'); + return this; + } + + setupListeners() { + this.worker.addEventListener('message', this.emit.bind(this, 'message')); + this.worker.addEventListener('error', this.emit.bind(this, 'error')); + } +} diff --git a/src/worker.js b/src/worker.js deleted file mode 120000 index a26f02f3..00000000 --- a/src/worker.js +++ /dev/null @@ -1 +0,0 @@ -worker.node.js \ No newline at end of file diff --git a/src/worker.js b/src/worker.js new file mode 100644 index 00000000..241e038a --- /dev/null +++ b/src/worker.js @@ -0,0 +1,9 @@ +/* + * This file is only a stub to make './worker' resolve the './worker.node/worker' module. + * Loading the browser worker into the browser bundle is done in the gulpfile by + * configuring a browserify override. + */ + +import Worker from './worker.node/worker'; + +export default Worker; diff --git a/src/worker.node.js b/src/worker.node.js deleted file mode 100644 index 747e59d5..00000000 --- a/src/worker.node.js +++ /dev/null @@ -1,8 +0,0 @@ -/*eslint-env node*/ - -export default class Worker { - constructor() { - // TODO - console.log('Node worker.'); - } -} diff --git a/src/worker.node/.eslintrc b/src/worker.node/.eslintrc new file mode 100644 index 00000000..00f8790c --- /dev/null +++ b/src/worker.node/.eslintrc @@ -0,0 +1,5 @@ +{ + "env" : { + "node" : "true" + } +} diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js new file mode 100644 index 00000000..8a8d4a5d --- /dev/null +++ b/src/worker.node/slave.js @@ -0,0 +1,58 @@ +// not using ES6 import/export syntax, since we need to require() in a handler +// what the ES6 syntax does not permit +const vm = require('vm'); + +let errorCatcherInPlace = false; +let messageHandler = function() { + console.error('No thread logic initialized.'); // eslint-disable-line no-console +}; + +function setupErrorCatcher() { + if (errorCatcherInPlace) { return; } + + process.on('uncaughtException', function(error) { + process.send({ + error : { message : error.message, stack : error.stack } + }); + }); + + errorCatcherInPlace = true; +} + + +function runAsSandboxedModule(code) { + var sandbox = { + Buffer, + console, + clearInterval, + clearTimeout, + module : { exports : null }, + require, + setInterval, + setTimeout + }; + + vm.runInNewContext(code, sandbox); + return sandbox.module.exports; +} + + +process.on('message', function(data) { + if (data.initByScript) { + messageHandler = require(data.script); + } + + if (data.initByMethod) { + messageHandler = runAsSandboxedModule('module.exports = ' + data.method); + } + + if (data.doRun) { + // it's a good idea to wait until first thread logic run to set this up, + // so initialization errors will be printed to console + setupErrorCatcher(); + + messageHandler(data.param, response => { + process.send({ response }); + }); + } +}); diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js new file mode 100644 index 00000000..6718c4d3 --- /dev/null +++ b/src/worker.node/worker.js @@ -0,0 +1,76 @@ +import child from 'child_process'; +import path from 'path'; +import EventEmitter from 'eventemitter3'; + +import { getConfig } from '../config'; + + +export default class Worker extends EventEmitter { + constructor(initialRunnable, options = {}) { + super(); + + this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options); + this.slave.on('message', this.handleMessage.bind(this)); + this.slave.on('error', this.emit.bind(this, 'error')); + this.slave.on('exit', this.emit.bind(this, 'exit')); + + if (initialRunnable) { + this.run(initialRunnable); + } + } + + run(toRun) { + if (typeof toRun === 'function') { + this.runMethod(toRun); + } else { + this.runScript(toRun); + } + return this; + } + + runMethod(method) { + this.slave.send({ + initByMethod : true, + method : method.toString() + }); + } + + runScript(script) { + if (!script) { throw new Error('Must pass a function or a script path to run().'); } + + const prefixedScriptPath = path.join(getConfig().basepath.node, script); + + // attention: single script for node, array for browser + this.slave.send({ + initByScript : true, + script : path.resolve(prefixedScriptPath) + }); + } + + send(param) { + this.slave.send({ + doRun : true, + param + }); + return this; + } + + kill() { + this.slave.kill(); + return this; + } + + handleMessage(message) { + if (message.error) { + const error = new Error(message.error.message); + error.stack = message.error.stack; + + if (!this.listeners('error', true)) { + console.error(error.stack); // eslint-disable-line no-console + } + this.emit('error', error); + } else { + this.emit('message', message.response); + } + } +} From d5d9e69cba2464ae4c3b8827ac95adf6fcc1097f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 29 Aug 2015 12:15:17 +0200 Subject: [PATCH 007/224] Implement config & worker tests (node testing only for now) --- test/spec-src/config.spec.js | 53 +++++++++++ test/spec-src/worker.spec.js | 140 ++++++++++++++++++++++++++++++ test/spec/config.spec.js | 61 +++++++++++++ test/spec/worker.spec.js | 138 +++++++++++++++++++++++++++++ test/thread-scripts/abc-sender.js | 3 + 5 files changed, 395 insertions(+) create mode 100644 test/spec-src/config.spec.js create mode 100644 test/spec-src/worker.spec.js create mode 100644 test/spec/config.spec.js create mode 100644 test/spec/worker.spec.js create mode 100644 test/thread-scripts/abc-sender.js diff --git a/test/spec-src/config.spec.js b/test/spec-src/config.spec.js new file mode 100644 index 00000000..745bb61f --- /dev/null +++ b/test/spec-src/config.spec.js @@ -0,0 +1,53 @@ +import expect from 'expect.js'; +import { config } from '../../lib'; + +function cloneWithMods(obj, callback) { + const clone = JSON.parse(JSON.stringify(obj)); + callback(clone); + + return clone; +} + +describe('Config', () => { + + it('can be read', () => { + const initialConfig = config.get(); + expect(initialConfig).to.be.a('object'); + }); + + it('can override existing properties', () => { + const initialConfig = config.get(); + const newConfigFragment = { + basepath : { web : '/scripts' } + }; + + config.set(newConfigFragment); + const expectedNewConfig = cloneWithMods(initialConfig, (configObj) => { configObj.basepath.web = '/scripts'; }); + + expect(config.get()).to.eql(expectedNewConfig); + }); + + it('can set custom properties', () => { + config.set({ someUnknownProp : 'test' }); + expect(config.get().someUnknownProp).to.eql('test'); + }); + + it('prevents setting a string config to an object', () => { + expect(() => { + config.set({ + basepath : { + web : { illegal : 'object' } + } + }); + }).to.throwError(/Expected config property not to be an object: basepath.web/); + }); + + it('prevents setting an object config to a string', () => { + expect(() => { + config.set({ + basepath : 'no string allowed here' + }); + }).to.throwError(/Expected config property to be an object: basepath/); + }); + +}); diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js new file mode 100644 index 00000000..cdb8ba2c --- /dev/null +++ b/test/spec-src/worker.spec.js @@ -0,0 +1,140 @@ +import async from 'async'; +import expect from 'expect.js'; +import sinon from 'sinon'; +import { config, spawn, Worker } from '../../lib'; + + +const env = typeof window === 'object' ? 'browser' : 'node'; + +function echoThread(param, done) { + done(param); +} + +function canSendAndReceive(worker, dataToSend, expectToRecv, done) { + worker + .once('message', (data) => { + expect(data).to.eql(expectToRecv); + done(); + }) + .send(dataToSend); +} + +function canSendAndReceiveEcho(worker, done) { + const testData = { foo: 'bar' }; + canSendAndReceive(worker, testData, testData, done); +} + + +describe('Worker', () => { + + before(() => { + sinon + .stub(config, 'get') + .returns({ + basepath : { + node : __dirname + '/../thread-scripts', + web : '/thread-scripts' + } + }); + }); + + + it('can be spawned', () => { + const worker = spawn(); + + expect(worker).to.be.a('object'); + expect(worker).to.be.a(Worker); + }); + + it('can be killed', done => { + let spy; + const worker = spawn(); + + // the browser worker owns a worker, the node worker owns a slave + if (env === 'browser') { + spy = sinon.spy(worker.worker, 'terminate'); + } else { + spy = sinon.spy(worker.slave, 'kill'); + } + + worker.on('exit', () => { + expect(spy.calledOnce).to.be.ok(); + done(); + }); + worker.kill(); + }); + + it('can run method (set using spawn())', done => { + const worker = spawn(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can run method (set using .run())', done => { + const worker = spawn().run(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can run script (set using spawn())', (done) => { + const worker = spawn('../thread-scripts/abc-sender.js'); + canSendAndReceive(worker, null, 'abc', done); + }); + + it('can run script (set using .run())', (done) => { + const worker = spawn(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can reset thread code', done => { + const worker = spawn(); + + // .run(code), .send(data), .run(script), .send(data), .run(code), .send(data) + async.series([ + (stepDone) => { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + }, + (stepDone) => { + canSendAndReceive(worker.run('../thread-scripts/abc-sender.js'), null, 'abc', stepDone); + }, + (stepDone) => { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + } + ], done); + }); + + it('can emit error', done => { + const worker = spawn(() => { + throw new Error('Test message'); + }); + + worker.on('error', (error) => { + expect(error.message).to.eql('Test message'); + done(); + }); + worker.send(); + }); + + + if (env === 'node') { + + it('thread code can use setTimeout, setInterval', (done) => { + let messageCount = 0; + + const worker = spawn() + .run((param, threadDone) => { + setTimeout(() => { + setInterval(() => { threadDone(true); }, 10); + }, 20); + }) + .send() + .on('message', (response) => { + messageCount++; + if (messageCount === 3) { + worker.kill(); + done(); + } + }); + }); + + } + +}); diff --git a/test/spec/config.spec.js b/test/spec/config.spec.js new file mode 100644 index 00000000..62c7b228 --- /dev/null +++ b/test/spec/config.spec.js @@ -0,0 +1,61 @@ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _expectJs = require('expect.js'); + +var _expectJs2 = _interopRequireDefault(_expectJs); + +var _lib = require('../../lib'); + +function cloneWithMods(obj, callback) { + var clone = JSON.parse(JSON.stringify(obj)); + callback(clone); + + return clone; +} + +describe('Config', function () { + + it('can be read', function () { + var initialConfig = _lib.config.get(); + (0, _expectJs2['default'])(initialConfig).to.be.a('object'); + }); + + it('can override existing properties', function () { + var initialConfig = _lib.config.get(); + var newConfigFragment = { + basepath: { web: '/scripts' } + }; + + _lib.config.set(newConfigFragment); + var expectedNewConfig = cloneWithMods(initialConfig, function (configObj) { + configObj.basepath.web = '/scripts'; + }); + + (0, _expectJs2['default'])(_lib.config.get()).to.eql(expectedNewConfig); + }); + + it('can set custom properties', function () { + _lib.config.set({ someUnknownProp: 'test' }); + (0, _expectJs2['default'])(_lib.config.get().someUnknownProp).to.eql('test'); + }); + + it('prevents setting a string config to an object', function () { + (0, _expectJs2['default'])(function () { + _lib.config.set({ + basepath: { + web: { illegal: 'object' } + } + }); + }).to.throwError(/Expected config property not to be an object: basepath.web/); + }); + + it('prevents setting an object config to a string', function () { + (0, _expectJs2['default'])(function () { + _lib.config.set({ + basepath: 'no string allowed here' + }); + }).to.throwError(/Expected config property to be an object: basepath/); + }); +}); \ No newline at end of file diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js new file mode 100644 index 00000000..8468d8fa --- /dev/null +++ b/test/spec/worker.spec.js @@ -0,0 +1,138 @@ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _async = require('async'); + +var _async2 = _interopRequireDefault(_async); + +var _expectJs = require('expect.js'); + +var _expectJs2 = _interopRequireDefault(_expectJs); + +var _sinon = require('sinon'); + +var _sinon2 = _interopRequireDefault(_sinon); + +var _lib = require('../../lib'); + +var env = typeof window === 'object' ? 'browser' : 'node'; + +function echoThread(param, done) { + done(param); +} + +function canSendAndReceive(worker, dataToSend, expectToRecv, done) { + worker.once('message', function (data) { + (0, _expectJs2['default'])(data).to.eql(expectToRecv); + done(); + }).send(dataToSend); +} + +function canSendAndReceiveEcho(worker, done) { + var testData = { foo: 'bar' }; + canSendAndReceive(worker, testData, testData, done); +} + +describe('Worker', function () { + + before(function () { + _sinon2['default'].stub(_lib.config, 'get').returns({ + basepath: { + node: __dirname + '/../thread-scripts', + web: '/thread-scripts' + } + }); + }); + + it('can be spawned', function () { + var worker = (0, _lib.spawn)(); + + (0, _expectJs2['default'])(worker).to.be.a('object'); + (0, _expectJs2['default'])(worker).to.be.a(_lib.Worker); + }); + + it('can be killed', function (done) { + var spy = undefined; + var worker = (0, _lib.spawn)(); + + // the browser worker owns a worker, the node worker owns a slave + if (env === 'browser') { + spy = _sinon2['default'].spy(worker.worker, 'terminate'); + } else { + spy = _sinon2['default'].spy(worker.slave, 'kill'); + } + + worker.on('exit', function () { + (0, _expectJs2['default'])(spy.calledOnce).to.be.ok(); + done(); + }); + worker.kill(); + }); + + it('can run method (set using spawn())', function (done) { + var worker = (0, _lib.spawn)(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can run method (set using .run())', function (done) { + var worker = (0, _lib.spawn)().run(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can run script (set using spawn())', function (done) { + var worker = (0, _lib.spawn)('../thread-scripts/abc-sender.js'); + canSendAndReceive(worker, null, 'abc', done); + }); + + it('can run script (set using .run())', function (done) { + var worker = (0, _lib.spawn)(echoThread); + canSendAndReceiveEcho(worker, done); + }); + + it('can reset thread code', function (done) { + var worker = (0, _lib.spawn)(); + + // .run(code), .send(data), .run(script), .send(data), .run(code), .send(data) + _async2['default'].series([function (stepDone) { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + }, function (stepDone) { + canSendAndReceive(worker.run('../thread-scripts/abc-sender.js'), null, 'abc', stepDone); + }, function (stepDone) { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + }], done); + }); + + it('can emit error', function (done) { + var worker = (0, _lib.spawn)(function () { + throw new Error('Test message'); + }); + + worker.on('error', function (error) { + (0, _expectJs2['default'])(error.message).to.eql('Test message'); + done(); + }); + worker.send(); + }); + + if (env === 'node') { + + it('thread code can use setTimeout, setInterval', function (done) { + var messageCount = 0; + + var worker = (0, _lib.spawn)().run(function (param, threadDone) { + setTimeout(function () { + setInterval(function () { + threadDone(true); + }, 10); + }, 20); + }).send().on('message', function (response) { + messageCount++; + if (messageCount === 3) { + worker.kill(); + done(); + } + }); + }); + } +}); \ No newline at end of file diff --git a/test/thread-scripts/abc-sender.js b/test/thread-scripts/abc-sender.js new file mode 100644 index 00000000..78d8b2c4 --- /dev/null +++ b/test/thread-scripts/abc-sender.js @@ -0,0 +1,3 @@ +module.exports = function(param, done) { + done('abc'); +}; From b8e5838ffb8654babcead7e7abb3b7bfca383f66 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 19:40:20 +0200 Subject: [PATCH 008/224] Remove obsolete file remains from lib/ --- lib/genericworker.browser.js | 82 -------------------------------- lib/genericworker.js | 1 - lib/slave.node.js | 9 ---- lib/worker.browser.js | 66 ------------------------- lib/worker.browser/worker.js | 8 ++-- lib/worker.browser/worker.js.map | 2 +- lib/worker.js | 18 +++---- lib/worker.js.map | 2 +- lib/worker.node.js | 65 ------------------------- 9 files changed, 12 insertions(+), 241 deletions(-) delete mode 100644 lib/genericworker.browser.js delete mode 100644 lib/genericworker.js delete mode 100644 lib/slave.node.js delete mode 100644 lib/worker.browser.js delete mode 100644 lib/worker.node.js diff --git a/lib/genericworker.browser.js b/lib/genericworker.browser.js deleted file mode 100644 index 10752b07..00000000 --- a/lib/genericworker.browser.js +++ /dev/null @@ -1,82 +0,0 @@ -/*eslint-env browser*/ - -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _workerJs = require('./worker.js'); - -var _workerJs2 = _interopRequireDefault(_workerJs); - -var slaveCode = 'this._thread = {' + ' methodId : 0,' + ' method : function () {}' + '};' + 'this.onmessage = function (event) {' + ' if (event.data.methodId !== this._thread.methodId) {' + ' var method = event.data.method;' + ' this._thread.method = Function.apply(null, method.args.concat(method.body));' + ' this._thread.methodId = event.data.methodId;' + ' ' + ' var scripts = event.data.importScripts;' + ' if (scripts.length > 0) {' + ' if (typeof importScripts !== "function") {' + ' throw new Error("importScripts not supported.");' + ' }' + ' importScripts.apply(null, scripts);' + ' }' + ' }' + ' this._thread.method(event.data.parameter, function(result) {' + ' postMessage(result);' + ' });' + '}'; - -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode); - -var GenericWorker = (function (_Worker) { - _inherits(GenericWorker, _Worker); - - function GenericWorker() { - _classCallCheck(this, GenericWorker); - - _get(Object.getPrototypeOf(GenericWorker.prototype), 'constructor', this).call(this, slaveCodeDataUri); - this.method = null; - this.methodId = 0; - this.importScripts = []; - } - - _createClass(GenericWorker, [{ - key: 'run', - value: function run(method) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - if (importScripts.length === 0 && this.importScripts.length === 0) { - // eliminate the case `both are empty array, but different array instances` - importScripts = this.importScripts; - } - - if (method === this.method && importScripts === this.importScripts) { - return this; - } - - this.method = method; - this.methodId++; - - return this; - } - }, { - key: 'send', - value: function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - if (!this.method) { - throw new Error('Call run() on generic worker before you send().'); - } - - _get(Object.getPrototypeOf(GenericWorker.prototype), 'send', this).call(this, { - method: this.method, - methodId: this.methodId, - importScripts: this.importScripts, - param: param - }, transferables); - - return this; - } - }]); - - return GenericWorker; -})(_workerJs2['default']); - -exports['default'] = GenericWorker; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/genericworker.js b/lib/genericworker.js deleted file mode 100644 index 9a390c31..00000000 --- a/lib/genericworker.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; \ No newline at end of file diff --git a/lib/slave.node.js b/lib/slave.node.js deleted file mode 100644 index 8836305a..00000000 --- a/lib/slave.node.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _process = require('process'); - -var _process2 = _interopRequireDefault(_process); - -_process2['default'].on('message', function (data) {}); \ No newline at end of file diff --git a/lib/worker.browser.js b/lib/worker.browser.js deleted file mode 100644 index 0b21d287..00000000 --- a/lib/worker.browser.js +++ /dev/null @@ -1,66 +0,0 @@ -/*eslint-env browser*/ - -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -if (typeof window.Worker !== 'object') { - throw new Error('Browser does not support web workers!'); -} - -var Worker = (function (_EventEmitter) { - _inherits(Worker, _EventEmitter); - - function Worker(url) { - _classCallCheck(this, Worker); - - _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); - - this.worker = new Worker(url); - this.setupListeners(); - } - - _createClass(Worker, [{ - key: 'send', - value: function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.worker.postMessage(param, transferables); - return this; - } - }, { - key: 'kill', - value: function kill() { - this.worker.terminate(); - this.emit('exit'); - return this; - } - }, { - key: 'setupListeners', - value: function setupListeners() { - this.worker.addEventListener('message', this.emit.bind(this, 'message')); - this.worker.addEventListener('error', this.emit.bind(this, 'error')); - } - }]); - - return Worker; -})(_eventemitter32['default']); - -exports['default'] = Worker; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index dc76e990..311d4e35 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -18,17 +18,17 @@ var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3); -var _slaveJsTxt = require('./slave.js.txt'); +var _slaveCode = require('./slave-code'); -var _slaveJsTxt2 = _interopRequireDefault(_slaveJsTxt); +var _slaveCode2 = _interopRequireDefault(_slaveCode); var _config = require('../config'); -if (typeof window.Worker !== 'object') { +if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveJsTxt2['default']); +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); function prependScriptUrl(scriptUrl) { var prefix = (0, _config.getConfig)().basepath.web; diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 654c3d9d..889ad9c0 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;0BAClB,gBAAgB;;;;sBAEZ,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;AACrC,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,yBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;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UAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEa,0BAAG;AACf,UAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AACzE,UAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;KACtE;;;SAvDkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave.js.txt';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new Worker(slaveCodeDataUri);\n this.setupListeners();\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n this.worker.postMessage({\n initByMethod : true,\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n setupListeners() {\n this.worker.addEventListener('message', this.emit.bind(this, 'message'));\n this.worker.addEventListener('error', this.emit.bind(this, 'error'));\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC3C,QAAI,CAAC,cAAc,EAAE,CAAC;;AAEtB,QAAI,aAAa,EAAE;AACjB,UAAI,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;KACxC;GACF;;eAVkB,MAAM;;WAYtB,aAAC,KAAK,EAAsB;UAApB,aAAa,yDAAG,EAAE;;AAC3B,UAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAI,CAAC,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;OACtC,MAAM;AACL,YAAI,CAAC,UAAU,CAAC,KAAK,EAAE,aAAa,CA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ode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new Worker(slaveCodeDataUri);\n this.setupListeners();\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n this.worker.postMessage({\n initByMethod : true,\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n setupListeners() {\n this.worker.addEventListener('message', this.emit.bind(this, 'message'));\n this.worker.addEventListener('error', this.emit.bind(this, 'error'));\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.js b/lib/worker.js index aa06af3e..8a858f4a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -1,3 +1,4 @@ +/*global module, require*/ /* * This file is only a stub to make './worker' resolve the './worker.node/worker' module. * Loading the browser worker into the browser bundle is done in the gulpfile by @@ -6,16 +7,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _workerNodeWorker = require('./worker.node/worker'); - -var _workerNodeWorker2 = _interopRequireDefault(_workerNodeWorker); - -exports['default'] = _workerNodeWorker2['default']; -module.exports = exports['default']; +if (typeof window === 'undefined') { + module.exports = require('./worker.node/worker'); +} else { + module.exports = require('./worker.browser/worker'); +} //# sourceMappingURL=worker.js.map \ No newline at end of file diff --git a/lib/worker.js.map b/lib/worker.js.map index 71df0f8b..bcce7316 100644 --- a/lib/worker.js.map +++ b/lib/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;gCAMmB,sBAAsB","file":"worker.js","sourcesContent":["/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nimport Worker from './worker.node/worker';\n\nexport default Worker;\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*global module, require*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof window === 'undefined') {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node.js b/lib/worker.node.js deleted file mode 100644 index ad9e7758..00000000 --- a/lib/worker.node.js +++ /dev/null @@ -1,65 +0,0 @@ -/*eslint-env node*/ - -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _child_process = require('child_process'); - -var _child_process2 = _interopRequireDefault(_child_process); - -var _path = require('path'); - -var _path2 = _interopRequireDefault(_path); - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var Worker = (function (_EventEmitter) { - _inherits(Worker, _EventEmitter); - - function Worker(url) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - _classCallCheck(this, Worker); - - _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); - - this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.node.js'), [url], options); - this.slave.on('message', this.emit.bind(this, 'message')); - this.slave.on('error', this.emit.bind(this, 'error')); - this.slave.on('exit', this.emit.bind(this, 'exit')); - } - - _createClass(Worker, [{ - key: 'send', - value: function send(param) { - this.slave.send(param); - return this; - } - }, { - key: 'kill', - value: function kill() { - this.slave.kill(); - return this; - } - }]); - - return Worker; -})(_eventemitter32['default']); - -exports['default'] = Worker; -module.exports = exports['default']; \ No newline at end of file From 2a5c2e76403dc9476f7016fe8c1c1dcd56b79f78 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 19:41:46 +0200 Subject: [PATCH 009/224] Implement browser tests (not succeeding yet) + new way of requiring a js file as a string --- dist/thread.browser.js | 17 ++++---- dist/thread.browser.min.js | 2 +- gulpfile.js | 42 +++++++++++++++--- karma.conf.js | 75 ++++++++++++++++++++++++++++++++ lib/worker.browser/slave-code.js | 1 + package.json | 10 ++++- src/worker.browser/worker.js | 4 +- src/worker.js | 9 ++-- test/spec-src/config.spec.js | 2 +- test/spec-src/worker.spec.js | 2 +- test/spec/config.spec.js | 18 ++++---- test/spec/worker.spec.js | 24 +++++----- 12 files changed, 160 insertions(+), 46 deletions(-) create mode 100644 karma.conf.js create mode 100644 lib/worker.browser/slave-code.js diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 177dd684..656d73b6 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -22,10 +22,7 @@ if (typeof define === 'function') { module.exports = _index2['default']; } //# sourceMappingURL=bundle.browser.js.map -},{"./index":3}],"./slave.js.txt":[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"; - -},{}],"./worker":[function(require,module,exports){ +},{"./index":3}],"./worker":[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -46,17 +43,17 @@ var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3); -var _slaveJsTxt = require('./slave.js.txt'); +var _slaveCode = require('./slave-code'); -var _slaveJsTxt2 = _interopRequireDefault(_slaveJsTxt); +var _slaveCode2 = _interopRequireDefault(_slaveCode); var _config = require('../config'); -if (typeof window.Worker !== 'object') { +if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveJsTxt2['default']); +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); function prependScriptUrl(scriptUrl) { var prefix = (0, _config.getConfig)().basepath.web; @@ -147,7 +144,7 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; //# sourceMappingURL=../worker.browser/worker.js.map -},{"../config":2,"./slave.js.txt":"./slave.js.txt","eventemitter3":4}],2:[function(require,module,exports){ +},{"../config":2,"./slave-code":4,"eventemitter3":5}],2:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -242,6 +239,8 @@ function spawn() { // TODO: export Pool //# sourceMappingURL=index.js.map },{"./config":2,"./worker":"./worker"}],4:[function(require,module,exports){ +module.exports = "/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"; +},{}],5:[function(require,module,exports){ 'use strict'; // diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index fc834898..a900379c 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(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 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"},{}],"./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("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 s(e){var t=h.getConfig().basepath.web;return t?t+"/"+e:e}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;nn;n++)t[n]=arguments[n];return u.set.apply(u,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},u={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,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]?null:arguments[0];return new a["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),u=e("./worker"),a=r(u);n.config=s["default"],n.Worker=a["default"]},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,u=new Array(s);s>o;o++)u[o]=r[o].fn;return u},o.prototype.emit=function(e,t,n,r,o,s){var u=i?i+e:e;if(!this._events||!this._events[u])return!1;var a,c,f=this._events[u],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,a=new Array(l-1);l>c;c++)a[c-1]=arguments[c];f.fn.apply(f.context,a)}else{var p,h=f.length;for(c=0;h>c;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;default:if(!a)for(p=1,a=new Array(l-1);l>p;p++)a[p-1]=arguments[p];f[c].fn.apply(f[c].context,a)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],u=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&u.push(s);else for(var a=0,c=s.length;c>a;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&u.push(s[a]);return u.length?this._events[o]=1===u.length?u[0]:u:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +require=function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(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;sn;n++)t[n]=arguments[n];return u.set.apply(u,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},u={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,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]?null:arguments[0];return new a["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),u=e("./worker"),a=r(u);n.config=s["default"],n.Worker=a["default"]},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,u=new Array(s);s>o;o++)u[o]=r[o].fn;return u},o.prototype.emit=function(e,t,n,r,o,s){var u=i?i+e:e;if(!this._events||!this._events[u])return!1;var a,c,f=this._events[u],p=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){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,s),!0}for(c=1,a=new Array(p-1);p>c;c++)a[c-1]=arguments[c];f.fn.apply(f.context,a)}else{var l,h=f.length;for(c=0;h>c;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),p){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;default:if(!a)for(l=1,a=new Array(p-1);p>l;l++)a[l-1]=arguments[l];f[c].fn.apply(f[c].context,a)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],u=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&u.push(s);else for(var a=0,c=s.length;c>a;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&u.push(s[a]);return u.length?this._events[o]=1===u.length?u[0]:u:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 68a9e202..e6698bfd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,13 +5,28 @@ var babel = require('gulp-babel'); var browserify = require('browserify'); var concat = require('gulp-concat'); var eslint = require('gulp-eslint'); +var karma = require('karma').server; var mocha = require('gulp-mocha'); +var rename = require('gulp-rename'); var source = require('vinyl-source-stream'); var sourcemaps = require('gulp-sourcemaps'); -var stringify = require('stringify'); +var through = require('through2'); var uglify = require('gulp-uglify'); +function toStringModule() { + return through.obj(function(file, enc, done) { + if (file.isBuffer()) { + var newContents = 'module.exports = ' + JSON.stringify(file.contents.toString(enc)) + ';'; + file.contents = new Buffer(newContents, enc); + } else if (file.isStream()) { + throw new Error('Streams are not yet supported.'); + } + done(null, file); + }); +} + + // Fix for gulp not terminating after mocha finishes gulp.doneCallback = function (err) { process.exit(err ? 1 : 0); @@ -41,12 +56,18 @@ gulp.task('babel-spec', function() { }); -gulp.task('browserify-lib', ['babel-lib'], function() { +gulp.task('browser-slave-module', function() { + return gulp.src('./src/worker.browser/slave.js.txt') + .pipe(toStringModule()) + .pipe(rename('slave-code.js')) + .pipe(gulp.dest('./lib/worker.browser/')); +}); + + +gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], function() { return browserify() - .transform(stringify(['.txt'])) .add('./lib/bundle.browser.js') - .require('./src/worker.browser/slave.js.txt', { expose : './slave.js.txt' }) - .require('./lib/worker.browser/worker.js', { expose : './worker' }) + .require('./lib/worker.browser/worker.js', { expose : './worker' }) // so the node worker won't make it's way into the bundle .bundle() .pipe(source('thread.browser.js')) .pipe(gulp.dest('dist/')); @@ -60,7 +81,14 @@ gulp.task('uglify', ['browserify-lib'], function() { }); -gulp.task('test', ['dist', 'babel-spec'], function() { +gulp.task('test-browser', ['dist', 'babel-spec'], function(done) { + karma.start({ + configFile: __dirname + '/karma.conf.js', + singleRun: true + }, done); +}); + +gulp.task('test-node', ['dist', 'babel-spec'], function() { return gulp.src('test/spec/*.spec.js', { read: false }) .pipe(mocha()); }); @@ -68,4 +96,4 @@ gulp.task('test', ['dist', 'babel-spec'], function() { gulp.task('dist', ['lint', 'browserify-lib', 'uglify']); -gulp.task('default', ['dist', 'test']); +gulp.task('default', ['dist', 'test-node', 'test-browser']); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..ae5399e4 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,75 @@ +// Karma configuration + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['browserify', 'mocha', 'expect'], + + // list of files / patterns to load in the browser + files: [ + 'test/spec/*.spec.js' + ], + + // list of files to exclude + exclude: [ + '**/*.swp' + ], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'test/spec/*.spec.js': ['browserify'] + }, + + browserify: { + debug : true, + configure : function(bundle) { + bundle.on('prebundle', function() { + bundle + .require('./lib/worker.browser/worker.js', { expose : './worker' }) // keep the node worker out of the bundle + }); + } + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_DEBUG, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + + browserNoActivityTimeout: 10000, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; diff --git a/lib/worker.browser/slave-code.js b/lib/worker.browser/slave-code.js new file mode 100644 index 00000000..04c8d8f3 --- /dev/null +++ b/lib/worker.browser/slave-code.js @@ -0,0 +1 @@ +module.exports = "/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"; \ No newline at end of file diff --git a/package.json b/package.json index e9646ab7..30371ebb 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,17 @@ "gulp-concat": "^2.5.2", "gulp-eslint": "^0.9.0", "gulp-mocha": "^2.1.3", + "gulp-rename": "^1.2.2", "gulp-uglify": "^1.2.0", + "karma": "^0.13.9", + "karma-browserify": "^4.3.0", + "karma-chrome-launcher": "^0.2.0", + "karma-expect": "^1.1.0", + "karma-mocha": "^0.2.0", + "karma-phantomjs-launcher": "^0.2.1", + "phantomjs": "^1.9.18", "sinon": "^1.16.1", - "stringify": "^3.1.0", + "through2": "^2.0.0", "vinyl-source-stream": "^1.1.0" }, "dependencies": { diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index ed14bbac..6c8c8f88 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -1,10 +1,10 @@ import EventEmitter from 'eventemitter3'; -import slaveCode from './slave.js.txt'; +import slaveCode from './slave-code'; import { getConfig } from '../config'; -if (typeof window.Worker !== 'object') { +if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } diff --git a/src/worker.js b/src/worker.js index 241e038a..0e62c774 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,9 +1,12 @@ +/*global module, require*/ /* * This file is only a stub to make './worker' resolve the './worker.node/worker' module. * Loading the browser worker into the browser bundle is done in the gulpfile by * configuring a browserify override. */ -import Worker from './worker.node/worker'; - -export default Worker; +if (typeof window === 'undefined') { + module.exports = require('./worker.node/worker'); +} else { + module.exports = require('./worker.browser/worker'); +} diff --git a/test/spec-src/config.spec.js b/test/spec-src/config.spec.js index 745bb61f..d2b2c569 100644 --- a/test/spec-src/config.spec.js +++ b/test/spec-src/config.spec.js @@ -1,5 +1,5 @@ import expect from 'expect.js'; -import { config } from '../../lib'; +import { config } from '../../'; function cloneWithMods(obj, callback) { const clone = JSON.parse(JSON.stringify(obj)); diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index cdb8ba2c..c398c9ff 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -1,7 +1,7 @@ import async from 'async'; import expect from 'expect.js'; import sinon from 'sinon'; -import { config, spawn, Worker } from '../../lib'; +import { config, spawn, Worker } from '../../'; const env = typeof window === 'object' ? 'browser' : 'node'; diff --git a/test/spec/config.spec.js b/test/spec/config.spec.js index 62c7b228..84d3484a 100644 --- a/test/spec/config.spec.js +++ b/test/spec/config.spec.js @@ -6,7 +6,7 @@ var _expectJs = require('expect.js'); var _expectJs2 = _interopRequireDefault(_expectJs); -var _lib = require('../../lib'); +var _ = require('../../'); function cloneWithMods(obj, callback) { var clone = JSON.parse(JSON.stringify(obj)); @@ -18,32 +18,32 @@ function cloneWithMods(obj, callback) { describe('Config', function () { it('can be read', function () { - var initialConfig = _lib.config.get(); + var initialConfig = _.config.get(); (0, _expectJs2['default'])(initialConfig).to.be.a('object'); }); it('can override existing properties', function () { - var initialConfig = _lib.config.get(); + var initialConfig = _.config.get(); var newConfigFragment = { basepath: { web: '/scripts' } }; - _lib.config.set(newConfigFragment); + _.config.set(newConfigFragment); var expectedNewConfig = cloneWithMods(initialConfig, function (configObj) { configObj.basepath.web = '/scripts'; }); - (0, _expectJs2['default'])(_lib.config.get()).to.eql(expectedNewConfig); + (0, _expectJs2['default'])(_.config.get()).to.eql(expectedNewConfig); }); it('can set custom properties', function () { - _lib.config.set({ someUnknownProp: 'test' }); - (0, _expectJs2['default'])(_lib.config.get().someUnknownProp).to.eql('test'); + _.config.set({ someUnknownProp: 'test' }); + (0, _expectJs2['default'])(_.config.get().someUnknownProp).to.eql('test'); }); it('prevents setting a string config to an object', function () { (0, _expectJs2['default'])(function () { - _lib.config.set({ + _.config.set({ basepath: { web: { illegal: 'object' } } @@ -53,7 +53,7 @@ describe('Config', function () { it('prevents setting an object config to a string', function () { (0, _expectJs2['default'])(function () { - _lib.config.set({ + _.config.set({ basepath: 'no string allowed here' }); }).to.throwError(/Expected config property to be an object: basepath/); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 8468d8fa..f77f9eb0 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -14,7 +14,7 @@ var _sinon = require('sinon'); var _sinon2 = _interopRequireDefault(_sinon); -var _lib = require('../../lib'); +var _ = require('../../'); var env = typeof window === 'object' ? 'browser' : 'node'; @@ -37,7 +37,7 @@ function canSendAndReceiveEcho(worker, done) { describe('Worker', function () { before(function () { - _sinon2['default'].stub(_lib.config, 'get').returns({ + _sinon2['default'].stub(_.config, 'get').returns({ basepath: { node: __dirname + '/../thread-scripts', web: '/thread-scripts' @@ -46,15 +46,15 @@ describe('Worker', function () { }); it('can be spawned', function () { - var worker = (0, _lib.spawn)(); + var worker = (0, _.spawn)(); (0, _expectJs2['default'])(worker).to.be.a('object'); - (0, _expectJs2['default'])(worker).to.be.a(_lib.Worker); + (0, _expectJs2['default'])(worker).to.be.a(_.Worker); }); it('can be killed', function (done) { var spy = undefined; - var worker = (0, _lib.spawn)(); + var worker = (0, _.spawn)(); // the browser worker owns a worker, the node worker owns a slave if (env === 'browser') { @@ -71,27 +71,27 @@ describe('Worker', function () { }); it('can run method (set using spawn())', function (done) { - var worker = (0, _lib.spawn)(echoThread); + var worker = (0, _.spawn)(echoThread); canSendAndReceiveEcho(worker, done); }); it('can run method (set using .run())', function (done) { - var worker = (0, _lib.spawn)().run(echoThread); + var worker = (0, _.spawn)().run(echoThread); canSendAndReceiveEcho(worker, done); }); it('can run script (set using spawn())', function (done) { - var worker = (0, _lib.spawn)('../thread-scripts/abc-sender.js'); + var worker = (0, _.spawn)('../thread-scripts/abc-sender.js'); canSendAndReceive(worker, null, 'abc', done); }); it('can run script (set using .run())', function (done) { - var worker = (0, _lib.spawn)(echoThread); + var worker = (0, _.spawn)(echoThread); canSendAndReceiveEcho(worker, done); }); it('can reset thread code', function (done) { - var worker = (0, _lib.spawn)(); + var worker = (0, _.spawn)(); // .run(code), .send(data), .run(script), .send(data), .run(code), .send(data) _async2['default'].series([function (stepDone) { @@ -104,7 +104,7 @@ describe('Worker', function () { }); it('can emit error', function (done) { - var worker = (0, _lib.spawn)(function () { + var worker = (0, _.spawn)(function () { throw new Error('Test message'); }); @@ -120,7 +120,7 @@ describe('Worker', function () { it('thread code can use setTimeout, setInterval', function (done) { var messageCount = 0; - var worker = (0, _lib.spawn)().run(function (param, threadDone) { + var worker = (0, _.spawn)().run(function (param, threadDone) { setTimeout(function () { setInterval(function () { threadDone(true); From d09d727f59fdfd1500cf40dfe76947e6aaa6c327 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 20:06:20 +0200 Subject: [PATCH 010/224] Add missing default export --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index cba0df04..4be80048 100644 --- a/src/index.js +++ b/src/index.js @@ -9,4 +9,8 @@ export function spawn(runnable = null) { return new Worker(runnable); } -// TODO: export Pool +export default { + config, + spawn, + Worker +}; From 003d2d1ca4fcaf7dce091e112945fc1733f21054 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 20:06:47 +0200 Subject: [PATCH 011/224] Fix bug --- src/worker.browser/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 6c8c8f88..cda6ba83 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -21,7 +21,7 @@ export default class Worker extends EventEmitter { constructor(initialScript = null, importScripts = []) { super(); - this.worker = new Worker(slaveCodeDataUri); + this.worker = new window.Worker(slaveCodeDataUri); this.setupListeners(); if (initialScript) { From 9991b7e120af6426ff6080824f51662d7baa0c2d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 20:28:37 +0200 Subject: [PATCH 012/224] New way to launch karma --- gulpfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e6698bfd..16b756c8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,7 @@ var babel = require('gulp-babel'); var browserify = require('browserify'); var concat = require('gulp-concat'); var eslint = require('gulp-eslint'); -var karma = require('karma').server; +var karma = require('karma'); var mocha = require('gulp-mocha'); var rename = require('gulp-rename'); var source = require('vinyl-source-stream'); @@ -82,10 +82,10 @@ gulp.task('uglify', ['browserify-lib'], function() { gulp.task('test-browser', ['dist', 'babel-spec'], function(done) { - karma.start({ + new karma.Server({ configFile: __dirname + '/karma.conf.js', singleRun: true - }, done); + }, done).start(); }); gulp.task('test-node', ['dist', 'babel-spec'], function() { From b8311d44d70da65ced7bb205c397e3f7d2800471 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 30 Aug 2015 20:29:13 +0200 Subject: [PATCH 013/224] Make karma use chrome w/ --disable-web-security --- karma.conf.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index ae5399e4..e40241aa 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -65,7 +65,15 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['ChromeInsecure'], + + + customLaunchers: { + ChromeInsecure: { + base: 'Chrome', + flags: ['--disable-web-security'] + } + }, // Continuous Integration mode From dea235202369cdaffb8554f0786a212da6ed19bc Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:04:19 +0200 Subject: [PATCH 014/224] Allow es6 template strings --- .eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index e0e3b492..059ff402 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,7 +7,8 @@ "destructuring" : true, "jsx" : true, "modules" : true, - "restParams" : true + "restParams" : true, + "templateStrings": true }, "globals" : { "Blob" : true, From 76768dbeaf50ce9bfdcbc9292476a68834b7889a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:05:00 +0200 Subject: [PATCH 015/224] Karma: Serve thread scripts --- karma.conf.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index e40241aa..28bb2a39 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -12,7 +12,8 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'test/spec/*.spec.js' + 'test/spec/*.spec.js', + { pattern : 'test/thread-scripts/*.js', included : false } ], // list of files to exclude @@ -78,6 +79,6 @@ module.exports = function(config) { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: false + singleRun: true }); }; From d53343051bcc5595512a3e64bbec678e7c113351 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:08:27 +0200 Subject: [PATCH 016/224] Fix browser slave code --- src/worker.browser/slave.js.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index fae16de9..505b0835 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -1,4 +1,5 @@ /*eslint-env worker*/ +/*global importScripts*/ /*eslint-disable no-console*/ this.module = { exports : function() { @@ -8,12 +9,11 @@ this.module = { this.onmessage = function (event) { var scripts = event.data.scripts; - if (scripts && scripts.length > 0 && importScripts !== 'function') { + if (scripts && scripts.length > 0 && typeof importScripts !== 'function') { throw new Error('importScripts() not supported.'); } if (event.data.initByScripts) { - this.module = { exports : {} }; importScripts.apply(null, scripts); } @@ -31,6 +31,9 @@ this.onmessage = function (event) { if (typeof handler !== 'function') { throw new Error('Cannot run thread logic. No handler has been exported.'); } - handler(event.data.param, function(response) { this.postMessage(response); }.bind(this)); + + handler(event.data.param, function(response) { + this.postMessage({ response : response }); + }.bind(this)); } -}; +}.bind(this); From 6c179669733875185e2ac61cef1662462647449c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:08:41 +0200 Subject: [PATCH 017/224] Improve worker error handling --- src/worker.browser/worker.js | 33 +++++++++++++++++++++++++++++---- src/worker.node/worker.js | 14 +++++++++----- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index cda6ba83..da80a574 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -22,7 +22,8 @@ export default class Worker extends EventEmitter { super(); this.worker = new window.Worker(slaveCodeDataUri); - this.setupListeners(); + this.worker.addEventListener('message', this.handleMessage.bind(this)); + this.worker.addEventListener('error', this.handleError.bind(this)); if (initialScript) { this.run(initialScript, importScripts); @@ -39,8 +40,13 @@ export default class Worker extends EventEmitter { } runMethod(method, importScripts) { + const methodStr = method.toString(); + const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); + const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); + this.worker.postMessage({ initByMethod : true, + method : { args, body }, scripts : importScripts }); } @@ -69,8 +75,27 @@ export default class Worker extends EventEmitter { return this; } - setupListeners() { - this.worker.addEventListener('message', this.emit.bind(this, 'message')); - this.worker.addEventListener('error', this.emit.bind(this, 'error')); + handleMessage(event) { + if (event.data.error) { + this.handleError(event.data.error); + } else { + this.emit('message', event.data.response); + } + } + + handleError(error) { + if (!this.listeners('error', true)) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + const fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 + ? error.filename.substr(0, 50) + '...' + : error.filename; + console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } + } + this.emit('error', error); } } diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 6718c4d3..d9ba109d 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -11,7 +11,7 @@ export default class Worker extends EventEmitter { this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options); this.slave.on('message', this.handleMessage.bind(this)); - this.slave.on('error', this.emit.bind(this, 'error')); + this.slave.on('error', this.handleError.bind(this)); this.slave.on('exit', this.emit.bind(this, 'exit')); if (initialRunnable) { @@ -65,12 +65,16 @@ export default class Worker extends EventEmitter { const error = new Error(message.error.message); error.stack = message.error.stack; - if (!this.listeners('error', true)) { - console.error(error.stack); // eslint-disable-line no-console - } - this.emit('error', error); + this.handleError(error); } else { this.emit('message', message.response); } } + + handleError(error) { + if (!this.listeners('error', true)) { + console.error(error.stack || error); // eslint-disable-line no-console + } + this.emit('error', error); + } } From f970657f3a804fceea7844145a9c1d8e5a40e98f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:10:05 +0200 Subject: [PATCH 018/224] Fix script paths in worker tests --- test/spec-src/worker.spec.js | 8 ++++---- test/spec/worker.spec.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index c398c9ff..1d783540 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -33,7 +33,7 @@ describe('Worker', () => { .returns({ basepath : { node : __dirname + '/../thread-scripts', - web : '/thread-scripts' + web : 'http://localhost:9876/base/test/thread-scripts' } }); }); @@ -75,7 +75,7 @@ describe('Worker', () => { }); it('can run script (set using spawn())', (done) => { - const worker = spawn('../thread-scripts/abc-sender.js'); + const worker = spawn('abc-sender.js'); canSendAndReceive(worker, null, 'abc', done); }); @@ -93,7 +93,7 @@ describe('Worker', () => { canSendAndReceiveEcho(worker.run(echoThread), stepDone); }, (stepDone) => { - canSendAndReceive(worker.run('../thread-scripts/abc-sender.js'), null, 'abc', stepDone); + canSendAndReceive(worker.run('abc-sender.js'), null, 'abc', stepDone); }, (stepDone) => { canSendAndReceiveEcho(worker.run(echoThread), stepDone); @@ -107,7 +107,7 @@ describe('Worker', () => { }); worker.on('error', (error) => { - expect(error.message).to.eql('Test message'); + expect(error.message).to.match(/^(Uncaught Error: )?Test message$/); done(); }); worker.send(); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index f77f9eb0..582151a8 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -40,7 +40,7 @@ describe('Worker', function () { _sinon2['default'].stub(_.config, 'get').returns({ basepath: { node: __dirname + '/../thread-scripts', - web: '/thread-scripts' + web: 'http://localhost:9876/base/test/thread-scripts' } }); }); @@ -81,7 +81,7 @@ describe('Worker', function () { }); it('can run script (set using spawn())', function (done) { - var worker = (0, _.spawn)('../thread-scripts/abc-sender.js'); + var worker = (0, _.spawn)('abc-sender.js'); canSendAndReceive(worker, null, 'abc', done); }); @@ -97,7 +97,7 @@ describe('Worker', function () { _async2['default'].series([function (stepDone) { canSendAndReceiveEcho(worker.run(echoThread), stepDone); }, function (stepDone) { - canSendAndReceive(worker.run('../thread-scripts/abc-sender.js'), null, 'abc', stepDone); + canSendAndReceive(worker.run('abc-sender.js'), null, 'abc', stepDone); }, function (stepDone) { canSendAndReceiveEcho(worker.run(echoThread), stepDone); }], done); @@ -109,7 +109,7 @@ describe('Worker', function () { }); worker.on('error', function (error) { - (0, _expectJs2['default'])(error.message).to.eql('Test message'); + (0, _expectJs2['default'])(error.message).to.match(/^(Uncaught Error: )?Test message$/); done(); }); worker.send(); From 11547d57000cfdb265ff6c14f86a6f5984becacc Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:11:32 +0200 Subject: [PATCH 019/224] Improve gulp file --- gulpfile.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 16b756c8..9a3a5bc6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -26,6 +26,22 @@ function toStringModule() { }); } +function runKarma(options, done) { + if (typeof options === 'function') { + done = options; + options = {}; + } + options.configFile = __dirname + '/karma.conf.js' + + new karma.Server(options, function(exitCode) { + if (exitCode === 0) { + done(); + } else { + done(new Error('Karma quit with exit code ' + exitCode)); + } + }).start(); +} + // Fix for gulp not terminating after mocha finishes gulp.doneCallback = function (err) { @@ -34,7 +50,7 @@ gulp.doneCallback = function (err) { gulp.task('lint', function() { - return gulp.src('src/**/*.js') + return gulp.src(['src/**/*.js', 'src/**/*.js.txt']) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failOnError()); @@ -82,10 +98,11 @@ gulp.task('uglify', ['browserify-lib'], function() { gulp.task('test-browser', ['dist', 'babel-spec'], function(done) { - new karma.Server({ - configFile: __dirname + '/karma.conf.js', - singleRun: true - }, done).start(); + runKarma(done); +}); + +gulp.task('test-browser-after-node', ['test-node'], function(done) { + runKarma(done); }); gulp.task('test-node', ['dist', 'babel-spec'], function() { @@ -95,5 +112,6 @@ gulp.task('test-node', ['dist', 'babel-spec'], function() { gulp.task('dist', ['lint', 'browserify-lib', 'uglify']); +gulp.task('test', ['test-node', 'test-browser-after-node']); -gulp.task('default', ['dist', 'test-node', 'test-browser']); +gulp.task('default', ['dist', 'test']); From 4b68c8be36ec1924560771cdeea7bafbec1c5b51 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:11:53 +0200 Subject: [PATCH 020/224] Update compiled files --- dist/thread.browser.js | 44 ++++++++++++++++++++++++++------ dist/thread.browser.min.js | 2 +- lib/index.js | 6 ++++- lib/index.js.map | 2 +- lib/worker.browser/slave-code.js | 2 +- lib/worker.browser/worker.js | 36 +++++++++++++++++++++----- lib/worker.browser/worker.js.map | 2 +- lib/worker.node/worker.js | 15 +++++++---- lib/worker.node/worker.js.map | 2 +- 9 files changed, 86 insertions(+), 25 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 656d73b6..43a95a0a 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -71,8 +71,9 @@ var Worker = (function (_EventEmitter) { _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); - this.worker = new Worker(slaveCodeDataUri); - this.setupListeners(); + this.worker = new window.Worker(slaveCodeDataUri); + this.worker.addEventListener('message', this.handleMessage.bind(this)); + this.worker.addEventListener('error', this.handleError.bind(this)); if (initialScript) { this.run(initialScript, importScripts); @@ -94,8 +95,13 @@ var Worker = (function (_EventEmitter) { }, { key: 'runMethod', value: function runMethod(method, importScripts) { + var methodStr = method.toString(); + var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); + var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); + this.worker.postMessage({ initByMethod: true, + method: { args: args, body: body }, scripts: importScripts }); } @@ -131,10 +137,28 @@ var Worker = (function (_EventEmitter) { return this; } }, { - key: 'setupListeners', - value: function setupListeners() { - this.worker.addEventListener('message', this.emit.bind(this, 'message')); - this.worker.addEventListener('error', this.emit.bind(this, 'error')); + key: 'handleMessage', + value: function handleMessage(event) { + if (event.data.error) { + this.handleError(event.data.error); + } else { + this.emit('message', event.data.response); + } + } + }, { + key: 'handleError', + value: function handleError(error) { + if (!this.listeners('error', true)) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } + } + this.emit('error', error); } }]); @@ -236,10 +260,14 @@ function spawn() { return new _worker2['default'](runnable); } -// TODO: export Pool +exports['default'] = { + config: _config2['default'], + spawn: spawn, + Worker: _worker2['default'] +}; //# sourceMappingURL=index.js.map },{"./config":2,"./worker":"./worker"}],4:[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"; +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"; },{}],5:[function(require,module,exports){ 'use strict'; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index a900379c..d6e7de51 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(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;sn;n++)t[n]=arguments[n];return u.set.apply(u,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},u={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,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]?null:arguments[0];return new a["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),u=e("./worker"),a=r(u);n.config=s["default"],n.Worker=a["default"]},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,u=new Array(s);s>o;o++)u[o]=r[o].fn;return u},o.prototype.emit=function(e,t,n,r,o,s){var u=i?i+e:e;if(!this._events||!this._events[u])return!1;var a,c,f=this._events[u],p=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){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,s),!0}for(c=1,a=new Array(p-1);p>c;c++)a[c-1]=arguments[c];f.fn.apply(f.context,a)}else{var l,h=f.length;for(c=0;h>c;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),p){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;default:if(!a)for(l=1,a=new Array(p-1);p>l;l++)a[l-1]=arguments[l];f[c].fn.apply(f[c].context,a)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],u=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&u.push(s);else for(var a=0,c=s.length;c>a;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&u.push(s[a]);return u.length?this._events[o]=1===u.length?u[0]:u:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(f["default"]);n["default"]=v,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var p,h=f.length;for(c=0;h>c;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;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index bfb71d2c..8cf82801 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,5 +25,9 @@ function spawn() { return new _worker2['default'](runnable); } -// TODO: export Pool +exports['default'] = { + config: _config2['default'], + spawn: spawn, + Worker: _worker2['default'] +}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map index 0eee3a29..9060d0fd 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;QACN,MAAM;;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\nexport { Worker }; // needed for testing\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\n// TODO: export Pool\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;QACN,MAAM;;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B;;qBAEc;AACb,QAAM,qBAAA;AACN,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\nexport { Worker }; // needed for testing\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\nexport default {\n config,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.browser/slave-code.js b/lib/worker.browser/slave-code.js index 04c8d8f3..915cc23c 100644 --- a/lib/worker.browser/slave-code.js +++ b/lib/worker.browser/slave-code.js @@ -1 +1 @@ -module.exports = "/*eslint-env worker*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.onmessage = function (event) {\n var scripts = event.data.scripts;\n if (scripts && scripts.length > 0 && importScripts !== 'function') {\n throw new Error('importScripts() not supported.');\n }\n\n if (event.data.initByScripts) {\n this.module = { exports : {} };\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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n handler(event.data.param, function(response) { this.postMessage(response); }.bind(this));\n }\n};\n"; \ No newline at end of file +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"; \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index 311d4e35..ca4fad0c 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -46,8 +46,9 @@ var Worker = (function (_EventEmitter) { _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); - this.worker = new Worker(slaveCodeDataUri); - this.setupListeners(); + this.worker = new window.Worker(slaveCodeDataUri); + this.worker.addEventListener('message', this.handleMessage.bind(this)); + this.worker.addEventListener('error', this.handleError.bind(this)); if (initialScript) { this.run(initialScript, importScripts); @@ -69,8 +70,13 @@ var Worker = (function (_EventEmitter) { }, { key: 'runMethod', value: function runMethod(method, importScripts) { + var methodStr = method.toString(); + var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); + var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); + this.worker.postMessage({ initByMethod: true, + method: { args: args, body: body }, scripts: importScripts }); } @@ -106,10 +112,28 @@ var Worker = (function (_EventEmitter) { return this; } }, { - key: 'setupListeners', - value: function setupListeners() { - this.worker.addEventListener('message', this.emit.bind(this, 'message')); - this.worker.addEventListener('error', this.emit.bind(this, 'error')); + key: 'handleMessage', + value: function handleMessage(event) { + if (event.data.error) { + this.handleError(event.data.error); + } else { + this.emit('message', event.data.response); + } + } + }, { + key: 'handleError', + value: function handleError(error) { + if (!this.listeners('error', true)) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } + } + this.emit('error', error); } }]); diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 889ad9c0..8a565d54 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC3C,QAAI,CAAC,cAAc,EAAE,CAAC;;AAEtB,QAAI,aAAa,EAAE;AACjB,UAAI,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;KACxC;GACF;;eAVkB,MAAM;;WAYtB,aAAC,KAAK,EAAsB;UAApB,aAAa,yDAAG,EAAE;;AAC3B,UAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAI,CAAC,SAAS,CA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KACtE;;;SAvDkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new Worker(slaveCodeDataUri);\n this.setupListeners();\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n this.worker.postMessage({\n initByMethod : true,\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n setupListeners() {\n this.worker.addEventListener('message', this.emit.bind(this, 'message'));\n this.worker.addEventListener('error', this.emit.bind(this, 'error'));\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,K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AE;AACnB,UAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;OACpC,MAAM;AACL,YAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;OAC3C;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,YAAI,KAAK,CAAC,KAAK,EAAE;AACf,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAhFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n this.emit('message', event.data.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index facc4109..3bbd56c5 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -40,7 +40,7 @@ var Worker = (function (_EventEmitter) { this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.js'), [], options); this.slave.on('message', this.handleMessage.bind(this)); - this.slave.on('error', this.emit.bind(this, 'error')); + this.slave.on('error', this.handleError.bind(this)); this.slave.on('exit', this.emit.bind(this, 'exit')); if (initialRunnable) { @@ -103,14 +103,19 @@ var Worker = (function (_EventEmitter) { var error = new Error(message.error.message); error.stack = message.error.stack; - if (!this.listeners('error', true)) { - console.error(error.stack); // eslint-disable-line no-console - } - this.emit('error', error); + this.handleError(error); } else { this.emit('message', message.response); } } + }, { + key: 'handleError', + value: function handleError(error) { + if (!this.listeners('error', true)) { + console.error(error.stack || error); // eslint-disable-line no-console + } + this.emit('error', error); + } }]); return Worker; diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index 771af8d1..bed81696 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;A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AI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEY,uBAAC,OAAO,EAAE;AACrB,UAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,YAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B;AACD,YAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;OAC3B,MAAM;AACL,YAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;OACxC;KACF;;;SAnEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.emit.bind(this, 'error'));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n if (!this.listeners('error', true)) {\n console.error(error.stack); // eslint-disable-line no-console\n }\n this.emit('error', error);\n } else {\n this.emit('message', message.response);\n }\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;eAZkB,MAAM;;WActB,aAAC,KAAK,EAAE;AACT,UAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAI,CA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C,QAAQ,CAAC,CAAC;OACxC;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAvEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file From e5a0f40705f6fbf21ebc9ae92e778d0a982e93c1 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:14:10 +0200 Subject: [PATCH 021/224] Add npm script commands to run gulp --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 30371ebb..7875a7cd 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "fork", "parallel" ], - "description": "Easy to use multi-threading library for node.js and the browser.", + "description": "Easy to use multi-threading library for node.js and the browser!", "author": "Andy Wermke ", "license": "MIT", "main": "lib/index.js", @@ -22,6 +22,10 @@ "type": "git", "url": "https://github.com/andywer/thread.js.git" }, + "scripts": { + "compile": "./node_modules/.bin/gulp dist", + "test": "./node_modules/.bin/gulp test" + }, "devDependencies": { "async": "^1.4.2", "browserify": "^9.0.8", From 0d785dc1ecd7cc6d392c0a09f15d8f65b7f6c183 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:47:05 +0200 Subject: [PATCH 022/224] Allow more than one thread response argument --- dist/thread.browser.js | 17 +++++++++++++++-- dist/thread.browser.min.js | 2 +- lib/worker.browser/slave-code.js | 2 +- lib/worker.browser/worker.js | 15 ++++++++++++++- lib/worker.browser/worker.js.map | 2 +- lib/worker.node/slave.js | 8 ++++++-- lib/worker.node/slave.js.map | 2 +- lib/worker.node/worker.js | 2 +- lib/worker.node/worker.js.map | 2 +- src/worker.browser/slave.js.txt | 4 ++-- src/worker.browser/worker.js | 15 ++++++++++++++- src/worker.node/slave.js | 4 ++-- src/worker.node/worker.js | 2 +- test/spec-src/worker.spec.js | 21 +++++++++++++++++++++ test/spec/worker.spec.js | 20 ++++++++++++++++++++ 15 files changed, 101 insertions(+), 17 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 43a95a0a..dc83c351 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -60,6 +60,18 @@ function prependScriptUrl(scriptUrl) { return prefix ? prefix + '/' + scriptUrl : scriptUrl; } +function convertToArray(input) { + var outputArray = []; + var index = 0; + + while (typeof input[index] !== 'undefined') { + outputArray.push(input[index]); + index++; + } + + return outputArray; +} + var Worker = (function (_EventEmitter) { _inherits(Worker, _EventEmitter); @@ -142,7 +154,8 @@ var Worker = (function (_EventEmitter) { if (event.data.error) { this.handleError(event.data.error); } else { - this.emit('message', event.data.response); + var responseArgs = convertToArray(event.data.response); + this.emit.apply(this, ['message'].concat(responseArgs)); } } }, { @@ -267,7 +280,7 @@ exports['default'] = { }; //# sourceMappingURL=index.js.map },{"./config":2,"./worker":"./worker"}],4:[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"; +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"; },{}],5:[function(require,module,exports){ 'use strict'; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index d6e7de51..3b9143e0 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(f["default"]);n["default"]=v,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var p,h=f.length;for(c=0;h>c;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;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/worker.browser/slave-code.js b/lib/worker.browser/slave-code.js index 915cc23c..3b89ab19 100644 --- a/lib/worker.browser/slave-code.js +++ b/lib/worker.browser/slave-code.js @@ -1 +1 @@ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function(response) {\n this.postMessage({ response : response });\n }.bind(this));\n }\n}.bind(this);\n"; \ No newline at end of file +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"; \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index ca4fad0c..da90fd04 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -35,6 +35,18 @@ function prependScriptUrl(scriptUrl) { return prefix ? prefix + '/' + scriptUrl : scriptUrl; } +function convertToArray(input) { + var outputArray = []; + var index = 0; + + while (typeof input[index] !== 'undefined') { + outputArray.push(input[index]); + index++; + } + + return outputArray; +} + var Worker = (function (_EventEmitter) { _inherits(Worker, _EventEmitter); @@ -117,7 +129,8 @@ var Worker = (function (_EventEmitter) { if (event.data.error) { this.handleError(event.data.error); } else { - this.emit('message', event.data.response); + var responseArgs = convertToArray(event.data.response); + this.emit.apply(this, ['message'].concat(responseArgs)); } } }, { diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 8a565d54..8f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,KAAK,CAAC,CAAC;KAC3B;;;SAhFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n this.emit('message', event.data.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFi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,KAAK,CAAC,KAAK,EAAE;AACf,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit.apply(this, ['message'].concat(responseArgs));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js index 9487b4d7..a9c89ed4 100644 --- a/lib/worker.node/slave.js +++ b/lib/worker.node/slave.js @@ -53,8 +53,12 @@ process.on('message', function (data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, function (response) { - process.send({ response: response }); + messageHandler(data.param, function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + process.send({ response: args }); }); } }); diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map index 2330059c..ca49dfae 100644 --- a/lib/worker.node/slave.js.map +++ b/lib/worker.node/slave.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,UAAA,QAAQ,EAAI;AACrC,aAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAR,QAAQ,EAAE,CAAC,CAAC;KAC5B,CAAC,CAAC;GACJ;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, response => {\n process.send({ response });\n });\n }\n});\n"],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BAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,YAAa;wCAAT,IAAI;AAAJ,YAAI;;;AACjC,aAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;KAClC,CAAC,CAAC;GACJ;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, (...args) => {\n process.send({ response: args });\n });\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index 3bbd56c5..a88c3c1f 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -105,7 +105,7 @@ var Worker = (function (_EventEmitter) { this.handleError(error); } else { - this.emit('message', message.response); + this.emit.apply(this, ['message'].concat(message.response)); } } }, { diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index bed81696..3b8bce82 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;eAZkB,MAAM;;WActB,aAAC,KAAK,EAAE;AACT,UAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;OACvB,MAAM;AACL,YAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;OACvB;AACD,aAAO,IAAI,CAAC;KACb;;;WAEQ,mBAAC,MAAM,EAAE;AAChB,UAAI,CA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AAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAvEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,e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EAAE,MAAM,CAAC,CAAC;;;AAGxE,UAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACd,oBAAY,EAAG,IAAI;AACnB,cAAM,EAAS,kBAAK,OAAO,CAAC,kBAAkB,CAAC;OAChD,CAAC,CAAC;KACJ;;;WAEG,cAAC,KAAK,EAAE;AACV,UAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACd,aAAK,EAAG,IAAI;AACZ,aAAK,EAAL,KAAK;OACN,CAAC,CAAC;AACH,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEY,uBAAC,OAAO,EAAE;AACrB,UAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;OACzB,MAAM;AACL,YAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;OAC7D;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAvEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit.apply(this, ['message'].concat(message.response));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index 505b0835..aefa776a 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -32,8 +32,8 @@ this.onmessage = function (event) { throw new Error('Cannot run thread logic. No handler has been exported.'); } - handler(event.data.param, function(response) { - this.postMessage({ response : response }); + handler(event.data.param, function() { + this.postMessage({ response : arguments }); }.bind(this)); } }.bind(this); diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index da80a574..3ae89435 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -16,6 +16,18 @@ function prependScriptUrl(scriptUrl) { return prefix ? prefix + '/' + scriptUrl : scriptUrl; } +function convertToArray(input) { + let outputArray = []; + let index = 0; + + while (typeof input[index] !== 'undefined') { + outputArray.push(input[index]); + index++; + } + + return outputArray; +} + export default class Worker extends EventEmitter { constructor(initialScript = null, importScripts = []) { @@ -79,7 +91,8 @@ export default class Worker extends EventEmitter { if (event.data.error) { this.handleError(event.data.error); } else { - this.emit('message', event.data.response); + const responseArgs = convertToArray(event.data.response); + this.emit.apply(this, ['message'].concat(responseArgs)); } } diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index 8a8d4a5d..e333aa26 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -51,8 +51,8 @@ process.on('message', function(data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, response => { - process.send({ response }); + messageHandler(data.param, (...args) => { + process.send({ response: args }); }); } }); diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index d9ba109d..53d94c1c 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -67,7 +67,7 @@ export default class Worker extends EventEmitter { this.handleError(error); } else { - this.emit('message', message.response); + this.emit.apply(this, ['message'].concat(message.response)); } } diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 1d783540..bfe444a0 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -84,6 +84,19 @@ describe('Worker', () => { canSendAndReceiveEcho(worker, done); }); + it('can pass more than one argument as response', (done) => { + const worker = spawn((input, done) => { done('a', 'b', 'c'); }); + worker + .send() + .on('message', (a, b, c) => { + expect(a).to.eql('a'); + expect(b).to.eql('b'); + expect(c).to.eql('c'); + worker.kill(); + done(); + }); + }); + it('can reset thread code', done => { const worker = spawn(); @@ -137,4 +150,12 @@ describe('Worker', () => { } + + if (env === 'browser') { + + // TODO: test additional importScripts() + // TODO: test transferables + + } + }); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 582151a8..e2b10f4f 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -90,6 +90,19 @@ describe('Worker', function () { canSendAndReceiveEcho(worker, done); }); + it('can pass more than one argument as response', function (done) { + var worker = (0, _.spawn)(function (input, done) { + done('a', 'b', 'c'); + }); + worker.send().on('message', function (a, b, c) { + (0, _expectJs2['default'])(a).to.eql('a'); + (0, _expectJs2['default'])(b).to.eql('b'); + (0, _expectJs2['default'])(c).to.eql('c'); + worker.kill(); + done(); + }); + }); + it('can reset thread code', function (done) { var worker = (0, _.spawn)(); @@ -135,4 +148,11 @@ describe('Worker', function () { }); }); } + + if (env === 'browser') { + + // TODO: test additional importScripts() + // TODO: test transferables + + } }); \ No newline at end of file From 7e230fb450c03686a6e0f38c4000c1486db24d36 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 00:48:16 +0200 Subject: [PATCH 023/224] Update readme --- readme.md | 92 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/readme.md b/readme.md index dff76d0a..41a099b1 100644 --- a/readme.md +++ b/readme.md @@ -1,14 +1,15 @@ # thread.js -Javascript thread library. Uses web workers when run in browsers and clusters +Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. - Convenience API - For client and server use -- Use different APIs (web worker, shared worker, node cluster) transparently +- Use different APIs (web worker, node child_process) transparently - Thread pools - example use cases -- ES6, but backwards-compatible +- ES6 and backwards-compatible +- Planned features: Shared workers ## How To @@ -19,50 +20,56 @@ when run by node.js. Also supports browsers which do not support web workers. import { spawn } from 'thread.js'; // ES5 syntax: var spawn = require('thread.js').spawn; -const thread = spawn('/path/to/worker.js'); +const thread = spawn(function(input, done) { + // Everything we do here will be run in parallel in another execution context. + // Remember that this function will be executed in the thread's context, + // so you cannot reference any value of the surrounding code. + done({ string : input.string, integer : parseInt(input.string) }); +}); thread - .send({ hello : 'world' }) - .on('message', function(message) { - console.log('Worker sent:', message); + .send({ string : '123' }) + .on('message', function(response) { + console.log('123 * 2 = ', response.integer * 2); + thread.kill(); }) .on('error', function(error) { console.error('Worker errored:', error); }) .on('exit', function() { - console.log('Worker is terminated.'); + console.log('Worker has been terminated.'); }); - -setTimeout(function() { - thread.kill(); -}, 1000); ``` -### Generic worker -Don't provide a worker script, but spawn a generic worker and provide him a -function to execute. This is especially useful for non-complex thread code. +### Thread code in separate files + +You don't have to write the thread's code inline. The file is expected to be a +commonjs module (so something that uses `module.exports = ...`), for node and +browser. ```javascript -import { spawn } from 'thread.js'; -// ES5 syntax: var spawn = require('thread.js').spawn; +import { config, spawn } from 'thread.js'; +// ES5 syntax: var config = require('thread.js').config, spawn = require('thread.js').spawn; + +// Set base paths to thread scripts +config.set({ + basepath : { + browser : 'http://myserver.local/thread-scripts', + node : __dirname + '/../thread-scripts' + } +}); -const thread = spawn(); -// spawn a SharedWorker: `spawn({ shared: true })` +const thread = spawn('worker.js'); thread - .run(function(param, done) { - // remember that this function will be executed in the thread's context, - // so you cannot reference any value of the surrounding code - done(param, param + 1); - }) - .send(1) - .send(2) - .on('message', function(value, valuePlusOne) { - console.log(`${value} + 1 = ${valuePlusOne}`); + .send({ do : 'Something awesome!' }) + .on('message', function(message) { + console.log('Worker sent:', message); }); ``` + ### Thread Pool You can also create a thread pool that spawns a fixed no. of workers. Pass jobs @@ -145,10 +152,11 @@ thread }); ``` -### Import scripts and transferable objects +### Transferable objects -You can also use dependencies in the spawned thread and use transferable objects -to improve performance when passing large buffers (in browser). +You can also use transferable objects to improve performance when passing large +buffers (in browser). Add script files you want to run using importScripts() +(if in browser) as second parameter to thread.run(). See [Transferable Objects: Lightning Fast!](http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast). ```javascript @@ -156,19 +164,25 @@ const largeArrayBuffer = new Uint8Array(1024*1024*32); // 32MB const data = { label : 'huge thing', buffer: largeArrayBuffer.buffer }; thread - .run(function(param, done) { - // do something cool with this.axios + .run(function(input, done) { + // do something cool with input.label, input.buffer done(); - }, { - // dependencies; resolved using node's require() or the web workers importScript() - // the key will be used as key on worker's `this` object - // the value is used similar to require() or es6 import - axios : 'axios' - }) + }, [ + // this file will be run in the thread using importScripts() if in browser + '/dependencies-bundle.js' + ]) // pass the buffers to transfer into thread context as 2nd parameter to send() .send(data, [ largeArrayBuffer.buffer ]); ``` +### Use external dependencies + +TODO +-> gulp task to bundle deps using browserify and expose all of them -> dependency bundle +-> dependency bundle can be imported by importScripts() +-> code can just call `var axios = require('axios');`, no matter if browser or node.js + + ## API You can find the API documentation in the [wiki](https://github.com/andywer/thread.js/wiki). From 13b8bbf69d57a9424ca75f740d3f7128038fb0e1 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 19:57:21 +0200 Subject: [PATCH 024/224] Fix linting --- gulpfile.js | 8 +++++--- test/spec-src/.eslintrc | 10 ++++++++++ test/spec-src/worker.spec.js | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/spec-src/.eslintrc diff --git a/gulpfile.js b/gulpfile.js index 9a3a5bc6..64654893 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,4 @@ +/*eslint-env node*/ 'use strict'; var gulp = require('gulp'); @@ -7,6 +8,7 @@ var concat = require('gulp-concat'); var eslint = require('gulp-eslint'); var karma = require('karma'); var mocha = require('gulp-mocha'); +var path = require('path'); var rename = require('gulp-rename'); var source = require('vinyl-source-stream'); var sourcemaps = require('gulp-sourcemaps'); @@ -31,7 +33,7 @@ function runKarma(options, done) { done = options; options = {}; } - options.configFile = __dirname + '/karma.conf.js' + options.configFile = path.join(__dirname, '/karma.conf.js'); new karma.Server(options, function(exitCode) { if (exitCode === 0) { @@ -45,12 +47,12 @@ function runKarma(options, done) { // Fix for gulp not terminating after mocha finishes gulp.doneCallback = function (err) { - process.exit(err ? 1 : 0); + process.exit(err ? 1 : 0); // eslint-disable-line no-process-exit }; gulp.task('lint', function() { - return gulp.src(['src/**/*.js', 'src/**/*.js.txt']) + return gulp.src(['src/**/*.js', 'src/**/*.js.txt', 'test/spec-src/*.js']) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failOnError()); diff --git a/test/spec-src/.eslintrc b/test/spec-src/.eslintrc new file mode 100644 index 00000000..a010af67 --- /dev/null +++ b/test/spec-src/.eslintrc @@ -0,0 +1,10 @@ +{ + "env" : { + "mocha" : true + }, + "globals" : { + "__dirname" : true, + "setInterval" : true, + "setTimeout" : true + } +} diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index bfe444a0..df41a66f 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -85,7 +85,7 @@ describe('Worker', () => { }); it('can pass more than one argument as response', (done) => { - const worker = spawn((input, done) => { done('a', 'b', 'c'); }); + const worker = spawn((input, threadDone) => { threadDone('a', 'b', 'c'); }); worker .send() .on('message', (a, b, c) => { @@ -139,7 +139,7 @@ describe('Worker', () => { }, 20); }) .send() - .on('message', (response) => { + .on('message', () => { messageCount++; if (messageCount === 3) { worker.kill(); From 63f4d22714bde5073f72746c0139e581b01d3ea5 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 20:39:33 +0200 Subject: [PATCH 025/224] Fix browser worker importScripts() bug --- dist/thread.browser.js | 2 +- dist/thread.browser.min.js | 2 +- lib/worker.browser/worker.js | 2 +- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index dc83c351..e1bc5e20 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -114,7 +114,7 @@ var Worker = (function (_EventEmitter) { this.worker.postMessage({ initByMethod: true, method: { args: args, body: body }, - scripts: importScripts + scripts: importScripts.map(prependScriptUrl) }); } }, { diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 3b9143e0..a9610e93 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index da90fd04..5c8d11b4 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -89,7 +89,7 @@ var Worker = (function (_EventEmitter) { this.worker.postMessage({ initByMethod: true, method: { args: args, body: body }, - scripts: importScripts + scripts: importScripts.map(prependScriptUrl) }); } }, { diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 8fda2656..bb557917 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,S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,IAAI,CAAC,KAAK,EAAE;AACpB,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;OACpC,MAAM;AACL,YAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,YAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;OACzD;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,YAAI,KAAK,CAAC,KAAK,EAAE;AACf,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit.apply(this, ['message'].concat(responseArgs));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC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KAAK,CAAC,KAAK,EAAE;AACf,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit.apply(this, ['message'].concat(responseArgs));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 3ae89435..86260d10 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -59,7 +59,7 @@ export default class Worker extends EventEmitter { this.worker.postMessage({ initByMethod : true, method : { args, body }, - scripts : importScripts + scripts : importScripts.map(prependScriptUrl) }); } From 67fbaebcb81c9550eb9119d1cd3d24ec6597e5a6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 20:40:03 +0200 Subject: [PATCH 026/224] Add importScripts() test case --- test/spec-src/worker.spec.js | 14 +++++++++++++- test/spec/worker.spec.js | 18 +++++++++++++----- test/thread-scripts/import-me.js | 3 +++ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 test/thread-scripts/import-me.js diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index df41a66f..74cac3b3 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -153,7 +153,19 @@ describe('Worker', () => { if (env === 'browser') { - // TODO: test additional importScripts() + it('can importScripts()', (done) => { + const worker = spawn() + .run(function(input, threadDone) { + this.importedEcho(input, threadDone); + }, [ 'import-me.js' ]) + .send('abc') + .on('message', (response) => { + expect(response).to.eql('abc'); + worker.kill(); + done(); + }); + }); + // TODO: test transferables } diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index e2b10f4f..63c63de5 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -91,8 +91,8 @@ describe('Worker', function () { }); it('can pass more than one argument as response', function (done) { - var worker = (0, _.spawn)(function (input, done) { - done('a', 'b', 'c'); + var worker = (0, _.spawn)(function (input, threadDone) { + threadDone('a', 'b', 'c'); }); worker.send().on('message', function (a, b, c) { (0, _expectJs2['default'])(a).to.eql('a'); @@ -139,7 +139,7 @@ describe('Worker', function () { threadDone(true); }, 10); }, 20); - }).send().on('message', function (response) { + }).send().on('message', function () { messageCount++; if (messageCount === 3) { worker.kill(); @@ -151,8 +151,16 @@ describe('Worker', function () { if (env === 'browser') { - // TODO: test additional importScripts() - // TODO: test transferables + it('can importScripts()', function (done) { + var worker = (0, _.spawn)().run(function (input, threadDone) { + this.importedEcho(input, threadDone); + }, ['import-me.js']).send('abc').on('message', function (response) { + (0, _expectJs2['default'])(response).to.eql('abc'); + worker.kill(); + done(); + }); + }); + // TODO: test transferables } }); \ No newline at end of file diff --git a/test/thread-scripts/import-me.js b/test/thread-scripts/import-me.js new file mode 100644 index 00000000..c4e76c41 --- /dev/null +++ b/test/thread-scripts/import-me.js @@ -0,0 +1,3 @@ +this.importedEcho = function(input, done) { + done(input); +}; From 35fa24e7f145d6f4bfe1c1eae91a1034e7620087 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 20:40:22 +0200 Subject: [PATCH 027/224] Update readme --- readme.md | 61 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/readme.md b/readme.md index 41a099b1..9b19e071 100644 --- a/readme.md +++ b/readme.md @@ -16,6 +16,9 @@ when run by node.js. Also supports browsers which do not support web workers. ### Basic use +Spawn threads to do the time-consuming work and let the parent thread focus on +daily business! + ```javascript import { spawn } from 'thread.js'; // ES5 syntax: var spawn = require('thread.js').spawn; @@ -29,6 +32,7 @@ const thread = spawn(function(input, done) { thread .send({ string : '123' }) + // The handlers come here: (none of them is mandatory) .on('message', function(response) { console.log('123 * 2 = ', response.integer * 2); thread.kill(); @@ -65,10 +69,19 @@ const thread = spawn('worker.js'); thread .send({ do : 'Something awesome!' }) .on('message', function(message) { - console.log('Worker sent:', message); + console.log('worker.js replied:', message); }); ``` +worker.js: +```javascript +// Use CommonJS syntax (module.exports). Works in browser, too! +// Only limitation: You won't have require() when run in the browser. +module.exports = function(input, done) { + done('Awesome thread script may run in browser and node.js!'); +}; +``` + ### Thread Pool @@ -80,11 +93,16 @@ import { Pool } from 'thread.js'; // ES5 syntax: var Pool = require('thread.js').Pool; const pool = new Pool(); -const jobA = pool.run('/path/to/worker').send({ do : 'something' }); + +// Run a script +const jobA = pool.run('/path/to/worker') + .send({ do : 'something' }); + +// Run inline code const jobB = pool.run( - function(string, done) { - const hash = md5(string); - done(hash); + function(input, done) { + const hash = md5(input); + done(hash, input); }, { // dependencies; resolved using node's require() or the web workers importScript() md5 : 'js-md5' @@ -92,11 +110,8 @@ const jobB = pool.run( ).send('Hash this string!'); jobA - .on('done', function(message) { - console.log('Job A done:', message); - }) - .on('error', function(error) { - console.error('Job A errored:', error); + .on('done', function(hash, input) { + console.log(`Job A hashed: md5("${input}") = "${hash}"`); }); pool @@ -106,18 +121,9 @@ pool .on('error', function(job, error) { console.error('Job errored:', job); }) - .on('spawn', function(worker, job) { - console.log('Thread pool spawned a new worker:', worker); - }) - .on('kill', function(worker) { - console.log('Thread pool killed a worker:', worker); - }) .on('finished', function() { console.log('Everything done, shutting down the thread pool.'); pool.destroy(); - }) - .on('destroy', function() { - console.log('Thread pool destroyed.'); }); ``` @@ -152,6 +158,22 @@ thread }); ``` +### Retraining + +As it turns out, `thread.run()` is no one-way road. + +```javascript +thread + .run(function doThis(input, done) { + done('My first job!'); + }) + .send() + .run(function doThat(input, done) { + done('Old job was boring. Trying something new!'); + }) + .send(); +``` + ### Transferable objects You can also use transferable objects to improve performance when passing large @@ -169,6 +191,7 @@ thread done(); }, [ // this file will be run in the thread using importScripts() if in browser + // the node.js code will ignore this second parameter '/dependencies-bundle.js' ]) // pass the buffers to transfer into thread context as 2nd parameter to send() From 38ca4444e3d01843f58d9111b1f27a19fe17ccb6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 21:50:15 +0200 Subject: [PATCH 028/224] Implement support for transferables in browser threads --- dist/thread.browser.js | 2 +- dist/thread.browser.min.js | 2 +- lib/worker.browser/slave-code.js | 2 +- lib/worker.node/slave.js | 25 ++++++++++++++++++------- lib/worker.node/slave.js.map | 2 +- src/worker.browser/slave.js.txt | 22 +++++++++++++++++++--- src/worker.node/slave.js | 14 +++++++++++--- test/spec-src/.eslintrc | 4 ++++ test/spec-src/worker.spec.js | 25 ++++++++++++++++++++++++- test/spec/worker.spec.js | 22 +++++++++++++++++++++- 10 files changed, 101 insertions(+), 19 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index e1bc5e20..195641b3 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -280,7 +280,7 @@ exports['default'] = { }; //# sourceMappingURL=index.js.map },{"./config":2,"./worker":"./worker"}],4:[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"; +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"; },{}],5:[function(require,module,exports){ 'use strict'; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index a9610e93..03667393 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./worker"),u=r(a);n.config=s["default"],n.Worker=u["default"],n["default"]={config:s["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +require=function e(t,n,r){function o(i,a){if(!n[i]){if(!t[i]){var u="function"==typeof require&&require;if(!a&&u)return u(i,!0);if(s)return s(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[i]={exports:{}};t[i][0].call(c.exports,function(e){var n=t[i][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[i].exports}for(var s="function"==typeof require&&require,i=0;i50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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 s=t[o],i=n.concat([o]);if("object"==typeof s){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+i.join("."));r(e[o],s,i)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+i.join("."));e[o]=s}})}function o(){return a.get()}function s(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=s;var i={basepath:{node:"",web:""}},a={get:function(){return i},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(i,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var s=e("./config"),i=r(s),a=e("./worker"),u=r(a);n.config=i["default"],n.Worker=u["default"],n["default"]={config:i["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var s="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=s?s+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);i>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,i){var a=s?s+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,i),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),i=s?s+e:e;return this._events||(this._events=s?{}:Object.create(null)),this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],o]:this._events[i].push(o):this._events[i]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),i=s?s+e:e;return this._events||(this._events=s?{}:Object.create(null)),this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],o]:this._events[i].push(o):this._events[i]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=s?s+e:e;if(!this._events||!this._events[o])return this;var i=this._events[o],a=[];if(t)if(i.fn)(i.fn!==t||r&&!i.once||n&&i.context!==n)&&a.push(i);else for(var u=0,f=i.length;f>u;u++)(i[u].fn!==t||r&&!i[u].once||n&&i[u].context!==n)&&a.push(i[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[s?s+e:e]:this._events=s?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=s,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/worker.browser/slave-code.js b/lib/worker.browser/slave-code.js index 3b89ab19..41c2deb3 100644 --- a/lib/worker.browser/slave-code.js +++ b/lib/worker.browser/slave-code.js @@ -1 +1 @@ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nthis.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 if (typeof handler !== 'function') {\n throw new Error('Cannot run thread logic. No handler has been exported.');\n }\n\n handler(event.data.param, function() {\n this.postMessage({ response : arguments });\n }.bind(this));\n }\n}.bind(this);\n"; \ No newline at end of file +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"; \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js index a9c89ed4..a5a13ad8 100644 --- a/lib/worker.node/slave.js +++ b/lib/worker.node/slave.js @@ -39,6 +39,23 @@ function runAsSandboxedModule(code) { return sandbox.module.exports; } +function messageHandlerDone() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + process.send({ response: args }); +} + +messageHandlerDone.transfer = function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + args.pop(); // ignore last parameter, since it's only useful for browser code + messageHandlerDone.apply(null, args); +}; + process.on('message', function (data) { if (data.initByScript) { messageHandler = require(data.script); @@ -53,13 +70,7 @@ process.on('message', function (data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - process.send({ response: args }); - }); + messageHandler(data.param, messageHandlerDone); } }); //# sourceMappingURL=../worker.node/slave.js.map \ No newline at end of file diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map index ca49dfae..8b0c76f4 100644 --- a/lib/worker.node/slave.js.map +++ b/lib/worker.node/slave.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,YAAa;wCAAT,IAAI;AAAJ,YAAI;;;AACjC,aAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;KAClC,CAAC,CAAC;GACJ;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, (...args) => {\n process.send({ response: args });\n });\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,SAAS,kBAAkB,GAAU;oCAAN,IAAI;AAAJ,QAAI;;;AACjC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAClC;;AAED,kBAAkB,CAAC,QAAQ,GAAG,YAAkB;qCAAN,IAAI;AAAJ,QAAI;;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;CACtC,CAAC;;AAGF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;GAChD;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone.apply(null, args);\n};\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone);\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index aefa776a..2b307e3a 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -7,6 +7,21 @@ this.module = { } }; +function handlerDone() { + this.postMessage({ response : arguments }); +} + +function handlerDoneTransfer() { + var args = Array.prototype.slice.call(arguments); + var lastArg = args.pop(); + + if (!(lastArg instanceof Array) && this.console) { + console.error('Expected 2nd parameter of .transfer() to be an array. Got:', lastArg); + } + + this.postMessage({ response : args }, lastArg); +} + this.onmessage = function (event) { var scripts = event.data.scripts; if (scripts && scripts.length > 0 && typeof importScripts !== 'function') { @@ -32,8 +47,9 @@ this.onmessage = function (event) { throw new Error('Cannot run thread logic. No handler has been exported.'); } - handler(event.data.param, function() { - this.postMessage({ response : arguments }); - }.bind(this)); + var preparedHandlerDone = handlerDone.bind(this); + preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); + + handler(event.data.param, preparedHandlerDone); } }.bind(this); diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index e333aa26..c36469df 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -37,6 +37,16 @@ function runAsSandboxedModule(code) { } +function messageHandlerDone(...args) { + process.send({ response: args }); +} + +messageHandlerDone.transfer = function(...args) { + args.pop(); // ignore last parameter, since it's only useful for browser code + messageHandlerDone.apply(null, args); +}; + + process.on('message', function(data) { if (data.initByScript) { messageHandler = require(data.script); @@ -51,8 +61,6 @@ process.on('message', function(data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, (...args) => { - process.send({ response: args }); - }); + messageHandler(data.param, messageHandlerDone); } }); diff --git a/test/spec-src/.eslintrc b/test/spec-src/.eslintrc index a010af67..9b59b79a 100644 --- a/test/spec-src/.eslintrc +++ b/test/spec-src/.eslintrc @@ -4,7 +4,11 @@ }, "globals" : { "__dirname" : true, + "console" : true, "setInterval" : true, "setTimeout" : true + }, + "rules" : { + "no-console" : 1 } } diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 74cac3b3..5c14375e 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -166,7 +166,30 @@ describe('Worker', () => { }); }); - // TODO: test transferables + it('can use transferables', (done) => { + const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB + const arrayBufferClone = new Uint8Array(1024 * 2); + // need to clone, because referencing arrayBuffer will not work after .send() + + for (let index = 0; index < arrayBuffer.byteLength; index++) { + arrayBufferClone[ index ] = arrayBuffer[ index ]; + } + + const worker = spawn(). + run((input, threadDone) => { + threadDone.transfer(input, [ input.data.buffer ]); + }) + .send({ data: arrayBuffer }, [ arrayBuffer.buffer ]) + .on('message', (response) => { + expect(response.data.byteLength).to.equal(arrayBufferClone.byteLength); + for (let index = 0; index < arrayBufferClone.byteLength; index++) { + expect(response.data[ index ]).to.equal(arrayBufferClone[ index ]); + } + + worker.kill(); + done(); + }); + }); } diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 63c63de5..a298bac7 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -161,6 +161,26 @@ describe('Worker', function () { }); }); - // TODO: test transferables + it('can use transferables', function (done) { + var arrayBuffer = new Uint8Array(1024 * 2); // 2 KB + var arrayBufferClone = new Uint8Array(1024 * 2); + // need to clone, because referencing arrayBuffer will not work after .send() + + for (var index = 0; index < arrayBuffer.byteLength; index++) { + arrayBufferClone[index] = arrayBuffer[index]; + } + + var worker = (0, _.spawn)().run(function (input, threadDone) { + threadDone.transfer(input, [input.data.buffer]); + }).send({ data: arrayBuffer }, [arrayBuffer.buffer]).on('message', function (response) { + (0, _expectJs2['default'])(response.data.byteLength).to.equal(arrayBufferClone.byteLength); + for (var index = 0; index < arrayBufferClone.byteLength; index++) { + (0, _expectJs2['default'])(response.data[index]).to.equal(arrayBufferClone[index]); + } + + worker.kill(); + done(); + }); + }); } }); \ No newline at end of file From 5af8cd181b66eeea0eedb1f1b1361acca8dff616 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 21:51:36 +0200 Subject: [PATCH 029/224] Update readme --- readme.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 9b19e071..a96ac032 100644 --- a/readme.md +++ b/readme.md @@ -181,21 +181,25 @@ buffers (in browser). Add script files you want to run using importScripts() (if in browser) as second parameter to thread.run(). See [Transferable Objects: Lightning Fast!](http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast). +Both features will be ignored by node.js version for now. + ```javascript -const largeArrayBuffer = new Uint8Array(1024*1024*32); // 32MB -const data = { label : 'huge thing', buffer: largeArrayBuffer.buffer }; +const largeArrayBuffer = new Uint8Array(1024 * 1024 * 32); // 32MB +const jobData = { label : 'huge thing', data: largeArrayBuffer.buffer }; thread .run(function(input, done) { - // do something cool with input.label, input.buffer - done(); + // do something cool with input.label, input.data + // call done.transfer() if you want to use transferables in the thread's response + // (the node.js code simply ignores the transferables) + done.transfer({ some : { response : input.buffer } }, [input.data.buffer]); }, [ // this file will be run in the thread using importScripts() if in browser // the node.js code will ignore this second parameter '/dependencies-bundle.js' ]) // pass the buffers to transfer into thread context as 2nd parameter to send() - .send(data, [ largeArrayBuffer.buffer ]); + .send(jobData, [ largeArrayBuffer.buffer ]); ``` ### Use external dependencies From 48dac9f279074005f04488aa3b20192bb6309f8d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 31 Aug 2015 23:19:21 +0200 Subject: [PATCH 030/224] Update readme --- readme.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index a96ac032..a43f5daa 100644 --- a/readme.md +++ b/readme.md @@ -95,11 +95,16 @@ import { Pool } from 'thread.js'; const pool = new Pool(); // Run a script -const jobA = pool.run('/path/to/worker') +const jobA = pool + .run('/path/to/worker') .send({ do : 'something' }); +// Run the same script, but with a different parameter +const jobB = pool + .send({ do : 'something else' }); + // Run inline code -const jobB = pool.run( +const jobC = pool.run( function(input, done) { const hash = md5(input); done(hash, input); @@ -109,9 +114,9 @@ const jobB = pool.run( } ).send('Hash this string!'); -jobA +jobC .on('done', function(hash, input) { - console.log(`Job A hashed: md5("${input}") = "${hash}"`); + console.log(`Job C hashed: md5("${input}") = "${hash}"`); }); pool From 3ac3304b4539091f28f6018865ac8b7fc6ad658e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 1 Sep 2015 09:01:47 +0200 Subject: [PATCH 031/224] Remove Worker export from index.js --- lib/index.js | 2 -- lib/index.js.map | 2 +- src/index.js | 1 - test/spec-src/worker.spec.js | 3 ++- test/spec/worker.spec.js | 6 +++++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 8cf82801..9d211189 100644 --- a/lib/index.js +++ b/lib/index.js @@ -16,8 +16,6 @@ var _worker = require('./worker'); var _worker2 = _interopRequireDefault(_worker); exports.config = _config2['default']; -exports.Worker = _worker2['default']; -// needed for testing function spawn() { var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; diff --git a/lib/index.js.map b/lib/index.js.map index 9060d0fd..8122383e 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;QACN,MAAM;;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B;;qBAEc;AACb,QAAM,qBAAA;AACN,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\nexport { Worker }; // needed for testing\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\nexport default {\n config,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B;;qBAEc;AACb,QAAM,qBAAA;AACN,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\nexport default {\n config,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 4be80048..f0a24f5a 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,6 @@ import config from './config'; import Worker from './worker'; export { config }; -export { Worker }; // needed for testing export function spawn(runnable = null) { return new Worker(runnable); diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 5c14375e..13056686 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -1,7 +1,8 @@ import async from 'async'; import expect from 'expect.js'; import sinon from 'sinon'; -import { config, spawn, Worker } from '../../'; +import Worker from '../../lib/worker'; +import { config, spawn } from '../../'; const env = typeof window === 'object' ? 'browser' : 'node'; diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index a298bac7..90fa7abf 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -14,6 +14,10 @@ var _sinon = require('sinon'); var _sinon2 = _interopRequireDefault(_sinon); +var _libWorker = require('../../lib/worker'); + +var _libWorker2 = _interopRequireDefault(_libWorker); + var _ = require('../../'); var env = typeof window === 'object' ? 'browser' : 'node'; @@ -49,7 +53,7 @@ describe('Worker', function () { var worker = (0, _.spawn)(); (0, _expectJs2['default'])(worker).to.be.a('object'); - (0, _expectJs2['default'])(worker).to.be.a(_.Worker); + (0, _expectJs2['default'])(worker).to.be.a(_libWorker2['default']); }); it('can be killed', function (done) { From ebe1f465badef9b22787806ab256c083edb145b2 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 5 Sep 2015 16:52:50 +0200 Subject: [PATCH 032/224] Replace function.apply() by spread operator --- lib/config.js | 6 +----- lib/config.js.map | 2 +- lib/worker.browser/worker.js | 4 +++- lib/worker.browser/worker.js.map | 2 +- lib/worker.node/slave.js | 2 +- lib/worker.node/slave.js.map | 2 +- lib/worker.node/worker.js | 4 +++- lib/worker.node/worker.js.map | 2 +- src/config.js | 2 +- src/worker.browser/worker.js | 2 +- src/worker.node/slave.js | 2 +- src/worker.node/worker.js | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/config.js b/lib/config.js index 2921b61a..743b8527 100644 --- a/lib/config.js +++ b/lib/config.js @@ -54,10 +54,6 @@ function getConfig() { } function setConfig() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return config.set.apply(config, args); + return config.set.apply(config, arguments); } //# sourceMappingURL=config.js.map \ No newline at end of file diff --git a/lib/config.js.map b/lib/config.js.map index 85b89884..007487b0 100644 --- a/lib/config.js.map +++ b/lib/config.js.map @@ -1 +1 @@ -{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAAE;;AAC1D,QAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AACvC,QAAI,QAAQ,GAAG,MAAM,CAAE,OAAO,CAAE,CAAC;AACjC,QAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC,CAAC;;AAE/D,QAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAChC,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,WAAW,IAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AACvF,cAAM,IAAI,KAAK,CAAC,gDAAgD,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OACpG;AACD,qBAAe,CAAC,OAAO,CAAE,OAAO,CAAE,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;KACrE,MAAM;AACL,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AAC1C,cAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OAChG;AACD,aAAO,CAAE,OAAO,CAAE,GAAG,QAAQ,CAAC;KAC/B;GACF,CAAC,CAAC;CACJ;;AAED,IAAM,MAAM,GAAG;AACb,KAAG,EAAE;WAAM,aAAa;GAAA;;AAExB,KAAG,EAAE,aAAC,SAAS,EAAK;AAClB,QAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,YAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;;AAED,mBAAe,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;GAC3C;CACF,CAAC;;qBAEa,MAAM;;AAEd,SAAS,SAAS,GAAI;AAC3B,SAAO,MAAM,CAAC,GAAG,EAAE,CAAC;CACrB;;AAEM,SAAS,SAAS,GAAW;oCAAN,IAAI;AAAJ,QAAI;;;AAChC,SAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACvC","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set.apply(config, args);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AC,yBAAyB,CAAC,CAAC;KAC5C;;AAED,mBAAe,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;GAC3C;CACF,CAAC;;qBAEa,MAAM;;AAEd,SAAS,SAAS,GAAI;AAC3B,SAAO,MAAM,CAAC,GAAG,EAAE,CAAC;CACrB;;AAEM,SAAS,SAAS,GAAW;AAClC,SAAO,MAAM,CAAC,GAAG,MAAA,CAAV,MAAM,YAAa,CAAC;CAC5B","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index 5c8d11b4..aabb3e26 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -10,6 +10,8 @@ var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_a function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -130,7 +132,7 @@ var Worker = (function (_EventEmitter) { this.handleError(event.data.error); } else { var responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(responseArgs)); + this.emit.apply(this, ['message'].concat(_toConsumableArray(responseArgs))); } } }, { diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index bb557917..fc814811 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,M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,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;OACpC,MAAM;AACL,YAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,YAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;OACzD;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,YAAI,KAAK,CAAC,KAAK,EAAE;AACf,iBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit.apply(this, ['message'].concat(responseArgs));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,MAAM,GAAG,IAAI,MAAM,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CAAC,KAAK,CAAC,CAAC;SAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js index a5a13ad8..8a639e32 100644 --- a/lib/worker.node/slave.js +++ b/lib/worker.node/slave.js @@ -53,7 +53,7 @@ messageHandlerDone.transfer = function () { } args.pop(); // ignore last parameter, since it's only useful for browser code - messageHandlerDone.apply(null, args); + messageHandlerDone.apply(undefined, args); }; process.on('message', function (data) { diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map index 8b0c76f4..2d5090ac 100644 --- a/lib/worker.node/slave.js.map +++ b/lib/worker.node/slave.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,SAAS,kBAAkB,GAAU;oCAAN,IAAI;AAAJ,QAAI;;;AACjC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAClC;;AAED,kBAAkB,CAAC,QAAQ,GAAG,YAAkB;qCAAN,IAAI;AAAJ,QAAI;;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;CACtC,CAAC;;AAGF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;GAChD;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone.apply(null, args);\n};\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone);\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,SAAS,kBAAkB,GAAU;oCAAN,IAAI;AAAJ,QAAI;;;AACjC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAClC;;AAED,kBAAkB,CAAC,QAAQ,GAAG,YAAkB;qCAAN,IAAI;AAAJ,QAAI;;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,kBAAI,IAAI,CAAC,CAAC;CAC7B,CAAC;;AAGF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;GAChD;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone);\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index a88c3c1f..88de7687 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -10,6 +10,8 @@ var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_a function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -105,7 +107,7 @@ var Worker = (function (_EventEmitter) { this.handleError(error); } else { - this.emit.apply(this, ['message'].concat(message.response)); + this.emit.apply(this, ['message'].concat(_toConsumableArray(message.response))); } } }, { diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index 3b8bce82..a37387d0 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"m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;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit.apply(this, ['message'].concat(message.response));\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GA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AS,kBAAK,OAAO,CAAC,kBAAkB,CAAC;OAChD,CAAC,CAAC;KACJ;;;WAEG,cAAC,KAAK,EAAE;AACV,UAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACd,aAAK,EAAG,IAAI;AACZ,aAAK,EAAL,KAAK;OACN,CAAC,CAAC;AACH,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEY,uBAAC,OAAO,EAAE;AACrB,UAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;OACzB,MAAM;AACL,YAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,4BAAK,OAAO,CAAC,QAAQ,GAAC,CAAC;OAC3C;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAvEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/config.js b/src/config.js index 8db8be6e..e2f0a9e7 100644 --- a/src/config.js +++ b/src/config.js @@ -43,5 +43,5 @@ export function getConfig () { } export function setConfig (...args) { - return config.set.apply(config, args); + return config.set(...args); } diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 86260d10..7e73086c 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -92,7 +92,7 @@ export default class Worker extends EventEmitter { this.handleError(event.data.error); } else { const responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(responseArgs)); + this.emit('message', ...responseArgs); } } diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index c36469df..72ce467e 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -43,7 +43,7 @@ function messageHandlerDone(...args) { messageHandlerDone.transfer = function(...args) { args.pop(); // ignore last parameter, since it's only useful for browser code - messageHandlerDone.apply(null, args); + messageHandlerDone(...args); }; diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 53d94c1c..51ca6c43 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -67,7 +67,7 @@ export default class Worker extends EventEmitter { this.handleError(error); } else { - this.emit.apply(this, ['message'].concat(message.response)); + this.emit('message', ...message.response); } } From 9e30754ba1f98a993e747caf5f7ede84a1e2660b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 5 Sep 2015 19:28:52 +0200 Subject: [PATCH 033/224] Implement job + tests --- lib/job.js | 117 +++++++++++++++++++++++ lib/job.js.map | 1 + src/job.js | 72 ++++++++++++++ test/spec-src/job.spec.js | 190 ++++++++++++++++++++++++++++++++++++ test/spec/job.spec.js | 196 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 576 insertions(+) create mode 100644 lib/job.js create mode 100644 lib/job.js.map create mode 100644 src/job.js create mode 100644 test/spec-src/job.spec.js create mode 100644 test/spec/job.spec.js diff --git a/lib/job.js b/lib/job.js new file mode 100644 index 00000000..aa2d40ce --- /dev/null +++ b/lib/job.js @@ -0,0 +1,117 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var Job = (function (_EventEmitter) { + _inherits(Job, _EventEmitter); + + function Job(pool) { + _classCallCheck(this, Job); + + _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); + this.pool = pool; + + this.runArgs = []; + this.clearSendParameter(); + + pool.emit('newJob', this); + } + + _createClass(Job, [{ + key: 'run', + value: function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 0) { + throw new Error('Cannot call .run() without arguments.'); + } + + this.runArgs = args; + return this; + } + }, { + key: 'send', + value: function send() { + if (this.runArgs.length === 0) { + throw new Error('Cannot .send() before .run().'); + } + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (this.hasSendParameter()) { + var _clone$clearSendParameter; + + // do not alter this job, clone it and set send param instead + return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); + } + + this.sendArgs = args; + this.parameterSet = true; + + this.emit('readyToRun'); + return this; + } + }, { + key: 'executeOn', + value: function executeOn(thread) { + var _thread$once$once$run, _thread$once$once; + + (_thread$once$once$run = (_thread$once$once = thread.once('done', this.emit.bind(this, 'done')).once('error', this.emit.bind(this, 'error'))).run.apply(_thread$once$once, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + return this; + } + }, { + key: 'clone', + value: function clone() { + var clone = new Job(this.pool); + + if (this.runArgs.length > 0) { + clone.run.apply(clone, _toConsumableArray(this.runArgs)); + } + if (this.parameterSet) { + clone.send.apply(clone, _toConsumableArray(this.sendArgs)); + } + + return clone; + } + }, { + key: 'hasSendParameter', + value: function hasSendParameter() { + return this.parameterSet; + } + }, { + key: 'clearSendParameter', + value: function clearSendParameter() { + this.parameterSet = false; + this.sendArgs = []; + return this; + } + }]); + + return Job; +})(_eventemitter32['default']); + +exports['default'] = Job; +module.exports = exports['default']; +//# sourceMappingURL=job.js.map \ No newline at end of file diff --git a/lib/job.js.map b/lib/job.js.map new file mode 100644 index 00000000..40268796 --- /dev/null +++ b/lib/job.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;eATkB,GAAG;;WAWnB,eAAU;wCAAN,IAAI;AAAJ,YAAI;;;AACT,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,cAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;OAC1D;;AAED,UAAI,CAAC,OAA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AAV,KAAK,qBAAS,IAAI,CAAC,QAAQ,EAAC,CAAC;OAC9B;;AAED,aAAO,KAAK,CAAC;KACd;;;WAEe,4BAAG;AACjB,aAAO,IAAI,CAAC,YAAY,CAAC;KAC1B;;;WAEiB,8BAAG;AACnB,UAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,UAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SAnEkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('done', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n return this;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/job.js b/src/job.js new file mode 100644 index 00000000..93b62ea6 --- /dev/null +++ b/src/job.js @@ -0,0 +1,72 @@ + +import EventEmitter from 'eventemitter3'; + +export default class Job extends EventEmitter { + constructor(pool) { + super(); + this.pool = pool; + + this.runArgs = []; + this.clearSendParameter(); + + pool.emit('newJob', this); + } + + run(...args) { + if (args.length === 0) { + throw new Error('Cannot call .run() without arguments.'); + } + + this.runArgs = args; + return this; + } + + send(...args) { + if (this.runArgs.length === 0) { + throw new Error('Cannot .send() before .run().'); + } + + if (this.hasSendParameter()) { + // do not alter this job, clone it and set send param instead + return this.clone().clearSendParameter().send(...args); + } + + this.sendArgs = args; + this.parameterSet = true; + + this.emit('readyToRun'); + return this; + } + + executeOn(thread) { + thread + .once('done', this.emit.bind(this, 'done')) + .once('error', this.emit.bind(this, 'error')) + .run(...this.runArgs) + .send(...this.sendArgs); + return this; + } + + clone() { + const clone = new Job(this.pool); + + if (this.runArgs.length > 0) { + clone.run(...this.runArgs); + } + if (this.parameterSet) { + clone.send(...this.sendArgs); + } + + return clone; + } + + hasSendParameter() { + return this.parameterSet; + } + + clearSendParameter() { + this.parameterSet = false; + this.sendArgs = []; + return this; + } +} diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js new file mode 100644 index 00000000..bfe43678 --- /dev/null +++ b/test/spec-src/job.spec.js @@ -0,0 +1,190 @@ +import expect from 'expect.js'; +import sinon from 'sinon'; +import EventEmitter from 'eventemitter3'; +import Job from '../../lib/job'; + + +function noop() { + return this; +} + +function createFakeThread(response) { + const thread = new EventEmitter(); + + thread.run = noop; + + if (response.error) { + thread.send = function() { + thread.emit('error', response.error); + }; + } else { + thread.send = function() { + thread.emit('done', ...response.response); + }; + } + + ['on', 'once', 'emit', 'run', 'send'] + .forEach((methodName) => { sinon.spy(thread, methodName); }); + + return thread; +} + + +describe('Job', () => { + let pool; + + beforeEach(() => { + // fake pool + pool = new EventEmitter(); + sinon.spy(pool, 'emit'); + }); + + it('can be created', () => { + const job = new Job(pool); + + expect(job.hasSendParameter()).to.equal(false); + sinon.assert.calledOnce(pool.emit); + sinon.assert.calledWith(pool.emit, 'newJob', job); + }); + + it('throws on .run() without arguments', () => { + const job = new Job(pool); + + expect(() => { job.run(); }).to.throwError(/Cannot call \.run\(\) without arguments/); + }); + + it('throws on .send() before .run()', () => { + const job = new Job(pool); + + expect(() => { job.send(); }).to.throwError(/Cannot \.send\(\) before \.run\(\)/); + }); + + it('triggers readyToRun event on .send()', () => { + const job = new Job(pool); + sinon.spy(job, 'emit'); + + job.run(noop); + sinon.assert.neverCalledWith(job.emit, 'readyToRun'); + job.send(); + sinon.assert.calledWith(job.emit, 'readyToRun'); + }); + + it('can be executed', () => { + const thread = { + once : noop, + run : noop, + send : noop + }; + const mock = sinon.mock(thread); + + const job = new Job(pool); + const runnable = noop; + const importScripts = []; + const param = 'some data'; + const transferables = []; + + mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); + mock.expects('send').once().withArgs(param, transferables).returnsThis(); + + job + .run(runnable, importScripts) + .send(param, transferables) + .executeOn(thread); + + mock.verify(); + }); + + it('triggers done event', () => { + const thread = createFakeThread({ + response : [ { foo: 'bar' }, 'more data' ] + }); + + const job = new Job(pool); + sinon.spy(job, 'emit'); + + job + .run(noop) + .send() + .executeOn(thread); + + sinon.assert.calledWith(job.emit, 'done', { foo: 'bar' }, 'more data'); + }); + + it('triggers error event', () => { + const error = new Error('Epic fail'); + const thread = createFakeThread({ + error : error + }); + + const job = new Job(pool); + sinon.spy(job, 'emit'); + + job + .run(noop) + .send() + .executeOn(thread); + + sinon.assert.calledWith(job.emit, 'error', error); + }); + + it('can clone empty job', () => { + const job = new Job(pool); + const clone = job.clone(); + + expect(clone.runArgs).to.eql(job.runArgs); + expect(clone.sendArgs).to.eql(job.sendArgs); + expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('can clone with runnable (w/o parameter)', () => { + const job = new Job(pool); + const runnable = noop; + const importScripts = []; + + job.run(runnable, importScripts); + const clone = job.clone(); + + expect(clone.runArgs).to.eql(job.runArgs); + expect(clone.sendArgs).to.eql(job.sendArgs); + expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('can clone with runnable & parameter', () => { + const job = new Job(pool); + const runnable = noop; + const importScripts = []; + const param = 'some data'; + const transferables = []; + + job + .run(runnable, importScripts) + .send(param, transferables); + + const clone = job.clone(); + + expect(clone.runArgs).to.eql(job.runArgs); + expect(clone.sendArgs).to.eql(job.sendArgs); + expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('clones on 2nd .send()', () => { + const job = new Job(pool); + const runnable = noop; + const paramA = { foo : 'bar' }; + const paramB = 'foo bar'; + + job + .run(runnable) + .send(paramA); + + const clone = job.send(paramB); + + expect(clone).not.to.equal(job); + expect(clone.runArgs).to.eql(job.runArgs); + expect(clone.sendArgs).to.eql([ paramB ]); + expect(clone.hasSendParameter()).to.equal(true); + expect(job.sendArgs).to.eql([ paramA ]); + expect(job.hasSendParameter()).to.equal(true); + }); + +}); diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js new file mode 100644 index 00000000..81fc02b0 --- /dev/null +++ b/test/spec/job.spec.js @@ -0,0 +1,196 @@ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + +var _expectJs = require('expect.js'); + +var _expectJs2 = _interopRequireDefault(_expectJs); + +var _sinon = require('sinon'); + +var _sinon2 = _interopRequireDefault(_sinon); + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _libJob = require('../../lib/job'); + +var _libJob2 = _interopRequireDefault(_libJob); + +function noop() { + return this; +} + +function createFakeThread(response) { + var thread = new _eventemitter32['default'](); + + thread.run = noop; + + if (response.error) { + thread.send = function () { + thread.emit('error', response.error); + }; + } else { + thread.send = function () { + thread.emit.apply(thread, ['done'].concat(_toConsumableArray(response.response))); + }; + } + + ['on', 'once', 'emit', 'run', 'send'].forEach(function (methodName) { + _sinon2['default'].spy(thread, methodName); + }); + + return thread; +} + +describe('Job', function () { + var pool = undefined; + + beforeEach(function () { + // fake pool + pool = new _eventemitter32['default'](); + _sinon2['default'].spy(pool, 'emit'); + }); + + it('can be created', function () { + var job = new _libJob2['default'](pool); + + (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(false); + _sinon2['default'].assert.calledOnce(pool.emit); + _sinon2['default'].assert.calledWith(pool.emit, 'newJob', job); + }); + + it('throws on .run() without arguments', function () { + var job = new _libJob2['default'](pool); + + (0, _expectJs2['default'])(function () { + job.run(); + }).to.throwError(/Cannot call \.run\(\) without arguments/); + }); + + it('throws on .send() before .run()', function () { + var job = new _libJob2['default'](pool); + + (0, _expectJs2['default'])(function () { + job.send(); + }).to.throwError(/Cannot \.send\(\) before \.run\(\)/); + }); + + it('triggers readyToRun event on .send()', function () { + var job = new _libJob2['default'](pool); + _sinon2['default'].spy(job, 'emit'); + + job.run(noop); + _sinon2['default'].assert.neverCalledWith(job.emit, 'readyToRun'); + job.send(); + _sinon2['default'].assert.calledWith(job.emit, 'readyToRun'); + }); + + it('can be executed', function () { + var thread = { + once: noop, + run: noop, + send: noop + }; + var mock = _sinon2['default'].mock(thread); + + var job = new _libJob2['default'](pool); + var runnable = noop; + var importScripts = []; + var param = 'some data'; + var transferables = []; + + mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); + mock.expects('send').once().withArgs(param, transferables).returnsThis(); + + job.run(runnable, importScripts).send(param, transferables).executeOn(thread); + + mock.verify(); + }); + + it('triggers done event', function () { + var thread = createFakeThread({ + response: [{ foo: 'bar' }, 'more data'] + }); + + var job = new _libJob2['default'](pool); + _sinon2['default'].spy(job, 'emit'); + + job.run(noop).send().executeOn(thread); + + _sinon2['default'].assert.calledWith(job.emit, 'done', { foo: 'bar' }, 'more data'); + }); + + it('triggers error event', function () { + var error = new Error('Epic fail'); + var thread = createFakeThread({ + error: error + }); + + var job = new _libJob2['default'](pool); + _sinon2['default'].spy(job, 'emit'); + + job.run(noop).send().executeOn(thread); + + _sinon2['default'].assert.calledWith(job.emit, 'error', error); + }); + + it('can clone empty job', function () { + var job = new _libJob2['default'](pool); + var clone = job.clone(); + + (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); + (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); + (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('can clone with runnable (w/o parameter)', function () { + var job = new _libJob2['default'](pool); + var runnable = noop; + var importScripts = []; + + job.run(runnable, importScripts); + var clone = job.clone(); + + (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); + (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); + (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('can clone with runnable & parameter', function () { + var job = new _libJob2['default'](pool); + var runnable = noop; + var importScripts = []; + var param = 'some data'; + var transferables = []; + + job.run(runnable, importScripts).send(param, transferables); + + var clone = job.clone(); + + (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); + (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); + (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); + }); + + it('clones on 2nd .send()', function () { + var job = new _libJob2['default'](pool); + var runnable = noop; + var paramA = { foo: 'bar' }; + var paramB = 'foo bar'; + + job.run(runnable).send(paramA); + + var clone = job.send(paramB); + + (0, _expectJs2['default'])(clone).not.to.equal(job); + (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); + (0, _expectJs2['default'])(clone.sendArgs).to.eql([paramB]); + (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(true); + (0, _expectJs2['default'])(job.sendArgs).to.eql([paramA]); + (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(true); + }); +}); \ No newline at end of file From 963a98e32ccce7a3ab62dbbf56b62f2d8d6b334d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 6 Sep 2015 18:14:45 +0200 Subject: [PATCH 034/224] Update readme --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index a43f5daa..7bc65911 100644 --- a/readme.md +++ b/readme.md @@ -46,6 +46,11 @@ thread ``` +### Installation + +TODO: npm, bower, script tag + + ### Thread code in separate files You don't have to write the thread's code inline. The file is expected to be a From 74fa8fbe338ff876fae142e95a9b551e9ee3c7ca Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 6 Sep 2015 20:34:26 +0200 Subject: [PATCH 035/224] Fix Job & its test --- src/job.js | 2 +- test/spec-src/job.spec.js | 2 +- test/spec/job.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/job.js b/src/job.js index 93b62ea6..933039c2 100644 --- a/src/job.js +++ b/src/job.js @@ -40,7 +40,7 @@ export default class Job extends EventEmitter { executeOn(thread) { thread - .once('done', this.emit.bind(this, 'done')) + .once('message', this.emit.bind(this, 'done')) .once('error', this.emit.bind(this, 'error')) .run(...this.runArgs) .send(...this.sendArgs); diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index bfe43678..f05b65d7 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -19,7 +19,7 @@ function createFakeThread(response) { }; } else { thread.send = function() { - thread.emit('done', ...response.response); + thread.emit('message', ...response.response); }; } diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 81fc02b0..052dca24 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -35,7 +35,7 @@ function createFakeThread(response) { }; } else { thread.send = function () { - thread.emit.apply(thread, ['done'].concat(_toConsumableArray(response.response))); + thread.emit.apply(thread, ['message'].concat(_toConsumableArray(response.response))); }; } From d6dc2471e57e3a42caace8165141c0817eaaa172 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 7 Sep 2015 10:27:23 +0200 Subject: [PATCH 036/224] Implement Pool & tests --- .eslintrc | 3 +- dist/thread.browser.js | 290 +++++++++++++++++++++++++++++++++++-- dist/thread.browser.min.js | 2 +- lib/index.js | 9 +- lib/index.js.map | 2 +- lib/job.js | 2 +- lib/job.js.map | 2 +- lib/pool.js | 144 ++++++++++++++++++ lib/pool.js.map | 1 + src/index.js | 8 +- src/pool.js | 89 ++++++++++++ test/spec-src/pool.spec.js | 226 +++++++++++++++++++++++++++++ test/spec/pool.spec.js | 249 +++++++++++++++++++++++++++++++ 13 files changed, 1005 insertions(+), 22 deletions(-) create mode 100644 lib/pool.js create mode 100644 lib/pool.js.map create mode 100644 src/pool.js create mode 100644 test/spec-src/pool.spec.js create mode 100644 test/spec/pool.spec.js diff --git a/.eslintrc b/.eslintrc index 059ff402..e6f5d8e8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,8 +11,7 @@ "templateStrings": true }, "globals" : { - "Blob" : true, - "BlobBuilder" : true + "setTimeout" : true }, "rules" : { "global-strict" : 0, diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 195641b3..5c1a6a36 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -35,6 +35,8 @@ var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_a function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -155,7 +157,7 @@ var Worker = (function (_EventEmitter) { this.handleError(event.data.error); } else { var responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(responseArgs)); + this.emit.apply(this, ['message'].concat(_toConsumableArray(responseArgs))); } } }, { @@ -181,7 +183,7 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; //# sourceMappingURL=../worker.browser/worker.js.map -},{"../config":2,"./slave-code":4,"eventemitter3":5}],2:[function(require,module,exports){ +},{"../config":2,"./slave-code":6,"eventemitter3":7}],2:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -238,11 +240,7 @@ function getConfig() { } function setConfig() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return config.set.apply(config, args); + return config.set.apply(config, arguments); } //# sourceMappingURL=config.js.map },{}],3:[function(require,module,exports){ @@ -259,29 +257,297 @@ var _config = require('./config'); var _config2 = _interopRequireDefault(_config); +var _pool = require('./pool'); + +var _pool2 = _interopRequireDefault(_pool); + var _worker = require('./worker'); var _worker2 = _interopRequireDefault(_worker); exports.config = _config2['default']; -exports.Worker = _worker2['default']; -// needed for testing +exports.Pool = _pool2['default']; function spawn() { var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - return new _worker2['default'](runnable); + return new _worker2['default'](runnable, importScripts); } exports['default'] = { config: _config2['default'], + Pool: _pool2['default'], spawn: spawn, Worker: _worker2['default'] }; //# sourceMappingURL=index.js.map -},{"./config":2,"./worker":"./worker"}],4:[function(require,module,exports){ +},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var Job = (function (_EventEmitter) { + _inherits(Job, _EventEmitter); + + function Job(pool) { + _classCallCheck(this, Job); + + _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); + this.pool = pool; + + this.runArgs = []; + this.clearSendParameter(); + + pool.emit('newJob', this); + } + + _createClass(Job, [{ + key: 'run', + value: function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 0) { + throw new Error('Cannot call .run() without arguments.'); + } + + this.runArgs = args; + return this; + } + }, { + key: 'send', + value: function send() { + if (this.runArgs.length === 0) { + throw new Error('Cannot .send() before .run().'); + } + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (this.hasSendParameter()) { + var _clone$clearSendParameter; + + // do not alter this job, clone it and set send param instead + return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); + } + + this.sendArgs = args; + this.parameterSet = true; + + this.emit('readyToRun'); + return this; + } + }, { + key: 'executeOn', + value: function executeOn(thread) { + var _thread$once$once$run, _thread$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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + return this; + } + }, { + key: 'clone', + value: function clone() { + var clone = new Job(this.pool); + + if (this.runArgs.length > 0) { + clone.run.apply(clone, _toConsumableArray(this.runArgs)); + } + if (this.parameterSet) { + clone.send.apply(clone, _toConsumableArray(this.sendArgs)); + } + + return clone; + } + }, { + key: 'hasSendParameter', + value: function hasSendParameter() { + return this.parameterSet; + } + }, { + key: 'clearSendParameter', + value: function clearSendParameter() { + this.parameterSet = false; + this.sendArgs = []; + return this; + } + }]); + + return Job; +})(_eventemitter32['default']); + +exports['default'] = Job; +module.exports = exports['default']; +//# sourceMappingURL=job.js.map +},{"eventemitter3":7}],5:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _job = require('./job'); + +var _job2 = _interopRequireDefault(_job); + +var _ = require('./'); + +var Pool = (function (_EventEmitter) { + _inherits(Pool, _EventEmitter); + + function Pool() { + var threads = arguments.length <= 0 || arguments[0] === undefined ? 8 : arguments[0]; + + _classCallCheck(this, Pool); + + _get(Object.getPrototypeOf(Pool.prototype), 'constructor', this).call(this); + this.threads = Pool.spawn(threads); + this.idleThreads = this.threads.slice(); + this.jobQueue = []; + this.lastCreatedJob = null; + + this.on('newJob', this.handleNewJob.bind(this)); + } + + _createClass(Pool, [{ + key: 'run', + value: function run() { + var _ref; + + return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + } + }, { + key: 'send', + value: function send() { + var _lastCreatedJob; + + if (!this.lastCreatedJob) { + throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); + } + + // this will not alter the last job, but rather clone it and set this params on the new job + return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + } + }, { + key: 'killAll', + value: function killAll() { + this.threads.forEach(function (thread) { + thread.kill(); + }); + } + }, { + key: 'queueJob', + value: function queueJob(job) { + this.jobQueue.push(job); + this.dequeue(); + } + }, { + key: 'dequeue', + value: function dequeue() { + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { + return; + } + + var job = this.jobQueue.shift(); + var thread = this.idleThreads.shift(); + + job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + + job.executeOn(thread); + } + }, { + key: 'handleNewJob', + value: function handleNewJob(job) { + this.lastCreatedJob = job; + job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + } + }, { + key: 'handleJobSuccess', + value: function handleJobSuccess(thread, job) { + for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + responseArgs[_key - 2] = arguments[_key]; + } + + this.emit.apply(this, ['done', job].concat(responseArgs)); + this.handleJobDone(thread); + } + }, { + key: 'handleJobError', + value: function handleJobError(thread, job, error) { + this.emit('error', job, error); + this.handleJobDone(thread); + } + }, { + key: 'handleJobDone', + value: function handleJobDone(thread) { + var _this = this; + + this.idleThreads.push(thread); + this.dequeue(); + + if (this.idleThreads.length === this.threads.length) { + // run deferred to give other job.on('done') handlers time to run first + setTimeout(function () { + _this.emit('finished'); + }, 0); + } + } + }]); + + return Pool; +})(_eventemitter32['default']); + +exports['default'] = Pool; + +Pool.spawn = function (threadCount) { + var threads = []; + + for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { + threads.push((0, _.spawn)()); + } + + return threads; +}; +module.exports = exports['default']; +//# sourceMappingURL=pool.js.map +},{"./":3,"./job":4,"eventemitter3":7}],6:[function(require,module,exports){ module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"; -},{}],5:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ 'use strict'; // diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 03667393..50a422d0 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function e(t,n,r){function o(i,a){if(!n[i]){if(!t[i]){var u="function"==typeof require&&require;if(!a&&u)return u(i,!0);if(s)return s(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[i]={exports:{}};t[i][0].call(c.exports,function(e){var n=t[i][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[i].exports}for(var s="function"==typeof require&&require,i=0;i50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(l["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":4,eventemitter3:5}],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 s=t[o],i=n.concat([o]);if("object"==typeof s){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+i.join("."));r(e[o],s,i)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+i.join("."));e[o]=s}})}function o(){return a.get()}function s(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return a.set.apply(a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=s;var i={basepath:{node:"",web:""}},a={get:function(){return i},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(i,e)}};n["default"]=a},{}],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]?null:arguments[0];return new u["default"](e)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var s=e("./config"),i=r(s),a=e("./worker"),u=r(a);n.config=i["default"],n.Worker=u["default"],n["default"]={config:i["default"],spawn:o,Worker:u["default"]}},{"./config":2,"./worker":"./worker"}],4:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],5:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var s="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=s?s+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);i>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,i){var a=s?s+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,i),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p,h=c.length;for(f=0;h>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(p=1,u=new Array(l-1);l>p;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),i=s?s+e:e;return this._events||(this._events=s?{}:Object.create(null)),this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],o]:this._events[i].push(o):this._events[i]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),i=s?s+e:e;return this._events||(this._events=s?{}:Object.create(null)),this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],o]:this._events[i].push(o):this._events[i]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=s?s+e:e;if(!this._events||!this._events[o])return this;var i=this._events[o],a=[];if(t)if(i.fn)(i.fn!==t||r&&!i.once||n&&i.context!==n)&&a.push(i);else for(var u=0,f=i.length;f>u;u++)(i[u].fn!==t||r&&!i[u].once||n&&i[u].context!==n)&&a.push(i[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[s?s+e:e]:this._events=s?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=s,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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 l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),l=e("./worker"),f=r(l);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(f["default"]);n["default"]=c,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(l["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,l,f=this._events[a],c=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),c){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,s),!0}for(l=1,u=new Array(c-1);c>l;l++)u[l-1]=arguments[l];f.fn.apply(f.context,u)}else{var h,p=f.length;for(l=0;p>l;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),c){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,n);break;default:if(!u)for(h=1,u=new Array(c-1);c>h;h++)u[h-1]=arguments[h];f[l].fn.apply(f[l].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,l=s.length;l>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 9d211189..11b3036d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -11,20 +11,27 @@ var _config = require('./config'); var _config2 = _interopRequireDefault(_config); +var _pool = require('./pool'); + +var _pool2 = _interopRequireDefault(_pool); + var _worker = require('./worker'); var _worker2 = _interopRequireDefault(_worker); exports.config = _config2['default']; +exports.Pool = _pool2['default']; function spawn() { var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - return new _worker2['default'](runnable); + return new _worker2['default'](runnable, importScripts); } exports['default'] = { config: _config2['default'], + Pool: _pool2['default'], spawn: spawn, Worker: _worker2['default'] }; diff --git a/lib/index.js.map b/lib/index.js.map index 8122383e..d1d8b511 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;sBACV,UAAU;;;;QAEpB,MAAM;;AAER,SAAS,KAAK,GAAkB;MAAjB,QAAQ,yDAAG,IAAI;;AACnC,SAAO,wBAAW,QAAQ,CAAC,CAAC;CAC7B;;qBAEc;AACb,QAAM,qBAAA;AACN,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Worker from './worker';\n\nexport { config };\n\nexport function spawn(runnable = null) {\n return new Worker(runnable);\n}\n\nexport default {\n config,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;sBACmB,UAAU;;;;oBACV,QAAQ;;;;sBACR,UAAU;;;;QAEpB,MAAM;QAAE,IAAI;;AAEd,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["\nimport config from './config';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n Pool,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/job.js b/lib/job.js index aa2d40ce..a265cb77 100644 --- a/lib/job.js +++ b/lib/job.js @@ -78,7 +78,7 @@ var Job = (function (_EventEmitter) { value: function executeOn(thread) { var _thread$once$once$run, _thread$once$once; - (_thread$once$once$run = (_thread$once$once = thread.once('done', this.emit.bind(this, 'done')).once('error', this.emit.bind(this, 'error'))).run.apply(_thread$once$once, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + (_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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); return this; } }, { diff --git a/lib/job.js.map b/lib/job.js.map index 40268796..ae966c24 100644 --- a/lib/job.js.map +++ b/lib/job.js.map @@ -1 +1 @@ -{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;eATkB,GAAG;;WAWnB,eAAU;wCAAN,IAAI;AAAJ,YAAI;;;AACT,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,cAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;OAC1D;;AAED,UAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAU;AACZ,UAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,cAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;OAClD;;yCAHK,IAAI;AAAJ,YAAI;;;AAKV,UAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;;;;AAE3B,eAAO,6BAAA,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAkB,EAAE,EAAC,IAAI,MAAA,4BAAI,IAAI,CAAC,CAAC;OACxD;;AAED,UAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrB,UAAI,CAAC,YAAY,GAAG,IAAI,CAAC;;AAEzB,UAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxB,aAAO,IAAI,CAAC;KACb;;;WAEQ,mBAAC,MAAM,EAAE;;;AAChB,+BAAA,qBAAA,MAAM,CACH,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAC1C,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAC5C,GAAG,MAAA,uCAAI,IAAI,CAAC,OAAO,EAAC,EACpB,IAAI,MAAA,2CAAI,IAAI,CAAC,QAAQ,EAAC,CAAC;AAC1B,aAAO,IAAI,CAAC;KACb;;;WAEI,iBAAG;AACN,UAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;AAEjC,UAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,aAAK,CAAC,GAAG,MAAA,CAAT,KAAK,qBAAQ,IAAI,CAAC,OAAO,EAAC,CAAC;OAC5B;AACD,UAAI,IAAI,CAAC,YAAY,EAAE;AACrB,aAAK,CAAC,IAAI,MAAA,CAAV,KAAK,qBAAS,IAAI,CAAC,QAAQ,EAAC,CAAC;OAC9B;;AAED,aAAO,KAAK,CAAC;KACd;;;WAEe,4BAAG;AACjB,aAAO,IAAI,CAAC,YAAY,CAAC;KAC1B;;;WAEiB,8BAAG;AACnB,UAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,UAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SAnEkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('done', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n return this;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;eATkB,GAAG;;WAWnB,eAAU;wCAAN,IAAI;AAAJ,YAAI;;;AACT,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,cAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;OAC1D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AK,CAAC,IAAI,MAAA,CAAV,KAAK,qBAAS,IAAI,CAAC,QAAQ,EAAC,CAAC;OAC9B;;AAED,aAAO,KAAK,CAAC;KACd;;;WAEe,4BAAG;AACjB,aAAO,IAAI,CAAC,YAAY,CAAC;KAC1B;;;WAEiB,8BAAG;AACnB,UAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,UAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SAnEkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n return this;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js new file mode 100644 index 00000000..077a39b3 --- /dev/null +++ b/lib/pool.js @@ -0,0 +1,144 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _job = require('./job'); + +var _job2 = _interopRequireDefault(_job); + +var _ = require('./'); + +var Pool = (function (_EventEmitter) { + _inherits(Pool, _EventEmitter); + + function Pool() { + var threads = arguments.length <= 0 || arguments[0] === undefined ? 8 : arguments[0]; + + _classCallCheck(this, Pool); + + _get(Object.getPrototypeOf(Pool.prototype), 'constructor', this).call(this); + this.threads = Pool.spawn(threads); + this.idleThreads = this.threads.slice(); + this.jobQueue = []; + this.lastCreatedJob = null; + + this.on('newJob', this.handleNewJob.bind(this)); + } + + _createClass(Pool, [{ + key: 'run', + value: function run() { + var _ref; + + return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + } + }, { + key: 'send', + value: function send() { + var _lastCreatedJob; + + if (!this.lastCreatedJob) { + throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); + } + + // this will not alter the last job, but rather clone it and set this params on the new job + return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + } + }, { + key: 'killAll', + value: function killAll() { + this.threads.forEach(function (thread) { + thread.kill(); + }); + } + }, { + key: 'queueJob', + value: function queueJob(job) { + this.jobQueue.push(job); + this.dequeue(); + } + }, { + key: 'dequeue', + value: function dequeue() { + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { + return; + } + + var job = this.jobQueue.shift(); + var thread = this.idleThreads.shift(); + + job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + + job.executeOn(thread); + } + }, { + key: 'handleNewJob', + value: function handleNewJob(job) { + this.lastCreatedJob = job; + job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + } + }, { + key: 'handleJobSuccess', + value: function handleJobSuccess(thread, job) { + for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + responseArgs[_key - 2] = arguments[_key]; + } + + this.emit.apply(this, ['done', job].concat(responseArgs)); + this.handleJobDone(thread); + } + }, { + key: 'handleJobError', + value: function handleJobError(thread, job, error) { + this.emit('error', job, error); + this.handleJobDone(thread); + } + }, { + key: 'handleJobDone', + value: function handleJobDone(thread) { + var _this = this; + + this.idleThreads.push(thread); + this.dequeue(); + + if (this.idleThreads.length === this.threads.length) { + // run deferred to give other job.on('done') handlers time to run first + setTimeout(function () { + _this.emit('finished'); + }, 0); + } + } + }]); + + return Pool; +})(_eventemitter32['default']); + +exports['default'] = Pool; + +Pool.spawn = function (threadCount) { + var threads = []; + + for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { + threads.push((0, _.spawn)()); + } + + return threads; +}; +module.exports = exports['default']; +//# sourceMappingURL=pool.js.map \ No newline at end of file diff --git a/lib/pool.js.map b/lib/pool.js.map new file mode 100644 index 00000000..467332c8 --- /dev/null +++ b/lib/pool.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;gBACP,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,GACE;QAAb,OAAO,yDAAG,CAAC;;0BADJ,IAAI;;AAErB,+BAFiB,IAAI,6CAEb;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACnC,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,cAAc,GAAG,IAAI,CAAC;;AAE3B,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;GACjD;;eATkB,IAAI;;WAWpB,eAAU;;;AACX,aAAO,QAAC,qBAAQ,IAAI,CAAC,EAAE,GAAG,MAAA,iBAAS,CAAC;KACrC;;;WAEG,gBAAU;;;AACZ,UAAI,CAAC,IAAI,CAAC,cAAc,EAAE;AACxB,cAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;OACvG;;;AAGD,aAAO,mBAAA,IAAI,CAAC,cAAc,EAAC,IAAI,MAAA,4BAAS,CAAC;KAC1C;;;WAEM,mBAAG;AACR,UAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,EAAI;AAC7B,cAAM,CAAC,IAAI,EAAE,CAAC;OACf,CAAC,CAAC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AC,CAAC;AAC/B,UAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;KAC5B;;;WAEY,uBAAC,MAAM,EAAE;;;AACpB,UAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,UAAI,CAAC,OAAO,EAAE,CAAC;;AAEf,UAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,kBAAU,CAAC,YAAM;AAAE,gBAAK,IAAI,CAAC,UAAU,CAAC,CAAC;SAAE,EAAE,CAAC,CAAC,CAAC;OACjD;KACF;;;SAzEkB,IAAI;;;qBAAJ,IAAI;;AA4EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads = 8) {\n super();\n this.threads = Pool.spawn(threads);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.lastCreatedJob = null;\n\n this.on('newJob', this.handleNewJob.bind(this));\n }\n\n run(...args) {\n return (new Job(this)).run(...args);\n }\n\n send(...args) {\n if (!this.lastCreatedJob) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n // this will not alter the last job, but rather clone it and set this params on the new job\n return this.lastCreatedJob.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/index.js b/src/index.js index f0a24f5a..0a65dc7a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,17 @@ import config from './config'; +import Pool from './pool'; import Worker from './worker'; -export { config }; +export { config, Pool }; -export function spawn(runnable = null) { - return new Worker(runnable); +export function spawn(runnable = null, importScripts = []) { + return new Worker(runnable, importScripts); } export default { config, + Pool, spawn, Worker }; diff --git a/src/pool.js b/src/pool.js new file mode 100644 index 00000000..16654081 --- /dev/null +++ b/src/pool.js @@ -0,0 +1,89 @@ +import EventEmitter from 'eventemitter3'; +import Job from './job'; +import { spawn } from './'; + +export default class Pool extends EventEmitter { + constructor(threads = 8) { + super(); + this.threads = Pool.spawn(threads); + this.idleThreads = this.threads.slice(); + this.jobQueue = []; + this.lastCreatedJob = null; + + this.on('newJob', this.handleNewJob.bind(this)); + } + + run(...args) { + return (new Job(this)).run(...args); + } + + send(...args) { + if (!this.lastCreatedJob) { + throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); + } + + // this will not alter the last job, but rather clone it and set this params on the new job + return this.lastCreatedJob.send(...args); + } + + killAll() { + this.threads.forEach(thread => { + thread.kill(); + }); + } + + queueJob(job) { + this.jobQueue.push(job); + this.dequeue(); + } + + dequeue() { + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { + return; + } + + const job = this.jobQueue.shift(); + const thread = this.idleThreads.shift(); + + job + .on('done', this.handleJobSuccess.bind(this, thread, job)) + .on('error', this.handleJobError.bind(this, thread, job)); + + job.executeOn(thread); + } + + handleNewJob(job) { + this.lastCreatedJob = job; + job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + } + + handleJobSuccess(thread, job, ...responseArgs) { + this.emit('done', job, ...responseArgs); + this.handleJobDone(thread); + } + + handleJobError(thread, job, error) { + this.emit('error', job, error); + this.handleJobDone(thread); + } + + handleJobDone(thread) { + this.idleThreads.push(thread); + this.dequeue(); + + if (this.idleThreads.length === this.threads.length) { + // run deferred to give other job.on('done') handlers time to run first + setTimeout(() => { this.emit('finished'); }, 0); + } + } +} + +Pool.spawn = (threadCount) => { + const threads = []; + + for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) { + threads.push(spawn()); + } + + return threads; +}; diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js new file mode 100644 index 00000000..7e2cf866 --- /dev/null +++ b/test/spec-src/pool.spec.js @@ -0,0 +1,226 @@ +import async from 'async'; +import expect from 'expect.js'; +import EventEmitter from 'eventemitter3'; +import { Pool } from '../../lib/'; + + +let spawnedFakeWorkers = 0; + +class FakeWorker extends EventEmitter { + constructor() { + super(); + spawnedFakeWorkers++; + } + + run(runnable, importScripts = []) { + this.runnable = runnable; + this.importScripts = importScripts; + return this; + } + + send(parameter, transferables = []) { + this.parameter = parameter; + this.transferables = transferables; + + setTimeout(() => { + if (parameter.error) { + this.emit('error', parameter.error); + } else { + this.emit('message', parameter); + } + }, 0); + return this; + } + + kill() { + this.emit('exit'); + return this; + } +} + +function noop() { return this; } + +function doTimes(callback, times) { + const returns = []; + + for (let index = 0; index < times; index++) { + returns.push(callback()); + } + + return returns; +} + + +describe('Pool', () => { + + const origSpawn = Pool.spawn; + + before(() => { + Pool.spawn = (threadCount) => { + return doTimes(() => new FakeWorker(), threadCount); + }; + }); + + beforeEach(() => { + spawnedFakeWorkers = 0; + }); + + after(() => { + Pool.spawn = origSpawn; + }); + + + it('can be created (w/o arguments)', () => { + const pool = new Pool(); + + expect(pool.threads.length).to.equal(8); + expect(pool.idleThreads).to.eql(pool.threads); + expect(spawnedFakeWorkers).to.equal(8); + }); + + it('can be created with arguments', () => { + const pool = new Pool(5); + + expect(pool.threads.length).to.equal(5); + expect(pool.idleThreads).to.eql(pool.threads); + expect(spawnedFakeWorkers).to.equal(5); + }); + + it('can kill', (done) => { + const pool = new Pool(5); + let killedThreads = 0; + + pool.threads.forEach(thread => { + thread.on('exit', () => { + killedThreads++; + }); + }); + + pool.killAll(); + + setTimeout(() => { + expect(killedThreads).to.equal(5); + done(); + }, 20); + }); + + it('can run jobs', (done) => { + const pool = new Pool(); + let calledJobA = 0, calledJobB = 0; + + const jobA = pool + .run(noop) + .send({ foo : 1 }); + const jobB = pool + .run(noop) + .send({ foo : 2 }); + + pool + .on('done', (job, message) => { + switch(job) { + case jobA: + calledJobA++; + expect(message).to.eql({ foo : 1 }); + break; + case jobB: + calledJobB++; + expect(message).to.eql({ foo : 2 }); + break; + default: + throw new Error('"message" event for unknown job.'); + } + }) + .on('finished', () => { + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + done(); + }); + }); + + it('can handle errors', (done) => { + let doneHandled = false, errorHandled = false; + + const pool = new Pool(); + + const jobA = pool + .run(noop) + .send({ foo : 'bar' }); + const jobB = pool + .run(noop) + .send({ error : new Error('Something went wrong.') }); + + pool + .on('done', (job, message) => { + doneHandled = true; + expect(job).to.equal(jobA); + expect(message).to.eql({ foo : 'bar' }); + }) + .on('error', (job, error) => { + errorHandled = true; + expect(job).to.equal(jobB); + expect(error.message).to.eql('Something went wrong.'); + }) + .on('finished', () => { + expect(doneHandled).to.equal(true); + expect(errorHandled).to.equal(true); + done(); + }); + }); + + it('can queue jobs', (done) => { + let calledJobA = 0, calledJobB = 0, calledJobC = 0; + let calledJobD = 0, calledJobE = 0; + const pool = new Pool(2); + + const part1 = (partDone) => { + pool + .run(noop) + .send({ foo : 1 }) + .on('done', () => { calledJobA++; }); + pool + .run(noop) + .send({ foo : 2 }) + .on('done', () => { calledJobB++; }); + pool + .run(noop) + .send({ foo : 3 }) + .on('done', () => { calledJobC++; }); + + pool.once('finished', () => { + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + expect(calledJobC).to.equal(1); + partDone(); + }); + }; + + const part2 = (partDone) => { + + pool + .run(noop) + .send({ error : new Error('Will the next job still be handled correctly?') }) + .on('error', () => { calledJobD++; }); + + pool + .run(noop) + .send({ foo : 4 }) + .on('done', () => { calledJobE++; }); + + pool.once('finished', () => { + // expectation: previous handlers have not been triggered again + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + expect(calledJobC).to.equal(1); + + expect(calledJobD).to.equal(1); + expect(calledJobE).to.equal(1); + partDone(); + }); + }; + + async.series([ + part1, part2 + ], done); + }); + +}); diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js new file mode 100644 index 00000000..0b34099e --- /dev/null +++ b/test/spec/pool.spec.js @@ -0,0 +1,249 @@ +'use strict'; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _async = require('async'); + +var _async2 = _interopRequireDefault(_async); + +var _expectJs = require('expect.js'); + +var _expectJs2 = _interopRequireDefault(_expectJs); + +var _eventemitter3 = require('eventemitter3'); + +var _eventemitter32 = _interopRequireDefault(_eventemitter3); + +var _lib = require('../../lib/'); + +var spawnedFakeWorkers = 0; + +var FakeWorker = (function (_EventEmitter) { + _inherits(FakeWorker, _EventEmitter); + + function FakeWorker() { + _classCallCheck(this, FakeWorker); + + _get(Object.getPrototypeOf(FakeWorker.prototype), 'constructor', this).call(this); + spawnedFakeWorkers++; + } + + _createClass(FakeWorker, [{ + key: 'run', + value: function run(runnable) { + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.runnable = runnable; + this.importScripts = importScripts; + return this; + } + }, { + key: 'send', + value: function send(parameter) { + var _this = this; + + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.parameter = parameter; + this.transferables = transferables; + + setTimeout(function () { + if (parameter.error) { + _this.emit('error', parameter.error); + } else { + _this.emit('message', parameter); + } + }, 0); + return this; + } + }, { + key: 'kill', + value: function kill() { + this.emit('exit'); + return this; + } + }]); + + return FakeWorker; +})(_eventemitter32['default']); + +function noop() { + return this; +} + +function doTimes(callback, times) { + var returns = []; + + for (var index = 0; index < times; index++) { + returns.push(callback()); + } + + return returns; +} + +describe('Pool', function () { + + var origSpawn = _lib.Pool.spawn; + + before(function () { + _lib.Pool.spawn = function (threadCount) { + return doTimes(function () { + return new FakeWorker(); + }, threadCount); + }; + }); + + beforeEach(function () { + spawnedFakeWorkers = 0; + }); + + after(function () { + _lib.Pool.spawn = origSpawn; + }); + + it('can be created (w/o arguments)', function () { + var pool = new _lib.Pool(); + + (0, _expectJs2['default'])(pool.threads.length).to.equal(8); + (0, _expectJs2['default'])(pool.idleThreads).to.eql(pool.threads); + (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(8); + }); + + it('can be created with arguments', function () { + var pool = new _lib.Pool(5); + + (0, _expectJs2['default'])(pool.threads.length).to.equal(5); + (0, _expectJs2['default'])(pool.idleThreads).to.eql(pool.threads); + (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(5); + }); + + it('can kill', function (done) { + var pool = new _lib.Pool(5); + var killedThreads = 0; + + pool.threads.forEach(function (thread) { + thread.on('exit', function () { + killedThreads++; + }); + }); + + pool.killAll(); + + setTimeout(function () { + (0, _expectJs2['default'])(killedThreads).to.equal(5); + done(); + }, 20); + }); + + it('can run jobs', function (done) { + var pool = new _lib.Pool(); + var calledJobA = 0, + calledJobB = 0; + + var jobA = pool.run(noop).send({ foo: 1 }); + var jobB = pool.run(noop).send({ foo: 2 }); + + pool.on('done', function (job, message) { + switch (job) { + case jobA: + calledJobA++; + (0, _expectJs2['default'])(message).to.eql({ foo: 1 }); + break; + case jobB: + calledJobB++; + (0, _expectJs2['default'])(message).to.eql({ foo: 2 }); + break; + default: + throw new Error('"message" event for unknown job.'); + } + }).on('finished', function () { + (0, _expectJs2['default'])(calledJobA).to.equal(1); + (0, _expectJs2['default'])(calledJobB).to.equal(1); + done(); + }); + }); + + it('can handle errors', function (done) { + var doneHandled = false, + errorHandled = false; + + var pool = new _lib.Pool(); + + var jobA = pool.run(noop).send({ foo: 'bar' }); + var jobB = pool.run(noop).send({ error: new Error('Something went wrong.') }); + + pool.on('done', function (job, message) { + doneHandled = true; + (0, _expectJs2['default'])(job).to.equal(jobA); + (0, _expectJs2['default'])(message).to.eql({ foo: 'bar' }); + }).on('error', function (job, error) { + errorHandled = true; + (0, _expectJs2['default'])(job).to.equal(jobB); + (0, _expectJs2['default'])(error.message).to.eql('Something went wrong.'); + }).on('finished', function () { + (0, _expectJs2['default'])(doneHandled).to.equal(true); + (0, _expectJs2['default'])(errorHandled).to.equal(true); + done(); + }); + }); + + it('can queue jobs', function (done) { + var calledJobA = 0, + calledJobB = 0, + calledJobC = 0; + var calledJobD = 0, + calledJobE = 0; + var pool = new _lib.Pool(2); + + var part1 = function part1(partDone) { + pool.run(noop).send({ foo: 1 }).on('done', function () { + calledJobA++; + }); + pool.run(noop).send({ foo: 2 }).on('done', function () { + calledJobB++; + }); + pool.run(noop).send({ foo: 3 }).on('done', function () { + calledJobC++; + }); + + pool.once('finished', function () { + (0, _expectJs2['default'])(calledJobA).to.equal(1); + (0, _expectJs2['default'])(calledJobB).to.equal(1); + (0, _expectJs2['default'])(calledJobC).to.equal(1); + partDone(); + }); + }; + + var part2 = function part2(partDone) { + + pool.run(noop).send({ error: new Error('Will the next job still be handled correctly?') }).on('error', function () { + calledJobD++; + }); + + pool.run(noop).send({ foo: 4 }).on('done', function () { + calledJobE++; + }); + + pool.once('finished', function () { + // expectation: previous handlers have not been triggered again + (0, _expectJs2['default'])(calledJobA).to.equal(1); + (0, _expectJs2['default'])(calledJobB).to.equal(1); + (0, _expectJs2['default'])(calledJobC).to.equal(1); + + (0, _expectJs2['default'])(calledJobD).to.equal(1); + (0, _expectJs2['default'])(calledJobE).to.equal(1); + partDone(); + }); + }; + + _async2['default'].series([part1, part2], done); + }); +}); \ No newline at end of file From 0520478af9691d45320e52b1651bbd60529e60a8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 7 Sep 2015 10:27:42 +0200 Subject: [PATCH 037/224] Add todo: promise --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 7bc65911..bb44cc10 100644 --- a/readme.md +++ b/readme.md @@ -184,6 +184,10 @@ thread .send(); ``` +### Promises + +TODO (.send().promise()) + ### Transferable objects You can also use transferable objects to improve performance when passing large From 553ae3717e5955874a6817b0fdd69ca4e0391216 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 7 Sep 2015 12:49:27 +0200 Subject: [PATCH 038/224] New npm name: threads --- package.json | 2 +- readme.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7875a7cd..aa449d01 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "thread.js", + "name": "threads", "version": "0.1.0", "keywords": [ "thread", diff --git a/readme.md b/readme.md index bb44cc10..94ebd736 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# thread.js +# threads.js Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. @@ -20,8 +20,8 @@ Spawn threads to do the time-consuming work and let the parent thread focus on daily business! ```javascript -import { spawn } from 'thread.js'; -// ES5 syntax: var spawn = require('thread.js').spawn; +import { spawn } from 'threads'; +// ES5 syntax: var spawn = require('threads').spawn; const thread = spawn(function(input, done) { // Everything we do here will be run in parallel in another execution context. @@ -58,8 +58,8 @@ commonjs module (so something that uses `module.exports = ...`), for node and browser. ```javascript -import { config, spawn } from 'thread.js'; -// ES5 syntax: var config = require('thread.js').config, spawn = require('thread.js').spawn; +import { config, spawn } from 'threads'; +// ES5 syntax: var config = require('threads').config, spawn = require('threads').spawn; // Set base paths to thread scripts config.set({ @@ -94,8 +94,8 @@ You can also create a thread pool that spawns a fixed no. of workers. Pass jobs to the thread pool which it will queue and pass to the next idle worker. ```javascript -import { Pool } from 'thread.js'; -// ES5 syntax: var Pool = require('thread.js').Pool; +import { Pool } from 'threads'; +// ES5 syntax: var Pool = require('threads').Pool; const pool = new Pool(); From ff5566de219a5d25899eed2f707b6433cccafa7e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 7 Sep 2015 22:11:46 +0200 Subject: [PATCH 039/224] Implement Promise support --- dist/thread.browser.js | 20 ++++++++++++++++ dist/thread.browser.min.js | 2 +- lib/job.js | 11 +++++++++ lib/job.js.map | 2 +- lib/worker.browser/worker.js | 9 +++++++ lib/worker.browser/worker.js.map | 2 +- lib/worker.node/worker.js | 9 +++++++ lib/worker.node/worker.js.map | 2 +- readme.md | 22 ++++++++++++++++- src/job.js | 10 ++++++++ src/worker.browser/worker.js | 8 +++++++ src/worker.node/worker.js | 8 +++++++ test/spec-src/job.spec.js | 30 ++++++++++++++++++++++- test/spec-src/worker.spec.js | 41 ++++++++++++++++++++++++++------ test/spec/job.spec.js | 24 +++++++++++++++++++ test/spec/worker.spec.js | 23 ++++++++++++++++++ 16 files changed, 210 insertions(+), 13 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 5c1a6a36..1eebb356 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -150,6 +150,15 @@ var Worker = (function (_EventEmitter) { this.emit('exit'); return this; } + }, { + key: 'promise', + value: function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + } }, { key: 'handleMessage', value: function handleMessage(event) { @@ -313,6 +322,7 @@ var Job = (function (_EventEmitter) { _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); this.pool = pool; + this.thread = null; this.runArgs = []; this.clearSendParameter(); @@ -364,8 +374,18 @@ var Job = (function (_EventEmitter) { var _thread$once$once$run, _thread$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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + + this.thread = thread; return this; } + }, { + key: 'promise', + value: function promise() { + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); + } + return this.thread.promise(); + } }, { key: 'clone', value: function clone() { diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 50a422d0..1d401b16 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +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 l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),l=e("./worker"),f=r(l);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(f["default"]);n["default"]=c,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(l["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,l,f=this._events[a],c=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),c){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,s),!0}for(l=1,u=new Array(c-1);c>l;l++)u[l-1]=arguments[l];f.fn.apply(f.context,u)}else{var h,p=f.length;for(l=0;p>l;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),c){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,n);break;default:if(!u)for(h=1,u=new Array(c-1);c>h;h++)u[h-1]=arguments[h];f[l].fn.apply(f[l].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,l=s.length;l>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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 l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new c["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),l=e("./worker"),c=r(l);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:c["default"]}},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this.thread=e,this}},{key:"promise",value:function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(c["default"]);n["default"]=f,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(l["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,l,c=this._events[a],f=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(l=1,u=new Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h,p=c.length;for(l=0;p>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;default:if(!u)for(h=1,u=new Array(f-1);f>h;h++)u[h-1]=arguments[h];c[l].fn.apply(c[l].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,l=s.length;l>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/job.js b/lib/job.js index a265cb77..b2aae0b1 100644 --- a/lib/job.js +++ b/lib/job.js @@ -28,6 +28,7 @@ var Job = (function (_EventEmitter) { _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); this.pool = pool; + this.thread = null; this.runArgs = []; this.clearSendParameter(); @@ -79,8 +80,18 @@ var Job = (function (_EventEmitter) { var _thread$once$once$run, _thread$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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + + this.thread = thread; return this; } + }, { + key: 'promise', + value: function promise() { + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); + } + return this.thread.promise(); + } }, { key: 'clone', value: function clone() { diff --git a/lib/job.js.map b/lib/job.js.map index ae966c24..9f569e5d 100644 --- a/lib/job.js.map +++ b/lib/job.js.map @@ -1 +1 @@ -{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;;AAEnB,QAAI,C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IAAI,CAAC;KACb;;;WAEI,iBAAG;AACN,UAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;AAEjC,UAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,aAAK,CAAC,GAAG,MAAA,CAAT,KAAK,qBAAQ,IAAI,CAAC,OAAO,EAAC,CAAC;OAC5B;AACD,UAAI,IAAI,CAAC,YAAY,EAAE;AACrB,aAAK,CAAC,IAAI,MAAA,CAAV,KAAK,qBAAS,IAAI,CAAC,QAAQ,EAAC,CAAC;OAC9B;;AAED,aAAO,KAAK,CAAC;KACd;;;WAEe,4BAAG;AACjB,aAAO,IAAI,CAAC,YAAY,CAAC;KAC1B;;;WAEiB,8BAAG;AACnB,UAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,UAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SAnEkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n return this;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;eAVkB,GAAG;;WAYnB,eAAU;wCAAN,IAAI;AAAJ,YAAI;;;AACT,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,cAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;OAC1D;;AAED,UAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAU;AACZ,UAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,cAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;OAClD;;yCAHK,IAAI;AAAJ,YAAI;;;AAKV,UAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;;;;AAE3B,eAAO,6BAAA,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAkB,EAAE,EAAC,IAAI,MAAA,4BAAI,IAAI,CAAC,CAAC;OACxD;;AAED,UAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrB,UAAI,CAAC,YAAY,GAAG,IAAI,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AE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SA7EkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n return this;\n }\n\n promise() {\n if (!this.thread) {\n throw new Error('Cannot return promise, since job is not executed.');\n }\n return this.thread.promise();\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index aabb3e26..bf46419d 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -125,6 +125,15 @@ var Worker = (function (_EventEmitter) { this.emit('exit'); return this; } + }, { + key: 'promise', + value: function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + } }, { key: 'handleMessage', value: function handleMessage(event) { diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index fc814811..b7466f9a 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,wBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;IAGoB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,GAC6B;QAA1C,aAAa,yDAAG,IAAI;QAAE,aAAa,yDAAG,EAAE;;0BADjC,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAClD,QAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,C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E;AAC1D,gBAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAjFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGt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CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAzFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index 88de7687..b8520ae6 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -98,6 +98,15 @@ var Worker = (function (_EventEmitter) { this.slave.kill(); return this; } + }, { + key: 'promise', + value: function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + } }, { key: 'handleMessage', value: function handleMessage(message) { diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index a37387d0..b709a386 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;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AC,wBAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;;;AAGxE,UAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACd,oBAAY,EAAG,IAAI;AACnB,cAAM,EAAS,kBAAK,OAAO,CAAC,kBAAkB,CAAC;OAChD,CAAC,CAAC;KACJ;;;WAEG,cAAC,KAAK,EAAE;AACV,UAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACd,aAAK,EAAG,IAAI;AACZ,aAAK,EAAL,KAAK;OACN,CAAC,CAAC;AACH,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEY,uBAAC,OAAO,EAAE;AACrB,UAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;OACzB,MAAM;AACL,YAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,4BAAK,OAAO,CAAC,QAAQ,GAAC,CAAC;OAC3C;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAvEkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,S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IAAI;AACZ,aAAK,EAAL,KAAK;OACN,CAAC,CAAC;AACH,aAAO,IAAI,CAAC;KACb;;;WAEG,gBAAG;AACL,UAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAClB,aAAO,IAAI,CAAC;KACb;;;WAEM,mBAAG;;;AACR,aAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM,EAAK;AACtC,cACG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACxB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;OAC1B,CAAC,CAAC;KACJ;;;WAEY,uBAAC,OAAO,EAAE;AACrB,UAAI,OAAO,CAAC,KAAK,EAAE;AACjB,YAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;OACzB,MAAM;AACL,YAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,4BAAK,OAAO,CAAC,QAAQ,GAAC,CAAC;OAC3C;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SA/EkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/readme.md b/readme.md index 94ebd736..d842f3ef 100644 --- a/readme.md +++ b/readme.md @@ -186,7 +186,27 @@ thread ### Promises -TODO (.send().promise()) +Instead of using callbacks, you can also turn thread messages and pool jobs into +promises. + +```javascript +spawn(myThreadFile) + .send({ important : 'data' }) + .promise() + .then(function success(message) {}, function error(error) {}); +``` + +```javascript +pool.run(fancyThreadCode); + +Promise.all([ + pool.send({ data : 1 }).promise(), + pool.send({ data : 2 }).promise() +]).then(function allResolved() { + console.log('Everything done! It\'s closing time...'); +}); +``` + ### Transferable objects diff --git a/src/job.js b/src/job.js index 933039c2..aa490fe4 100644 --- a/src/job.js +++ b/src/job.js @@ -5,6 +5,7 @@ export default class Job extends EventEmitter { constructor(pool) { super(); this.pool = pool; + this.thread = null; this.runArgs = []; this.clearSendParameter(); @@ -44,9 +45,18 @@ export default class Job extends EventEmitter { .once('error', this.emit.bind(this, 'error')) .run(...this.runArgs) .send(...this.sendArgs); + + this.thread = thread; return this; } + promise() { + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); + } + return this.thread.promise(); + } + clone() { const clone = new Job(this.pool); diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 7e73086c..b50ea35f 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -87,6 +87,14 @@ export default class Worker extends EventEmitter { return this; } + promise() { + return new Promise((resolve, reject) => { + this + .once('message', resolve) + .once('error', reject); + }); + } + handleMessage(event) { if (event.data.error) { this.handleError(event.data.error); diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 51ca6c43..fa687952 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -60,6 +60,14 @@ export default class Worker extends EventEmitter { return this; } + promise() { + return new Promise((resolve, reject) => { + this + .once('message', resolve) + .once('error', reject); + }); + } + handleMessage(message) { if (message.error) { const error = new Error(message.error.message); diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index f05b65d7..bfac9ed2 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -4,6 +4,8 @@ import EventEmitter from 'eventemitter3'; import Job from '../../lib/job'; +const fakeThreadPromise = new Promise(() => {}); + function noop() { return this; } @@ -11,7 +13,8 @@ function noop() { function createFakeThread(response) { const thread = new EventEmitter(); - thread.run = noop; + thread.run = noop; + thread.promise = () => fakeThreadPromise; if (response.error) { thread.send = function() { @@ -187,4 +190,29 @@ describe('Job', () => { expect(job.hasSendParameter()).to.equal(true); }); + it('proxies the promise', () => { + const job = new Job(pool); + const thread = createFakeThread({ + response : [ 'foo bar' ] + }); + + const promise = job + .run(noop) + .send() + .executeOn(thread) + .promise(); + + expect(promise).to.equal(fakeThreadPromise); + }); + + it('prevents promise without .executeOn()', () => { + const job = new Job(pool); + + job + .run(noop) + .send(); + + expect(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + }); + }); diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 13056686..a22bd3af 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -75,17 +75,17 @@ describe('Worker', () => { canSendAndReceiveEcho(worker, done); }); - it('can run script (set using spawn())', (done) => { + it('can run script (set using spawn())', done => { const worker = spawn('abc-sender.js'); canSendAndReceive(worker, null, 'abc', done); }); - it('can run script (set using .run())', (done) => { + it('can run script (set using .run())', done => { const worker = spawn(echoThread); canSendAndReceiveEcho(worker, done); }); - it('can pass more than one argument as response', (done) => { + it('can pass more than one argument as response', done => { const worker = spawn((input, threadDone) => { threadDone('a', 'b', 'c'); }); worker .send() @@ -120,17 +120,44 @@ describe('Worker', () => { throw new Error('Test message'); }); - worker.on('error', (error) => { + worker.on('error', error => { expect(error.message).to.match(/^(Uncaught Error: )?Test message$/); done(); }); worker.send(); }); + it('can promise and resolve', done => { + const promise = spawn(echoThread) + .send('foo bar') + .promise(); + + expect(promise).to.be.a(Promise); + + promise.then(response => { + expect(response).to.eql('foo bar'); + done(); + }); + }); + + it('can promise and reject', done => { + const worker = spawn(() => { + throw new Error('I fail'); + }); + const promise = worker + .send() + .promise(); + + promise.catch(error => { + expect(error.message).to.match(/^(Uncaught Error: )?I fail$/); + done(); + }); + }); + if (env === 'node') { - it('thread code can use setTimeout, setInterval', (done) => { + it('thread code can use setTimeout, setInterval', done => { let messageCount = 0; const worker = spawn() @@ -154,7 +181,7 @@ describe('Worker', () => { if (env === 'browser') { - it('can importScripts()', (done) => { + it('can importScripts()', done => { const worker = spawn() .run(function(input, threadDone) { this.importedEcho(input, threadDone); @@ -167,7 +194,7 @@ describe('Worker', () => { }); }); - it('can use transferables', (done) => { + it('can use transferables', done => { const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB const arrayBufferClone = new Uint8Array(1024 * 2); // need to clone, because referencing arrayBuffer will not work after .send() diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 052dca24..76e63835 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -20,6 +20,8 @@ var _libJob = require('../../lib/job'); var _libJob2 = _interopRequireDefault(_libJob); +var fakeThreadPromise = new Promise(function () {}); + function noop() { return this; } @@ -28,6 +30,9 @@ function createFakeThread(response) { var thread = new _eventemitter32['default'](); thread.run = noop; + thread.promise = function () { + return fakeThreadPromise; + }; if (response.error) { thread.send = function () { @@ -193,4 +198,23 @@ describe('Job', function () { (0, _expectJs2['default'])(job.sendArgs).to.eql([paramA]); (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(true); }); + + it('proxies the promise', function () { + var job = new _libJob2['default'](pool); + var thread = createFakeThread({ + response: ['foo bar'] + }); + + var promise = job.run(noop).send().executeOn(thread).promise(); + + (0, _expectJs2['default'])(promise).to.equal(fakeThreadPromise); + }); + + it('prevents promise without .executeOn()', function () { + var job = new _libJob2['default'](pool); + + job.run(noop).send(); + + (0, _expectJs2['default'])(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + }); }); \ No newline at end of file diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 90fa7abf..85d05fc8 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -132,6 +132,29 @@ describe('Worker', function () { worker.send(); }); + it('can promise and resolve', function (done) { + var promise = (0, _.spawn)(echoThread).send('foo bar').promise(); + + (0, _expectJs2['default'])(promise).to.be.a(Promise); + + promise.then(function (response) { + (0, _expectJs2['default'])(response).to.eql('foo bar'); + done(); + }); + }); + + it('can promise and reject', function (done) { + var worker = (0, _.spawn)(function () { + throw new Error('I fail'); + }); + var promise = worker.send().promise(); + + promise['catch'](function (error) { + (0, _expectJs2['default'])(error.message).to.match(/^(Uncaught Error: )?I fail$/); + done(); + }); + }); + if (env === 'node') { it('thread code can use setTimeout, setInterval', function (done) { From efe0b942deeb328398092be626c37504593b2a42 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 7 Sep 2015 23:29:36 +0200 Subject: [PATCH 040/224] Minor package description change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aa449d01..eaebb6e3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "fork", "parallel" ], - "description": "Easy to use multi-threading library for node.js and the browser!", + "description": "Easy to use, yet powerful multi-threading library for node.js and the browser!", "author": "Andy Wermke ", "license": "MIT", "main": "lib/index.js", From 4b73fef8db924efcf6521ea57c859cbd326d5355 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 8 Sep 2015 09:12:25 +0200 Subject: [PATCH 041/224] Ship with Promise polyfill --- dist/thread.browser.js | 381 ++++++++++++++++++++++++++++++++++++- dist/thread.browser.min.js | 2 +- lib/index.js | 2 + lib/index.js.map | 2 +- package.json | 3 +- src/index.js | 1 + 6 files changed, 387 insertions(+), 4 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 1eebb356..5a4e4174 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -262,6 +262,8 @@ exports.spawn = spawn; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +require('native-promise-only'); + var _config = require('./config'); var _config2 = _interopRequireDefault(_config); @@ -291,7 +293,7 @@ exports['default'] = { Worker: _worker2['default'] }; //# sourceMappingURL=index.js.map -},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(require,module,exports){ +},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -831,4 +833,381 @@ if ('undefined' !== typeof module) { module.exports = EventEmitter; } +},{}],8:[function(require,module,exports){ +(function (global){ +/*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org +*/ + +(function UMD(name,context,definition){ + // special form of UMD for polyfilling across evironments + context[name] = context[name] || definition(); + if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } + else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } +})("Promise",typeof global != "undefined" ? global : this,function DEF(){ + /*jshint validthis:true */ + "use strict"; + + var builtInProp, cycle, scheduling_queue, + ToString = Object.prototype.toString, + timer = (typeof setImmediate != "undefined") ? + function timer(fn) { return setImmediate(fn); } : + setTimeout + ; + + // dammit, IE8. + try { + Object.defineProperty({},"x",{}); + builtInProp = function builtInProp(obj,name,val,config) { + return Object.defineProperty(obj,name,{ + value: val, + writable: true, + configurable: config !== false + }); + }; + } + catch (err) { + builtInProp = function builtInProp(obj,name,val) { + obj[name] = val; + return obj; + }; + } + + // Note: using a queue instead of array for efficiency + scheduling_queue = (function Queue() { + var first, last, item; + + function Item(fn,self) { + this.fn = fn; + this.self = self; + this.next = void 0; + } + + return { + add: function add(fn,self) { + item = new Item(fn,self); + if (last) { + last.next = item; + } + else { + first = item; + } + last = item; + item = void 0; + }, + drain: function drain() { + var f = first; + first = last = cycle = void 0; + + while (f) { + f.fn.call(f.self); + f = f.next; + } + } + }; + })(); + + function schedule(fn,self) { + scheduling_queue.add(fn,self); + if (!cycle) { + cycle = timer(scheduling_queue.drain); + } + } + + // promise duck typing + function isThenable(o) { + var _then, o_type = typeof o; + + if (o != null && + ( + o_type == "object" || o_type == "function" + ) + ) { + _then = o.then; + } + return typeof _then == "function" ? _then : false; + } + + function notify() { + for (var i=0; i 0) { + schedule(notify,self); + } + } + } + catch (err) { + reject.call(new MakeDefWrapper(self),err); + } + } + + function reject(msg) { + var self = this; + + // already triggered? + if (self.triggered) { return; } + + self.triggered = true; + + // unwrap + if (self.def) { + self = self.def; + } + + self.msg = msg; + self.state = 2; + if (self.chain.length > 0) { + schedule(notify,self); + } + } + + function iteratePromises(Constructor,arr,resolver,rejecter) { + for (var idx=0; idx50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new c["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o;var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),l=e("./worker"),c=r(l);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:c["default"]}},{"./config":2,"./pool":5,"./worker":"./worker"}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this.thread=e,this}},{key:"promise",value:function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(c["default"]);n["default"]=f,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(l["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,l,c=this._events[a],f=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(l=1,u=new Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h,p=c.length;for(l=0;p>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;default:if(!u)for(h=1,u=new Array(f-1);f>h;h++)u[h-1]=arguments[h];c[l].fn.apply(c[l].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,l=s.length;l>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}]},{},[1]); \ No newline at end of file +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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),c=e("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this.thread=e,this}},{key:"promise",value:function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(f["default"]);n["default"]=l,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(c["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;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;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],8:[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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(c){i.call(new a(u),c)}}}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 Date: Tue, 8 Sep 2015 20:42:33 +0200 Subject: [PATCH 042/224] Add missing dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b5df0886..2aafbecd 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "gulp-eslint": "^0.9.0", "gulp-mocha": "^2.1.3", "gulp-rename": "^1.2.2", + "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^1.2.0", "karma": "^0.13.9", "karma-browserify": "^4.3.0", From 4fd2e54e397bc6449e0fd9136c1cb87d0a38c3b2 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 8 Sep 2015 20:42:50 +0200 Subject: [PATCH 043/224] Use babel loose mode --- dist/thread.browser.js | 468 ++++++++++++++----------------- dist/thread.browser.min.js | 2 +- gulpfile.js | 2 +- lib/config.js | 4 +- lib/config.js.map | 2 +- lib/index.js | 4 +- lib/index.js.map | 2 +- lib/job.js | 143 +++++----- lib/job.js.map | 2 +- lib/pool.js | 149 +++++----- lib/pool.js.map | 2 +- lib/worker.browser/worker.js | 178 ++++++------ lib/worker.browser/worker.js.map | 2 +- lib/worker.node/worker.js | 150 +++++----- lib/worker.node/worker.js.map | 2 +- 15 files changed, 491 insertions(+), 621 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 5a4e4174..2a10fef1 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -25,18 +25,10 @@ if (typeof define === 'function') { },{"./index":3}],"./worker":[function(require,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -58,7 +50,7 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); function prependScriptUrl(scriptUrl) { - var prefix = (0, _config.getConfig)().basepath.web; + var prefix = _config.getConfig().basepath.web; return prefix ? prefix + '/' + scriptUrl : scriptUrl; } @@ -83,7 +75,7 @@ var Worker = (function (_EventEmitter) { _classCallCheck(this, Worker); - _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.worker = new window.Worker(slaveCodeDataUri); this.worker.addEventListener('message', this.handleMessage.bind(this)); @@ -94,97 +86,87 @@ var Worker = (function (_EventEmitter) { } } - _createClass(Worker, [{ - key: 'run', - value: function run(toRun) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + Worker.prototype.run = function run(toRun) { + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - if (typeof toRun === 'function') { - this.runMethod(toRun, importScripts); - } else { - this.runScripts(toRun, importScripts); - } - return this; + if (typeof toRun === 'function') { + this.runMethod(toRun, importScripts); + } else { + this.runScripts(toRun, importScripts); } - }, { - key: 'runMethod', - value: function runMethod(method, importScripts) { - var methodStr = method.toString(); - var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); - var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); - - this.worker.postMessage({ - initByMethod: true, - method: { args: args, body: body }, - scripts: importScripts.map(prependScriptUrl) - }); + return this; + }; + + Worker.prototype.runMethod = function runMethod(method, importScripts) { + var methodStr = method.toString(); + var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); + var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); + + this.worker.postMessage({ + initByMethod: true, + method: { args: args, body: body }, + scripts: importScripts.map(prependScriptUrl) + }); + }; + + Worker.prototype.runScripts = function runScripts(script, importScripts) { + if (!script) { + throw new Error('Must pass a function or a script URL to run().'); } - }, { - key: 'runScripts', - value: function runScripts(script, importScripts) { - if (!script) { - throw new Error('Must pass a function or a script URL to run().'); - } - // attention: array for browser, single script for node - this.worker.postMessage({ - initByScripts: true, - scripts: importScripts.concat([script]).map(prependScriptUrl) - }); - } - }, { - key: 'send', - value: function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.worker.postMessage({ - doRun: true, - param: param - }, transferables); - return this; - } - }, { - key: 'kill', - value: function kill() { - this.worker.terminate(); - this.emit('exit'); - return this; - } - }, { - key: 'promise', - value: function promise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); - } - }, { - key: 'handleMessage', - value: function handleMessage(event) { - if (event.data.error) { - this.handleError(event.data.error); - } else { - var responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(_toConsumableArray(responseArgs))); - } + // attention: array for browser, single script for node + this.worker.postMessage({ + initByScripts: true, + scripts: importScripts.concat([script]).map(prependScriptUrl) + }); + }; + + Worker.prototype.send = function send(param) { + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.worker.postMessage({ + doRun: true, + param: param + }, transferables); + return this; + }; + + Worker.prototype.kill = function kill() { + this.worker.terminate(); + this.emit('exit'); + return this; + }; + + Worker.prototype.promise = function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + }; + + Worker.prototype.handleMessage = function handleMessage(event) { + if (event.data.error) { + this.handleError(event.data.error); + } else { + var responseArgs = convertToArray(event.data.response); + this.emit.apply(this, ['message'].concat(responseArgs)); } - }, { - key: 'handleError', - value: function handleError(error) { - if (!this.listeners('error', true)) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } - } - this.emit('error', error); + }; + + Worker.prototype.handleError = function handleError(error) { + if (!this.listeners('error', true)) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } } - }]); + this.emit('error', error); + }; return Worker; })(_eventemitter32['default']); @@ -195,9 +177,7 @@ module.exports = exports['default']; },{"../config":2,"./slave-code":6,"eventemitter3":7}],2:[function(require,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); +exports.__esModule = true; exports.getConfig = getConfig; exports.setConfig = setConfig; var configuration = { @@ -255,9 +235,7 @@ function setConfig() { },{}],3:[function(require,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); +exports.__esModule = true; exports.spawn = spawn; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -296,18 +274,10 @@ exports['default'] = { },{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(require,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -322,7 +292,7 @@ var Job = (function (_EventEmitter) { function Job(pool) { _classCallCheck(this, Job); - _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.pool = pool; this.thread = null; @@ -332,89 +302,80 @@ var Job = (function (_EventEmitter) { pool.emit('newJob', this); } - _createClass(Job, [{ - key: 'run', - value: function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (args.length === 0) { - throw new Error('Cannot call .run() without arguments.'); - } + Job.prototype.run = function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - this.runArgs = args; - return this; + if (args.length === 0) { + throw new Error('Cannot call .run() without arguments.'); } - }, { - key: 'send', - value: function send() { - if (this.runArgs.length === 0) { - throw new Error('Cannot .send() before .run().'); - } - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + this.runArgs = args; + return this; + }; - if (this.hasSendParameter()) { - var _clone$clearSendParameter; + Job.prototype.send = function send() { + if (this.runArgs.length === 0) { + throw new Error('Cannot .send() before .run().'); + } - // do not alter this job, clone it and set send param instead - return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); - } + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - this.sendArgs = args; - this.parameterSet = true; + if (this.hasSendParameter()) { + var _clone$clearSendParameter; - this.emit('readyToRun'); - return this; + // do not alter this job, clone it and set send param instead + return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); } - }, { - key: 'executeOn', - value: function executeOn(thread) { - var _thread$once$once$run, _thread$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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + this.sendArgs = args; + this.parameterSet = true; - this.thread = thread; - return this; - } - }, { - key: 'promise', - value: function promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); - } - }, { - key: 'clone', - value: function clone() { - var clone = new Job(this.pool); + this.emit('readyToRun'); + return this; + }; - if (this.runArgs.length > 0) { - clone.run.apply(clone, _toConsumableArray(this.runArgs)); - } - if (this.parameterSet) { - clone.send.apply(clone, _toConsumableArray(this.sendArgs)); - } + Job.prototype.executeOn = function executeOn(thread) { + var _thread$once$once$run, _thread$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); - return clone; + this.thread = thread; + return this; + }; + + Job.prototype.promise = function promise() { + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); } - }, { - key: 'hasSendParameter', - value: function hasSendParameter() { - return this.parameterSet; + return this.thread.promise(); + }; + + Job.prototype.clone = function clone() { + var clone = new Job(this.pool); + + if (this.runArgs.length > 0) { + clone.run.apply(clone, this.runArgs); } - }, { - key: 'clearSendParameter', - value: function clearSendParameter() { - this.parameterSet = false; - this.sendArgs = []; - return this; + if (this.parameterSet) { + clone.send.apply(clone, this.sendArgs); } - }]); + + return clone; + }; + + Job.prototype.hasSendParameter = function hasSendParameter() { + return this.parameterSet; + }; + + Job.prototype.clearSendParameter = function clearSendParameter() { + this.parameterSet = false; + this.sendArgs = []; + return this; + }; return Job; })(_eventemitter32['default']); @@ -425,13 +386,7 @@ module.exports = exports['default']; },{"eventemitter3":7}],5:[function(require,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -457,7 +412,7 @@ var Pool = (function (_EventEmitter) { _classCallCheck(this, Pool); - _get(Object.getPrototypeOf(Pool.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.threads = Pool.spawn(threads); this.idleThreads = this.threads.slice(); this.jobQueue = []; @@ -466,90 +421,79 @@ var Pool = (function (_EventEmitter) { this.on('newJob', this.handleNewJob.bind(this)); } - _createClass(Pool, [{ - key: 'run', - value: function run() { - var _ref; + Pool.prototype.run = function run() { + var _ref; - return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); - } - }, { - key: 'send', - value: function send() { - var _lastCreatedJob; + return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + }; - if (!this.lastCreatedJob) { - throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); - } + Pool.prototype.send = function send() { + var _lastCreatedJob; - // this will not alter the last job, but rather clone it and set this params on the new job - return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); - } - }, { - key: 'killAll', - value: function killAll() { - this.threads.forEach(function (thread) { - thread.kill(); - }); + if (!this.lastCreatedJob) { + throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - }, { - key: 'queueJob', - value: function queueJob(job) { - this.jobQueue.push(job); - this.dequeue(); - } - }, { - key: 'dequeue', - value: function dequeue() { - if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; - } - var job = this.jobQueue.shift(); - var thread = this.idleThreads.shift(); + // this will not alter the last job, but rather clone it and set this params on the new job + return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + }; - job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + Pool.prototype.killAll = function killAll() { + this.threads.forEach(function (thread) { + thread.kill(); + }); + }; - job.executeOn(thread); - } - }, { - key: 'handleNewJob', - value: function handleNewJob(job) { - this.lastCreatedJob = job; - job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() - } - }, { - key: 'handleJobSuccess', - value: function handleJobSuccess(thread, job) { - for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - responseArgs[_key - 2] = arguments[_key]; - } + Pool.prototype.queueJob = function queueJob(job) { + this.jobQueue.push(job); + this.dequeue(); + }; - this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread); + Pool.prototype.dequeue = function dequeue() { + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { + return; } - }, { - key: 'handleJobError', - value: function handleJobError(thread, job, error) { - this.emit('error', job, error); - this.handleJobDone(thread); + + var job = this.jobQueue.shift(); + var thread = this.idleThreads.shift(); + + job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + + job.executeOn(thread); + }; + + Pool.prototype.handleNewJob = function handleNewJob(job) { + this.lastCreatedJob = job; + job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + }; + + Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { + for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + responseArgs[_key - 2] = arguments[_key]; } - }, { - key: 'handleJobDone', - value: function handleJobDone(thread) { - var _this = this; - - this.idleThreads.push(thread); - this.dequeue(); - - if (this.idleThreads.length === this.threads.length) { - // run deferred to give other job.on('done') handlers time to run first - setTimeout(function () { - _this.emit('finished'); - }, 0); - } + + this.emit.apply(this, ['done', job].concat(responseArgs)); + this.handleJobDone(thread); + }; + + Pool.prototype.handleJobError = function handleJobError(thread, job, error) { + this.emit('error', job, error); + this.handleJobDone(thread); + }; + + Pool.prototype.handleJobDone = function handleJobDone(thread) { + var _this = this; + + this.idleThreads.push(thread); + this.dequeue(); + + if (this.idleThreads.length === this.threads.length) { + // run deferred to give other job.on('done') handlers time to run first + setTimeout(function () { + _this.emit('finished'); + }, 0); } - }]); + }; return Pool; })(_eventemitter32['default']); @@ -560,7 +504,7 @@ Pool.spawn = function (threadCount) { var threads = []; for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push((0, _.spawn)()); + threads.push(_.spawn()); } return threads; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index c48022f7..8b073a7b 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +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;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e);this.emit("error",e)}}]),t}(h["default"]);n["default"]=g,t.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}Object.defineProperty(n,"__esModule",{value:!0}),n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](e,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./pool"),u=r(a),c=e("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);tn;n++)t[n]=arguments[n];if(0===t.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=t,this}},{key:"send",value:function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,this.emit("readyToRun"),this}},{key:"executeOn",value: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,o(this.runArgs))).send.apply(t,o(this.sendArgs)),this.thread=e,this}},{key:"promise",value:function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()}},{key:"clone",value:function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,o(this.runArgs)),this.parameterSet&&n.send.apply(n,o(this.sendArgs)),n}},{key:"hasSendParameter",value:function(){return this.parameterSet}},{key:"clearSendParameter",value:function(){return this.parameterSet=!1,this.sendArgs=[],this}}]),t}(f["default"]);n["default"]=l,t.exports=n["default"]},{eventemitter3:7}],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("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)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)}},{key:"handleJobError",value:function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)}},{key:"handleJobDone",value:function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)}}]),t}(c["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(e,t,n){t.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof 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,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;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;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],8:[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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(c){i.call(new a(u),c)}}}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;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),h=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=h,h.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],h=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),h){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(h-1);h>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var l,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,f[c].fn,void 0,!0),h){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(l=1,u=new Array(h-1);h>l;l++)u[l-1]=arguments[l];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){l.add(t,e),h||(h=d(l.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAAE;;AAC1D,QAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AACv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unction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index e8db95e8..1d15d756 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); +exports.__esModule = true; exports.spawn = spawn; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } diff --git a/lib/index.js.map b/lib/index.js.map index 7b6173d8..41f8fb5c 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;QAAO,qBAAqB;;sBAET,UAAU;;;;oBACV,QAAQ;;;;sBACR,UAAU;;;;QAEpB,MAAM;QAAE,IAAI;;AAEd,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["import 'native-promise-only';\n\nimport config from './config';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n Pool,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;QAAO,qBAAqB;;sBAET,UAAU;;;;oBACV,QAAQ;;;;sBACR,UAAU;;;;QAEpB,MAAM;QAAE,IAAI;;AAEd,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["import 'native-promise-only';\n\nimport config from './config';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n Pool,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/job.js b/lib/job.js index b2aae0b1..c589ea07 100644 --- a/lib/job.js +++ b/lib/job.js @@ -1,17 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -26,7 +18,7 @@ var Job = (function (_EventEmitter) { function Job(pool) { _classCallCheck(this, Job); - _get(Object.getPrototypeOf(Job.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.pool = pool; this.thread = null; @@ -36,89 +28,80 @@ var Job = (function (_EventEmitter) { pool.emit('newJob', this); } - _createClass(Job, [{ - key: 'run', - value: function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (args.length === 0) { - throw new Error('Cannot call .run() without arguments.'); - } + Job.prototype.run = function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - this.runArgs = args; - return this; + if (args.length === 0) { + throw new Error('Cannot call .run() without arguments.'); } - }, { - key: 'send', - value: function send() { - if (this.runArgs.length === 0) { - throw new Error('Cannot .send() before .run().'); - } - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + this.runArgs = args; + return this; + }; - if (this.hasSendParameter()) { - var _clone$clearSendParameter; + Job.prototype.send = function send() { + if (this.runArgs.length === 0) { + throw new Error('Cannot .send() before .run().'); + } - // do not alter this job, clone it and set send param instead - return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); - } + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - this.sendArgs = args; - this.parameterSet = true; + if (this.hasSendParameter()) { + var _clone$clearSendParameter; - this.emit('readyToRun'); - return this; + // do not alter this job, clone it and set send param instead + return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); } - }, { - key: 'executeOn', - value: function executeOn(thread) { - var _thread$once$once$run, _thread$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, _toConsumableArray(this.runArgs))).send.apply(_thread$once$once$run, _toConsumableArray(this.sendArgs)); + this.sendArgs = args; + this.parameterSet = true; - this.thread = thread; - return this; - } - }, { - key: 'promise', - value: function promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); - } - }, { - key: 'clone', - value: function clone() { - var clone = new Job(this.pool); - - if (this.runArgs.length > 0) { - clone.run.apply(clone, _toConsumableArray(this.runArgs)); - } - if (this.parameterSet) { - clone.send.apply(clone, _toConsumableArray(this.sendArgs)); - } - - return clone; + this.emit('readyToRun'); + return this; + }; + + Job.prototype.executeOn = function executeOn(thread) { + var _thread$once$once$run, _thread$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); + + this.thread = thread; + return this; + }; + + Job.prototype.promise = function promise() { + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); } - }, { - key: 'hasSendParameter', - value: function hasSendParameter() { - return this.parameterSet; + return this.thread.promise(); + }; + + Job.prototype.clone = function clone() { + var clone = new Job(this.pool); + + if (this.runArgs.length > 0) { + clone.run.apply(clone, this.runArgs); } - }, { - key: 'clearSendParameter', - value: function clearSendParameter() { - this.parameterSet = false; - this.sendArgs = []; - return this; + if (this.parameterSet) { + clone.send.apply(clone, this.sendArgs); } - }]); + + return clone; + }; + + Job.prototype.hasSendParameter = function hasSendParameter() { + return this.parameterSet; + }; + + Job.prototype.clearSendParameter = function clearSendParameter() { + this.parameterSet = false; + this.sendArgs = []; + return this; + }; return Job; })(_eventemitter32['default']); diff --git a/lib/job.js.map b/lib/job.js.map index 9f569e5d..60c4e0df 100644 --- a/lib/job.js.map +++ b/lib/job.js.map @@ -1 +1 @@ -{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,+BAFiB,GAAG,6CAEZ;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;eAVkB,GAAG;;WAYnB,eAAU;wCAAN,IAAI;AAAJ,YAAI;;;AACT,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,cAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;OAC1D;;AA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AAI,CAAC,CAAC;;AAEjC,UAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,aAAK,CAAC,GAAG,MAAA,CAAT,KAAK,qBAAQ,IAAI,CAAC,OAAO,EAAC,CAAC;OAC5B;AACD,UAAI,IAAI,CAAC,YAAY,EAAE;AACrB,aAAK,CAAC,IAAI,MAAA,CAAV,KAAK,qBAAS,IAAI,CAAC,QAAQ,EAAC,CAAC;OAC9B;;AAED,aAAO,KAAK,CAAC;KACd;;;WAEe,4BAAG;AACjB,aAAO,IAAI,CAAC,YAAY,CAAC;KAC1B;;;WAEiB,8BAAG;AACnB,UAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,UAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,aAAO,IAAI,CAAC;KACb;;;SA7EkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n return this;\n }\n\n promise() {\n if (!this.thread) {\n throw new Error('Cannot return promise, since job is not executed.');\n }\n return this.thread.promise();\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;AAVkB,KAAG,WAYtB,GAAG,GAAA,eAAU;sCAAN,IAAI;AAAJ,UAAI;;;AACT,QAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,YAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;KAC1D;;AAED,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAnBkB,KAAG,WAqBtB,IAAI,GAAA,gBAAU;AACZ,QAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,YAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;;uCAHK,IAAI;AAAJ,UAAI;;;AAKV,QAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;;;;AAE3B,aAAO,6BAAA,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAkB,EAAE,EAAC,IAAI,MAAA,4BAAI,IAAI,CAAC,CAAC;KACxD;;AAED,QAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrB,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;AACjB,WAAO,IAAI,CAAC,YAAY,CAAC;GAC1B;;AAvEkB,KAAG,WAyEtB,kBAAkB,GAAA,8BAAG;AACnB,QAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,WAAO,IAAI,CAAC;GACb;;SA7EkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n return this;\n }\n\n promise() {\n if (!this.thread) {\n throw new Error('Cannot return promise, since job is not executed.');\n }\n return this.thread.promise();\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js index 077a39b3..804f52b6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,12 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -32,7 +26,7 @@ var Pool = (function (_EventEmitter) { _classCallCheck(this, Pool); - _get(Object.getPrototypeOf(Pool.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.threads = Pool.spawn(threads); this.idleThreads = this.threads.slice(); this.jobQueue = []; @@ -41,90 +35,79 @@ var Pool = (function (_EventEmitter) { this.on('newJob', this.handleNewJob.bind(this)); } - _createClass(Pool, [{ - key: 'run', - value: function run() { - var _ref; + Pool.prototype.run = function run() { + var _ref; - return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); - } - }, { - key: 'send', - value: function send() { - var _lastCreatedJob; + return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + }; - if (!this.lastCreatedJob) { - throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); - } + Pool.prototype.send = function send() { + var _lastCreatedJob; - // this will not alter the last job, but rather clone it and set this params on the new job - return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); - } - }, { - key: 'killAll', - value: function killAll() { - this.threads.forEach(function (thread) { - thread.kill(); - }); - } - }, { - key: 'queueJob', - value: function queueJob(job) { - this.jobQueue.push(job); - this.dequeue(); + if (!this.lastCreatedJob) { + throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - }, { - key: 'dequeue', - value: function dequeue() { - if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; - } - var job = this.jobQueue.shift(); - var thread = this.idleThreads.shift(); + // this will not alter the last job, but rather clone it and set this params on the new job + return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + }; - job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + Pool.prototype.killAll = function killAll() { + this.threads.forEach(function (thread) { + thread.kill(); + }); + }; - job.executeOn(thread); - } - }, { - key: 'handleNewJob', - value: function handleNewJob(job) { - this.lastCreatedJob = job; - job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() - } - }, { - key: 'handleJobSuccess', - value: function handleJobSuccess(thread, job) { - for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - responseArgs[_key - 2] = arguments[_key]; - } - - this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread); + Pool.prototype.queueJob = function queueJob(job) { + this.jobQueue.push(job); + this.dequeue(); + }; + + Pool.prototype.dequeue = function dequeue() { + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { + return; } - }, { - key: 'handleJobError', - value: function handleJobError(thread, job, error) { - this.emit('error', job, error); - this.handleJobDone(thread); + + var job = this.jobQueue.shift(); + var thread = this.idleThreads.shift(); + + job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + + job.executeOn(thread); + }; + + Pool.prototype.handleNewJob = function handleNewJob(job) { + this.lastCreatedJob = job; + job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + }; + + Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { + for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + responseArgs[_key - 2] = arguments[_key]; } - }, { - key: 'handleJobDone', - value: function handleJobDone(thread) { - var _this = this; - - this.idleThreads.push(thread); - this.dequeue(); - - if (this.idleThreads.length === this.threads.length) { - // run deferred to give other job.on('done') handlers time to run first - setTimeout(function () { - _this.emit('finished'); - }, 0); - } + + this.emit.apply(this, ['done', job].concat(responseArgs)); + this.handleJobDone(thread); + }; + + Pool.prototype.handleJobError = function handleJobError(thread, job, error) { + this.emit('error', job, error); + this.handleJobDone(thread); + }; + + Pool.prototype.handleJobDone = function handleJobDone(thread) { + var _this = this; + + this.idleThreads.push(thread); + this.dequeue(); + + if (this.idleThreads.length === this.threads.length) { + // run deferred to give other job.on('done') handlers time to run first + setTimeout(function () { + _this.emit('finished'); + }, 0); } - }]); + }; return Pool; })(_eventemitter32['default']); @@ -135,7 +118,7 @@ Pool.spawn = function (threadCount) { var threads = []; for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push((0, _.spawn)()); + threads.push(_.spawn()); } return threads; diff --git a/lib/pool.js.map b/lib/pool.js.map index 467332c8..178da719 100644 --- a/lib/pool.js.map +++ b/lib/pool.js.map @@ -1 +1 @@ -{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;gBACP,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,GACE;QAAb,OAAO,yDAAG,CAAC;;0BADJ,IAAI;;AAErB,+BAFiB,IAAI,6CAEb;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACnC,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAA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GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads = 8) {\n super();\n this.threads = Pool.spawn(threads);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.lastCreatedJob = null;\n\n this.on('newJob', this.handleNewJob.bind(this));\n }\n\n run(...args) {\n return (new Job(this)).run(...args);\n }\n\n send(...args) {\n if (!this.lastCreatedJob) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n // this will not alter the last job, but rather clone it and set this params on the new job\n return this.lastCreatedJob.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["p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MAAI,WAiEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,OAAO,EAAE,CAAC;;AAEf,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,cAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SAzEkB,IAAI;;;qBAAJ,IAAI;;AA4EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads = 8) {\n super();\n this.threads = Pool.spawn(threads);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.lastCreatedJob = null;\n\n this.on('newJob', this.handleNewJob.bind(this));\n }\n\n run(...args) {\n return (new Job(this)).run(...args);\n }\n\n send(...args) {\n if (!this.lastCreatedJob) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n // this will not alter the last job, but rather clone it and set this params on the new job\n return this.lastCreatedJob.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index bf46419d..bee78161 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -1,17 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -33,7 +25,7 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); function prependScriptUrl(scriptUrl) { - var prefix = (0, _config.getConfig)().basepath.web; + var prefix = _config.getConfig().basepath.web; return prefix ? prefix + '/' + scriptUrl : scriptUrl; } @@ -58,7 +50,7 @@ var Worker = (function (_EventEmitter) { _classCallCheck(this, Worker); - _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.worker = new window.Worker(slaveCodeDataUri); this.worker.addEventListener('message', this.handleMessage.bind(this)); @@ -69,97 +61,87 @@ var Worker = (function (_EventEmitter) { } } - _createClass(Worker, [{ - key: 'run', - value: function run(toRun) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - if (typeof toRun === 'function') { - this.runMethod(toRun, importScripts); - } else { - this.runScripts(toRun, importScripts); - } - return this; - } - }, { - key: 'runMethod', - value: function runMethod(method, importScripts) { - var methodStr = method.toString(); - var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); - var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); - - this.worker.postMessage({ - initByMethod: true, - method: { args: args, body: body }, - scripts: importScripts.map(prependScriptUrl) - }); - } - }, { - key: 'runScripts', - value: function runScripts(script, importScripts) { - if (!script) { - throw new Error('Must pass a function or a script URL to run().'); - } - - // attention: array for browser, single script for node - this.worker.postMessage({ - initByScripts: true, - scripts: importScripts.concat([script]).map(prependScriptUrl) - }); - } - }, { - key: 'send', - value: function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.worker.postMessage({ - doRun: true, - param: param - }, transferables); - return this; - } - }, { - key: 'kill', - value: function kill() { - this.worker.terminate(); - this.emit('exit'); - return this; + Worker.prototype.run = function run(toRun) { + var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + if (typeof toRun === 'function') { + this.runMethod(toRun, importScripts); + } else { + this.runScripts(toRun, importScripts); } - }, { - key: 'promise', - value: function promise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); + return this; + }; + + Worker.prototype.runMethod = function runMethod(method, importScripts) { + var methodStr = method.toString(); + var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); + var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); + + this.worker.postMessage({ + initByMethod: true, + method: { args: args, body: body }, + scripts: importScripts.map(prependScriptUrl) + }); + }; + + Worker.prototype.runScripts = function runScripts(script, importScripts) { + if (!script) { + throw new Error('Must pass a function or a script URL to run().'); } - }, { - key: 'handleMessage', - value: function handleMessage(event) { - if (event.data.error) { - this.handleError(event.data.error); - } else { - var responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(_toConsumableArray(responseArgs))); - } + + // attention: array for browser, single script for node + this.worker.postMessage({ + initByScripts: true, + scripts: importScripts.concat([script]).map(prependScriptUrl) + }); + }; + + Worker.prototype.send = function send(param) { + var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + this.worker.postMessage({ + doRun: true, + param: param + }, transferables); + return this; + }; + + Worker.prototype.kill = function kill() { + this.worker.terminate(); + this.emit('exit'); + return this; + }; + + Worker.prototype.promise = function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + }; + + Worker.prototype.handleMessage = function handleMessage(event) { + if (event.data.error) { + this.handleError(event.data.error); + } else { + var responseArgs = convertToArray(event.data.response); + this.emit.apply(this, ['message'].concat(responseArgs)); } - }, { - key: 'handleError', - value: function handleError(error) { - if (!this.listeners('error', true)) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } - } - this.emit('error', error); + }; + + Worker.prototype.handleError = function handleError(error) { + if (!this.listeners('error', true)) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } } - }]); + this.emit('error', error); + }; return Worker; })(_eventemitter32['default']); diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index b7466f9a..fc842e2b 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,I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AI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,mBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;WAChE,MAAM;AACL,qBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;OACF;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SAzFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS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,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,iBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;SAChE,MAAM;AACL,mBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;WACtB;KACF;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAzFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index b8520ae6..06d8c4c4 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -1,17 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -38,7 +30,7 @@ var Worker = (function (_EventEmitter) { _classCallCheck(this, Worker); - _get(Object.getPrototypeOf(Worker.prototype), 'constructor', this).call(this); + _EventEmitter.call(this); this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.js'), [], options); this.slave.on('message', this.handleMessage.bind(this)); @@ -50,84 +42,74 @@ var Worker = (function (_EventEmitter) { } } - _createClass(Worker, [{ - key: 'run', - value: function run(toRun) { - if (typeof toRun === 'function') { - this.runMethod(toRun); - } else { - this.runScript(toRun); - } - return this; - } - }, { - key: 'runMethod', - value: function runMethod(method) { - this.slave.send({ - initByMethod: true, - method: method.toString() - }); - } - }, { - key: 'runScript', - value: function runScript(script) { - if (!script) { - throw new Error('Must pass a function or a script path to run().'); - } - - var prefixedScriptPath = _path2['default'].join((0, _config.getConfig)().basepath.node, script); - - // attention: single script for node, array for browser - this.slave.send({ - initByScript: true, - script: _path2['default'].resolve(prefixedScriptPath) - }); + Worker.prototype.run = function run(toRun) { + if (typeof toRun === 'function') { + this.runMethod(toRun); + } else { + this.runScript(toRun); } - }, { - key: 'send', - value: function send(param) { - this.slave.send({ - doRun: true, - param: param - }); - return this; + return this; + }; + + Worker.prototype.runMethod = function runMethod(method) { + this.slave.send({ + initByMethod: true, + method: method.toString() + }); + }; + + Worker.prototype.runScript = function runScript(script) { + if (!script) { + throw new Error('Must pass a function or a script path to run().'); } - }, { - key: 'kill', - value: function kill() { - this.slave.kill(); - return this; - } - }, { - key: 'promise', - value: function promise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); - } - }, { - key: 'handleMessage', - value: function handleMessage(message) { - if (message.error) { - var error = new Error(message.error.message); - error.stack = message.error.stack; - - this.handleError(error); - } else { - this.emit.apply(this, ['message'].concat(_toConsumableArray(message.response))); - } + + var prefixedScriptPath = _path2['default'].join(_config.getConfig().basepath.node, script); + + // attention: single script for node, array for browser + this.slave.send({ + initByScript: true, + script: _path2['default'].resolve(prefixedScriptPath) + }); + }; + + Worker.prototype.send = function send(param) { + this.slave.send({ + doRun: true, + param: param + }); + return this; + }; + + Worker.prototype.kill = function kill() { + this.slave.kill(); + return this; + }; + + Worker.prototype.promise = function promise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); + }; + + Worker.prototype.handleMessage = function handleMessage(message) { + if (message.error) { + var error = new Error(message.error.message); + error.stack = message.error.stack; + + this.handleError(error); + } else { + this.emit.apply(this, ['message'].concat(message.response)); } - }, { - key: 'handleError', - value: function handleError(error) { - if (!this.listeners('error', true)) { - console.error(error.stack || error); // eslint-disable-line no-console - } - this.emit('error', error); + }; + + Worker.prototype.handleError = function handleError(error) { + if (!this.listeners('error', true)) { + console.error(error.stack || error); // eslint-disable-line no-console } - }]); + this.emit('error', error); + }; return Worker; })(_eventemitter32['default']); diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index b709a386..fe0a2463 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,+BAFiB,MAAM,6CAEf;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;eAZkB,MAAM;;WActB,aAAC,KAAK,EAAE;AACT,UAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;OACvB,MAAM;AACL,YAAI,CAAC,SAAS,CAAC,K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AK,CAAC;;AAElC,YAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;OACzB,MAAM;AACL,YAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,4BAAK,OAAO,CAAC,QAAQ,GAAC,CAAC;OAC3C;KACF;;;WAEU,qBAAC,KAAK,EAAE;AACjB,UAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;OACrC;AACD,UAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3B;;;SA/EkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;AAZkB,QAAM,WAczB,GAAG,GAAA,aAAC,KAAK,EAAE;AACT,QAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,UAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB,MAAM;AACL,UAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB;AACD,WAAO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AAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,WAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KACzB,MAAM;AACL,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;KAC3C;GACF;;AAxEkB,QAAM,WA0EzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SA/EkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file From 8aa9da2d38f9b01f407c9564ffb3e3ab3e95ddc7 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 11 Sep 2015 19:30:25 +0200 Subject: [PATCH 044/224] Add travis config --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..513be4da --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.12 + - 4.0 From c1cda1d34f232bf04d05c94fc4127bdf02227a41 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 11 Sep 2015 19:34:49 +0200 Subject: [PATCH 045/224] Update travis config for karma browser --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 513be4da..b92c81dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,6 @@ language: node_js node_js: - 0.12 - 4.0 +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start From 0ea68ccaefe4a9b8d50becff2aadc88bb4311601 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 11 Sep 2015 19:38:23 +0200 Subject: [PATCH 046/224] Another try to use travis-ci, karma & chrome --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b92c81dd..0cf4ca24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ node_js: - 0.12 - 4.0 before_script: + - export CHROME_BIN=chromium-browser - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From 3d6bf01857cca7c365f4158936077dcb606f7fa3 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 11 Sep 2015 19:42:36 +0200 Subject: [PATCH 047/224] Try running chrome with --no-sandbox on travis --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 28bb2a39..91f8c4dc 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -72,7 +72,7 @@ module.exports = function(config) { customLaunchers: { ChromeInsecure: { base: 'Chrome', - flags: ['--disable-web-security'] + flags: ['--disable-web-security', '--no-sandbox'] } }, From 3e927fad2425ffea37a64e97d6b4f218f8423e75 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 18:25:19 +0200 Subject: [PATCH 048/224] Web worker: Use self instead of this in root scope --- dist/thread.browser.js | 2 +- dist/thread.browser.min.js | 2 +- lib/worker.browser/slave-code.js | 2 +- src/worker.browser/slave.js.txt | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 2a10fef1..795d7198 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -512,7 +512,7 @@ Pool.spawn = function (threadCount) { module.exports = exports['default']; //# sourceMappingURL=pool.js.map },{"./":3,"./job":4,"eventemitter3":7}],6:[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"; +module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 self.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"; },{}],7:[function(require,module,exports){ 'use strict'; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 8b073a7b..6264048e 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),h=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=h,h.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.module = {\n exports : function() {\n if (console) { console.error('No thread logic initialized.'); }\n }\n};\n\nfunction handlerDone() {\n this.postMessage({ response : arguments });\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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(this);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],h=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),h){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(h-1);h>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var l,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,f[c].fn,void 0,!0),h){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(l=1,u=new Array(h-1);h>l;l++)u[l-1]=arguments[l];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){l.add(t,e),h||(h=d(l.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 self.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o Date: Fri, 18 Sep 2015 19:18:32 +0200 Subject: [PATCH 049/224] Web worker: Fix more context issues --- dist/thread.browser.js | 2 +- dist/thread.browser.min.js | 2 +- lib/worker.browser/slave-code.js | 2 +- src/worker.browser/slave.js.txt | 6 +++--- test/thread-scripts/import-me.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 795d7198..5c8424f9 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -512,7 +512,7 @@ Pool.spawn = function (threadCount) { module.exports = exports['default']; //# sourceMappingURL=pool.js.map },{"./":3,"./job":4,"eventemitter3":7}],6:[function(require,module,exports){ -module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 self.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"; +module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"; },{}],7:[function(require,module,exports){ 'use strict'; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 6264048e..173f32fd 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.exports="/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disable no-console*/\nthis.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\n}\n\nthis.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 self.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 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 handler(event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 0 && typeof importScripts !== 'function') { throw new Error('importScripts() not supported.'); @@ -51,6 +51,6 @@ this.onmessage = function (event) { var preparedHandlerDone = handlerDone.bind(this); preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); - handler(event.data.param, preparedHandlerDone); + handler.call(this, event.data.param, preparedHandlerDone); } }.bind(self); diff --git a/test/thread-scripts/import-me.js b/test/thread-scripts/import-me.js index c4e76c41..eb78fb3c 100644 --- a/test/thread-scripts/import-me.js +++ b/test/thread-scripts/import-me.js @@ -1,3 +1,3 @@ -this.importedEcho = function(input, done) { +self.importedEcho = function(input, done) { done(input); }; From 1ee715ff77b092d0bd15003c84f5d51ef02efeb6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 20:04:40 +0200 Subject: [PATCH 050/224] Split handleError method --- dist/thread.browser.js | 20 ++++++++++++-------- dist/thread.browser.min.js | 2 +- lib/worker.browser/worker.js | 20 ++++++++++++-------- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 24 ++++++++++++++---------- 5 files changed, 40 insertions(+), 28 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 5c8424f9..4ffd16e2 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -66,6 +66,17 @@ function convertToArray(input) { return outputArray; } +function logError(error) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } +} + var Worker = (function (_EventEmitter) { _inherits(Worker, _EventEmitter); @@ -156,14 +167,7 @@ var Worker = (function (_EventEmitter) { Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } + logError(error); } this.emit('error', error); }; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index 173f32fd..efdbc827 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t);this.emit("error",t)},e}(c["default"]);n["default"]=d,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.worker=new window.Worker(d),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } +} + var Worker = (function (_EventEmitter) { _inherits(Worker, _EventEmitter); @@ -131,14 +142,7 @@ var Worker = (function (_EventEmitter) { Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } + logError(error); } this.emit('error', error); }; diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index fc842e2b..054eb74c 100644 --- a/lib/worker.brow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AzEkB,QAAM,WA2EzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,UAAI,KAAK,CAAC,KAAK,EAAE;AACf,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;OAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1D,cAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,GAC5E,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GACpC,KAAK,CAAC,QAAQ,CAAC;AAChC,iBAAO,CAAC,KAAK,CAAI,KAAK,CAAC,OAAO,UAAK,QAAQ,SAAI,KAAK,CAAC,MAAM,CAAG,CAAC;SAChE,MAAM;AACL,mBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;WACtB;KACF;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAzFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n }\n this.emit('error', error);\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AAC,CAAC;AAClB,WAAO,IAAI,CAAC;GACb;;AAxDkB,QAAM,WA0DzB,OAAO,GAAA,mBAAG;;;AACR,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM,EAAK;AACtC,YACG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACxB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAC1B,CAAC,CAAC;GACJ;;AAhEkB,QAAM,WAkEzB,aAAa,GAAA,uBAAC,KAAK,EAAE;AACnB,QAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC,MAAM;AACL,UAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;KACvC;GACF;;AAzEkB,QAAM,WA2EzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index b50ea35f..8f781cc9 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -28,6 +28,19 @@ function convertToArray(input) { return outputArray; } +function logError(error) { + if (error.stack) { + console.error(error.stack); // eslint-disable-line no-console + } else if (error.message && error.filename && error.lineno) { + const fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 + ? error.filename.substr(0, 50) + '...' + : error.filename; + console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } +} + export default class Worker extends EventEmitter { constructor(initialScript = null, importScripts = []) { @@ -106,16 +119,7 @@ export default class Worker extends EventEmitter { handleError(error) { if (!this.listeners('error', true)) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - const fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 - ? error.filename.substr(0, 50) + '...' - : error.filename; - console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } + logError(error); } this.emit('error', error); } From 2b88123ccd3030e7b6b74810e16ef4e0b20b96e0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 21:28:02 +0200 Subject: [PATCH 051/224] Call error.preventDefault() --- dist/thread.browser.js | 2 ++ dist/thread.browser.min.js | 2 +- lib/worker.browser/worker.js | 2 ++ lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/thread.browser.js b/dist/thread.browser.js index 4ffd16e2..fbda906b 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -169,6 +169,8 @@ var Worker = (function (_EventEmitter) { if (!this.listeners('error', true)) { logError(error); } + + error.preventDefault(); this.emit('error', error); }; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index efdbc827..f82ab840 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.worker=new window.Worker(d),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.worker=new window.Worker(d),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault(),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;y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AC,UAAC,OAAO,EAAE,MAAM,EAAK;AACtC,YACG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACxB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAC1B,CAAC,CAAC;GACJ;;AAhEkB,QAAM,WAkEzB,aAAa,GAAA,uBAAC,KAAK,EAAE;AACnB,QAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC,MAAM;AACL,UAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;KACvC;GACF;;AAzEkB,QAAM,WA2EzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,SAAK,CAAC,cAAc,EAAE,CAAC;AACvB,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAlFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n error.preventDefault();\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 8f781cc9..0cae8df8 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -121,6 +121,8 @@ export default class Worker extends EventEmitter { if (!this.listeners('error', true)) { logError(error); } + + error.preventDefault(); this.emit('error', error); } } From 297a917c817299561f1fc172a6b7dcac3d5a9598 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 21:32:36 +0200 Subject: [PATCH 052/224] Minor adaptions for Firefox testing --- test/spec-src/worker.spec.js | 4 ++-- test/spec/worker.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index a22bd3af..4f6a4d01 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -121,7 +121,7 @@ describe('Worker', () => { }); worker.on('error', error => { - expect(error.message).to.match(/^(Uncaught Error: )?Test message$/); + expect(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); done(); }); worker.send(); @@ -149,7 +149,7 @@ describe('Worker', () => { .promise(); promise.catch(error => { - expect(error.message).to.match(/^(Uncaught Error: )?I fail$/); + expect(error.message).to.match(/^((Uncaught )?Error: )?I fail$/); done(); }); }); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 85d05fc8..2cf1beef 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -126,7 +126,7 @@ describe('Worker', function () { }); worker.on('error', function (error) { - (0, _expectJs2['default'])(error.message).to.match(/^(Uncaught Error: )?Test message$/); + (0, _expectJs2['default'])(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); done(); }); worker.send(); @@ -150,7 +150,7 @@ describe('Worker', function () { var promise = worker.send().promise(); promise['catch'](function (error) { - (0, _expectJs2['default'])(error.message).to.match(/^(Uncaught Error: )?I fail$/); + (0, _expectJs2['default'])(error.message).to.match(/^((Uncaught )?Error: )?I fail$/); done(); }); }); From 613727d027d2e5764abad3fa3a37c32eff06def0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 21:33:24 +0200 Subject: [PATCH 053/224] Run tests on Firefox --- .travis.yml | 1 + karma.conf.js | 2 +- package.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0cf4ca24..867fbc45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,5 @@ node_js: before_script: - export CHROME_BIN=chromium-browser - export DISPLAY=:99.0 + - export TRAVISCI=1 - sh -e /etc/init.d/xvfb start diff --git a/karma.conf.js b/karma.conf.js index 91f8c4dc..27b9787d 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -66,7 +66,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['ChromeInsecure'], + browsers: process.env.TRAVISCI ? ['Firefox'] : ['ChromeInsecure', 'Firefox'], customLaunchers: { diff --git a/package.json b/package.json index 2aafbecd..4b1f1987 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "karma-browserify": "^4.3.0", "karma-chrome-launcher": "^0.2.0", "karma-expect": "^1.1.0", + "karma-firefox-launcher": "^0.1.6", "karma-mocha": "^0.2.0", "karma-phantomjs-launcher": "^0.2.1", "phantomjs": "^1.9.18", From d26eb69dfc9f08ad9e58ab4de4f4dde298fa8d4e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 21:47:08 +0200 Subject: [PATCH 054/224] Minor testing code improvement --- test/spec-src/worker.spec.js | 13 +++++++++---- test/spec/worker.spec.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 4f6a4d01..f8123691 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -25,6 +25,14 @@ function canSendAndReceiveEcho(worker, done) { canSendAndReceive(worker, testData, testData, done); } +function expectEqualBuffers(buffer1, buffer2) { + expect(buffer2.byteLength).to.equal(buffer1.byteLength); + + for (let index = 0; index < buffer1.byteLength; index++) { + expect(buffer2[ index ]).to.equal(buffer1[ index ]); + } +} + describe('Worker', () => { @@ -209,10 +217,7 @@ describe('Worker', () => { }) .send({ data: arrayBuffer }, [ arrayBuffer.buffer ]) .on('message', (response) => { - expect(response.data.byteLength).to.equal(arrayBufferClone.byteLength); - for (let index = 0; index < arrayBufferClone.byteLength; index++) { - expect(response.data[ index ]).to.equal(arrayBufferClone[ index ]); - } + expectEqualBuffers(arrayBufferClone, response.data); worker.kill(); done(); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 2cf1beef..2063c972 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -38,6 +38,14 @@ function canSendAndReceiveEcho(worker, done) { canSendAndReceive(worker, testData, testData, done); } +function expectEqualBuffers(buffer1, buffer2) { + (0, _expectJs2['default'])(buffer2.byteLength).to.equal(buffer1.byteLength); + + for (var index = 0; index < buffer1.byteLength; index++) { + (0, _expectJs2['default'])(buffer2[index]).to.equal(buffer1[index]); + } +} + describe('Worker', function () { before(function () { @@ -200,10 +208,7 @@ describe('Worker', function () { var worker = (0, _.spawn)().run(function (input, threadDone) { threadDone.transfer(input, [input.data.buffer]); }).send({ data: arrayBuffer }, [arrayBuffer.buffer]).on('message', function (response) { - (0, _expectJs2['default'])(response.data.byteLength).to.equal(arrayBufferClone.byteLength); - for (var index = 0; index < arrayBufferClone.byteLength; index++) { - (0, _expectJs2['default'])(response.data[index]).to.equal(arrayBufferClone[index]); - } + expectEqualBuffers(arrayBufferClone, response.data); worker.kill(); done(); From 1c9cc9fd650669217c6f81e2822f318081aa1f2b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 18 Sep 2015 21:55:04 +0200 Subject: [PATCH 055/224] Increase timeout for our problem child --- test/spec-src/worker.spec.js | 5 ++++- test/spec/worker.spec.js | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index f8123691..7362c216 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -202,7 +202,10 @@ describe('Worker', () => { }); }); - it('can use transferables', done => { + it('can use transferables', function(done) { + // for some reason this test consumes extra-ordinarily much time when run on travis ci + this.timeout(5000); + const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB const arrayBufferClone = new Uint8Array(1024 * 2); // need to clone, because referencing arrayBuffer will not work after .send() diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 2063c972..831451d2 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -197,6 +197,9 @@ describe('Worker', function () { }); it('can use transferables', function (done) { + // for some reason this test consumes extra-ordinarily much time when run on travis ci + this.timeout(5000); + var arrayBuffer = new Uint8Array(1024 * 2); // 2 KB var arrayBufferClone = new Uint8Array(1024 * 2); // need to clone, because referencing arrayBuffer will not work after .send() From 4dd2b56af766ef0c303649964e762e6b05c81f64 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 19 Sep 2015 18:39:05 +0200 Subject: [PATCH 056/224] Try using env.global setting --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 867fbc45..8d7bc81f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,10 @@ language: node_js node_js: - 0.12 - 4.0 +env: + global: + - CHROME_BIN=chromium-browser + - DISPLAY=:99.0 + - TRAVISCI=1 before_script: - - export CHROME_BIN=chromium-browser - - export DISPLAY=:99.0 - - export TRAVISCI=1 - sh -e /etc/init.d/xvfb start From a2edb923c25ad20a857d3de787af17904428570e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 19 Sep 2015 18:46:03 +0200 Subject: [PATCH 057/224] Update readme: Add beta notice --- readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d842f3ef..1c851d4c 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,6 @@ -# threads.js +# threads.js - BETA + +**Attention: This is an early release. Use with care and be aware that the API might still change.** Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. From 825534f8da72fa4296aa8d83d41e2de5bbb88e8e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 20 Sep 2015 01:42:39 +0200 Subject: [PATCH 058/224] Update readme --- readme.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 1c851d4c..c64299d4 100644 --- a/readme.md +++ b/readme.md @@ -1,17 +1,15 @@ # threads.js - BETA +[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) **Attention: This is an early release. Use with care and be aware that the API might still change.** Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. -- Convenience API - For client and server use - Use different APIs (web worker, node child_process) transparently - Thread pools -- example use cases - ES6 and backwards-compatible -- Planned features: Shared workers ## How To @@ -240,15 +238,12 @@ thread ### Use external dependencies -TODO --> gulp task to bundle deps using browserify and expose all of them -> dependency bundle --> dependency bundle can be imported by importScripts() --> code can just call `var axios = require('axios');`, no matter if browser or node.js +Not yet completely implemented. - -## API - -You can find the API documentation in the [wiki](https://github.com/andywer/thread.js/wiki). +To do: +- gulp task to bundle dependencies using browserify and expose all of them -> dependency bundle +- dependency bundle can be imported by importScripts() +- code can just call `var myDependency = require('my-dependency');`, no matter if browser or node.js ## License From 55d0990807a1ff6ce51ca4ba36c60c730fba4090 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 20 Sep 2015 16:41:25 +0200 Subject: [PATCH 059/224] Fix an issue related to web worker fallback --- lib/worker.browser/worker.js | 5 ++++- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index f184f5b7..896e0365 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -145,7 +145,10 @@ var Worker = (function (_EventEmitter) { logError(error); } - error.preventDefault(); + if (error.preventDefault) { + error.preventDefault(); + } + this.emit('error', error); }; diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 682cc5fd..0a8eecc5 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;AAED,SAAS,QAAQ,CAAC,KA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E,KAAK,CAAC,CAAC;GAC3B;;SAlFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n error.preventDefault();\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,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AAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SArFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 0cae8df8..e6e39c6d 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -122,7 +122,10 @@ export default class Worker extends EventEmitter { logError(error); } - error.preventDefault(); + if (error.preventDefault) { + error.preventDefault(); + } + this.emit('error', error); } } From dd2c0d1b15a2fb917d79db35354ea4789444dfa4 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 20 Sep 2015 18:19:53 +0200 Subject: [PATCH 060/224] Update readme: Link to webworker-fallback --- readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.md b/readme.md index c64299d4..42994f81 100644 --- a/readme.md +++ b/readme.md @@ -236,6 +236,12 @@ thread .send(jobData, [ largeArrayBuffer.buffer ]); ``` +### Web worker fallback + +You can provide a fallback if the user's browser does not support web workers. +See [webworker-fallback](https://github.com/andywer/webworker-fallback). This will not have any effect if used by node.js code. + + ### Use external dependencies Not yet completely implemented. From 36b260016bfb7721aff7c0670f3f85dc12063d12 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 09:01:03 +0200 Subject: [PATCH 061/224] Implement slave script fallback --- dist/slave.js | 56 ++++++++++++++++++++++++++++++++ dist/slave.min.js | 1 + dist/thread.browser.js | 25 ++++++++++++-- dist/thread.browser.min.js | 2 +- gulpfile.js | 18 +++++++++- lib/config.js | 3 ++ lib/config.js.map | 2 +- lib/worker.browser/worker.js | 17 +++++++++- lib/worker.browser/worker.js.map | 2 +- readme.md | 19 +++++++++++ src/config.js | 3 ++ src/worker.browser/worker.js | 17 +++++++++- 12 files changed, 157 insertions(+), 8 deletions(-) create mode 100644 dist/slave.js create mode 100644 dist/slave.min.js diff --git a/dist/slave.js b/dist/slave.js new file mode 100644 index 00000000..403205cb --- /dev/null +++ b/dist/slave.js @@ -0,0 +1,56 @@ +/*eslint-env worker*/ +/*global importScripts*/ +/*eslint-disable no-console*/ +self.module = { + exports : function() { + if (console) { console.error('No thread logic initialized.'); } + } +}; + +function handlerDone() { + var args = Array.prototype.slice.call(arguments, 0); + this.postMessage({ response : args }); +} + +function handlerDoneTransfer() { + var args = Array.prototype.slice.call(arguments); + var lastArg = args.pop(); + + if (!(lastArg instanceof Array) && this.console) { + console.error('Expected 2nd parameter of .transfer() to be an array. Got:', lastArg); + } + + this.postMessage({ response : args }, lastArg); +} + +self.onmessage = function (event) { + var scripts = event.data.scripts; + if (scripts && scripts.length > 0 && typeof importScripts !== 'function') { + throw new Error('importScripts() not supported.'); + } + + if (event.data.initByScripts) { + importScripts.apply(null, scripts); + } + + if (event.data.initByMethod) { + var method = event.data.method; + this.module.exports = Function.apply(null, method.args.concat(method.body)); + + if (scripts && scripts.length > 0) { + importScripts.apply(null, scripts); + } + } + + if (event.data.doRun) { + var handler = this.module.exports; + if (typeof handler !== 'function') { + throw new Error('Cannot run thread logic. No handler has been exported.'); + } + + var preparedHandlerDone = handlerDone.bind(this); + preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); + + handler.call(this, event.data.param, preparedHandlerDone); + } +}.bind(self); diff --git a/dist/slave.min.js b/dist/slave.min.js new file mode 100644 index 00000000..f1f10b8a --- /dev/null +++ b/dist/slave.min.js @@ -0,0 +1 @@ +function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n)}}.bind(self); \ No newline at end of file diff --git a/dist/thread.browser.js b/dist/thread.browser.js index fbda906b..2adf7e48 100644 --- a/dist/thread.browser.js +++ b/dist/thread.browser.js @@ -88,7 +88,7 @@ var Worker = (function (_EventEmitter) { _EventEmitter.call(this); - this.worker = new window.Worker(slaveCodeDataUri); + this.initWorker(); this.worker.addEventListener('message', this.handleMessage.bind(this)); this.worker.addEventListener('error', this.handleError.bind(this)); @@ -97,6 +97,21 @@ var Worker = (function (_EventEmitter) { } } + Worker.prototype.initWorker = function initWorker() { + try { + this.worker = new window.Worker(slaveCodeDataUri); + } catch (error) { + var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; + if (slaveScriptUrl) { + // try using the slave script file instead of the data URI + this.worker = new window.Worker(slaveCodeDataUri); + } else { + // re-throw + throw error; + } + } + }; + Worker.prototype.run = function run(toRun) { var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; @@ -170,7 +185,10 @@ var Worker = (function (_EventEmitter) { logError(error); } - error.preventDefault(); + if (error.preventDefault) { + error.preventDefault(); + } + this.emit('error', error); }; @@ -190,6 +208,9 @@ var configuration = { basepath: { node: '', web: '' + }, + fallback: { + slaveScriptUrl: '' } }; diff --git a/dist/thread.browser.min.js b/dist/thread.browser.min.js index f82ab840..7a07e5ee 100644 --- a/dist/thread.browser.min.js +++ b/dist/thread.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.worker=new window.Worker(d),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault(),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;AACD,UAAQ,EAAG;AACT,kBAAc,EAAG,EAAE;GACpB;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAA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MAAM,YAAa,CAAC;CAC5B","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n },\n fallback : {\n slaveScriptUrl : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js index 896e0365..b2734549 100644 --- a/lib/worker.browser/worker.js +++ b/lib/worker.browser/worker.js @@ -63,7 +63,7 @@ var Worker = (function (_EventEmitter) { _EventEmitter.call(this); - this.worker = new window.Worker(slaveCodeDataUri); + this.initWorker(); this.worker.addEventListener('message', this.handleMessage.bind(this)); this.worker.addEventListener('error', this.handleError.bind(this)); @@ -72,6 +72,21 @@ var Worker = (function (_EventEmitter) { } } + Worker.prototype.initWorker = function initWorker() { + try { + this.worker = new window.Worker(slaveCodeDataUri); + } catch (error) { + var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; + if (slaveScriptUrl) { + // try using the slave script file instead of the data URI + this.worker = new window.Worker(slaveCodeDataUri); + } else { + // re-throw + throw error; + } + } + }; + Worker.prototype.run = function run(toRun) { var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 0a8eecc5..e0cada83 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;AAED,SAAS,QAAQ,CAAC,KAAK,EAAE;AACvB,MAAI,KAAK,CAAC,KAAK,EAAE;AACf,WAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;GAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MA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AE,aAAa,CAAC,CAAC;AAClB,WAAO,IAAI,CAAC;GACb;;AAlDkB,QAAM,WAoDzB,IAAI,GAAA,gBAAG;AACL,QAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;AACxB,QAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,WAAO,IAAI,CAAC;GACb;;AAxDkB,QAAM,WA0DzB,OAAO,GAAA,mBAAG;;;AACR,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM,EAAK;AACtC,YACG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACxB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAC1B,CAAC,CAAC;GACJ;;AAhEkB,QAAM,WAkEzB,aAAa,GAAA,uBAAC,KAAK,EAAE;AACnB,QAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC,MAAM;AACL,UAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;KACvC;GACF;;AAzEkB,QAAM,WA2EzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SArFkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.worker = new window.Worker(slaveCodeDataUri);\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,SAAK,EAAE,CAAC;GACT;;AAED,SAAO,WAAW,CAAC;CACpB;;AAED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I,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;KACvC;GACF;;AAxFkB,QAAM,WA0FzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SApGkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/readme.md b/readme.md index 42994f81..b83c3eed 100644 --- a/readme.md +++ b/readme.md @@ -252,6 +252,25 @@ To do: - code can just call `var myDependency = require('my-dependency');`, no matter if browser or node.js +## Configuration + +```javascript +import { config } from 'threads'; +// ES5 syntax: var config = require('threads').config + +// These configuration properties are all optional +config.set({ + basepath : { + node : 'path/to/my/worker/scripts/directory', + web : 'path-or-url/to/my/worker/scripts/directory' + }, + fallback : { + slaveScriptUrl : 'path-or-url/to/dist/slave.js' // used for IE where you cannot pass code to a worker using a data URI + } +}); +``` + + ## License This library is published under the MIT license. See [LICENSE](https://raw.githubusercontent.com/andywer/thread.js/master/LICENSE) for details. diff --git a/src/config.js b/src/config.js index e2f0a9e7..717110c9 100644 --- a/src/config.js +++ b/src/config.js @@ -2,6 +2,9 @@ let configuration = { basepath : { node : '', web : '' + }, + fallback : { + slaveScriptUrl : '' } }; diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index e6e39c6d..8b762a68 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -46,7 +46,7 @@ export default class Worker extends EventEmitter { constructor(initialScript = null, importScripts = []) { super(); - this.worker = new window.Worker(slaveCodeDataUri); + this.initWorker(); this.worker.addEventListener('message', this.handleMessage.bind(this)); this.worker.addEventListener('error', this.handleError.bind(this)); @@ -55,6 +55,21 @@ export default class Worker extends EventEmitter { } } + initWorker() { + try { + this.worker = new window.Worker(slaveCodeDataUri); + } catch (error) { + const slaveScriptUrl = getConfig().fallback.slaveScriptUrl; + if (slaveScriptUrl) { + // try using the slave script file instead of the data URI + this.worker = new window.Worker(slaveCodeDataUri); + } else { + // re-throw + throw error; + } + } + } + run(toRun, importScripts = []) { if (typeof toRun === 'function') { this.runMethod(toRun, importScripts); From 992c71cda24a5658645d4d65945f55217e597fe0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 20:36:58 +0200 Subject: [PATCH 062/224] Prepare for npm/bower publish --- bower.json | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 00000000..39b16309 --- /dev/null +++ b/bower.json @@ -0,0 +1,11 @@ +{ + "name": "threads", + "version": "0.5.0", + "main": "dist/thread.browser.js", + "homepage": "https://github.com/andywer/threads.js", + "authors": [ + "Andy Wermke " + ], + "description": "Easy to use, yet powerful multi-threading library for node.js and the browser!", + "license": "MIT" +} diff --git a/package.json b/package.json index 4b1f1987..88544be6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.1.0", + "version": "0.5.0", "keywords": [ "thread", "web worker", From 278bf598597f4e1ffeca87e4c011253a84a1f31a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 20:59:27 +0200 Subject: [PATCH 063/224] Add ignore to bower.json --- bower.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 39b16309..98208be0 100644 --- a/bower.json +++ b/bower.json @@ -7,5 +7,9 @@ "Andy Wermke " ], "description": "Easy to use, yet powerful multi-threading library for node.js and the browser!", - "license": "MIT" + "license": "MIT", + "ignore": [ + "node_modules", + "test" + ] } From 69d7d35b57f4a61c423da45132457fd5784b9803 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:01:54 +0200 Subject: [PATCH 064/224] Update readme: Add npm version badge --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b83c3eed..26f50b3f 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # threads.js - BETA -[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) +[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) **Attention: This is an early release. Use with care and be aware that the API might still change.** From 3bb38ea942b755a72c9698ee9338ee8e5945fec6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:03:08 +0200 Subject: [PATCH 065/224] Update readme.md --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 26f50b3f..ff0d7474 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,6 @@ # threads.js - BETA -[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) +[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) +[![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) **Attention: This is an early release. Use with care and be aware that the API might still change.** From a6314632f5c24198b62134ed1da58c11a0bdc50f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:13:08 +0200 Subject: [PATCH 066/224] Rename dist files --- dist/{thread.browser.js => threads.browser.js} | 0 dist/{thread.browser.min.js => threads.browser.min.js} | 0 gulpfile.js | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename dist/{thread.browser.js => threads.browser.js} (100%) rename dist/{thread.browser.min.js => threads.browser.min.js} (100%) diff --git a/dist/thread.browser.js b/dist/threads.browser.js similarity index 100% rename from dist/thread.browser.js rename to dist/threads.browser.js diff --git a/dist/thread.browser.min.js b/dist/threads.browser.min.js similarity index 100% rename from dist/thread.browser.min.js rename to dist/threads.browser.min.js diff --git a/gulpfile.js b/gulpfile.js index 086bfbe0..44095213 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -94,14 +94,14 @@ gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], function() { .add('./lib/bundle.browser.js') .require('./lib/worker.browser/worker.js', { expose : './worker' }) // so the node worker won't make it's way into the bundle .bundle() - .pipe(source('thread.browser.js')) + .pipe(source('threads.browser.js')) .pipe(gulp.dest('dist/')); }); gulp.task('uglify-lib', ['browserify-lib'], function() { - return gulp.src('dist/thread.browser.js') + return gulp.src('dist/threads.browser.js') .pipe(uglify()) - .pipe(concat('thread.browser.min.js')) + .pipe(concat('threads.browser.min.js')) .pipe(gulp.dest('dist/')); }); From 663156139aca0b3126eac078a65a7e21e5cd6b07 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:14:14 +0200 Subject: [PATCH 067/224] Update readme: Add installation how-to --- readme.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ff0d7474..e466aea7 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,25 @@ thread ### Installation -TODO: npm, bower, script tag +#### NPM (Node.js, Browserify, Webpack) + +```bash +npm install --save threads +``` + +#### Bower + +```bash +bower install --save threads +``` + +#### Script tag + +```html + +``` + +(where `__VERSION__` is the library's version to use, like `0.5.0`) ### Thread code in separate files From 5de3543df557f3a04559e36829f1a5f0183f7b6c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:24:30 +0200 Subject: [PATCH 068/224] Update readme --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e466aea7..6e4ff51f 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) -**Attention: This is an early release. Use with care and be aware that the API might still change.** +**This is a pretty early release. Use with care and be aware that the API might still change.** Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. From e21e9d61c16bfd997f8ca9877c60905fb07529f4 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:28:38 +0200 Subject: [PATCH 069/224] Increase timeout for troublesome test case --- test/spec-src/worker.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 7362c216..d8cae78f 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -204,7 +204,7 @@ describe('Worker', () => { it('can use transferables', function(done) { // for some reason this test consumes extra-ordinarily much time when run on travis ci - this.timeout(5000); + this.timeout(6000); const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB const arrayBufferClone = new Uint8Array(1024 * 2); From 56b688b49e945aa81120a67ee555b9a1dd7e5ec4 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Sep 2015 21:42:26 +0200 Subject: [PATCH 070/224] Update readme.md --- readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.md b/readme.md index 6e4ff51f..94364e90 100644 --- a/readme.md +++ b/readme.md @@ -293,3 +293,6 @@ config.set({ ## License This library is published under the MIT license. See [LICENSE](https://raw.githubusercontent.com/andywer/thread.js/master/LICENSE) for details. + + +__Have fun and build something awesome!__ From f6eb79a96b25e6dcf6545b4c9fc26419c12c76ea Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 23 Sep 2015 09:20:07 +0200 Subject: [PATCH 071/224] Add keywords to bower.json --- bower.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bower.json b/bower.json index 98208be0..37023918 100644 --- a/bower.json +++ b/bower.json @@ -8,6 +8,16 @@ ], "description": "Easy to use, yet powerful multi-threading library for node.js and the browser!", "license": "MIT", + "keywords": [ + "thread", + "web worker", + "cluster", + "child_process", + "threadpool", + "spawn", + "fork", + "parallel" + ], "ignore": [ "node_modules", "test" From e06b4f8ba43aa933b678c0c6f111c07022e8be38 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 25 Sep 2015 00:53:49 +0200 Subject: [PATCH 072/224] Update readme --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 94364e90..d1e6c2dd 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,8 @@ when run by node.js. Also supports browsers which do not support web workers. - For client and server use - Use different APIs (web worker, node child_process) transparently - Thread pools +- Built-in error handling +- Well tested - ES6 and backwards-compatible From 1550128685edb451ba0367c5b603f15e1cf5be88 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 27 Sep 2015 16:49:38 +0200 Subject: [PATCH 073/224] Change keyword: thread => threads --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 37023918..696baec8 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "description": "Easy to use, yet powerful multi-threading library for node.js and the browser!", "license": "MIT", "keywords": [ - "thread", + "threads", "web worker", "cluster", "child_process", diff --git a/package.json b/package.json index 88544be6..18d16911 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "threads", "version": "0.5.0", "keywords": [ - "thread", + "threads", "web worker", "cluster", "child_process", From b4d88b8bd166398c084a556d5609856ad955b30b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 4 Oct 2015 17:36:35 +0200 Subject: [PATCH 074/224] Update readme.md --- readme.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/readme.md b/readme.md index d1e6c2dd..06a942d4 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,7 @@ -# threads.js - BETA +# threads.js [![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) -**This is a pretty early release. Use with care and be aware that the API might still change.** - Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. From df937f012cf89ef82d9410548fd4bc4e43a620b5 Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Wed, 14 Oct 2015 11:51:24 +0100 Subject: [PATCH 075/224] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 06a942d4..b67982ae 100644 --- a/readme.md +++ b/readme.md @@ -152,7 +152,7 @@ pool }) .on('finished', function() { console.log('Everything done, shutting down the thread pool.'); - pool.destroy(); + pool.killAll(); }); ``` From cc12f198f12758c5d580ce2a5695d1c0b7fbf6ed Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Thu, 15 Oct 2015 11:23:50 +0100 Subject: [PATCH 076/224] Update pool.js --- src/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pool.js b/src/pool.js index 16654081..58425aff 100644 --- a/src/pool.js +++ b/src/pool.js @@ -1,11 +1,12 @@ import EventEmitter from 'eventemitter3'; import Job from './job'; +import { cpus } from 'os'; import { spawn } from './'; export default class Pool extends EventEmitter { - constructor(threads = 8) { + constructor(threads) { super(); - this.threads = Pool.spawn(threads); + this.threads = Pool.spawn(threads || (cpus().length + 1)); this.idleThreads = this.threads.slice(); this.jobQueue = []; this.lastCreatedJob = null; From ea26972e7b1608c24c6589ed538a45a87083f697 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 15 Oct 2015 19:46:05 +0200 Subject: [PATCH 077/224] Implement browser & node 'defaults' module --- dist/threads.browser.js | 35 ++++++++++++++++++++++++++++------- dist/threads.browser.min.js | 2 +- gulpfile.js | 5 ++++- lib/defaults.browser.js | 12 ++++++++++++ lib/defaults.browser.js.map | 1 + lib/defaults.js | 15 +++++++++++++++ lib/defaults.js.map | 1 + lib/defaults.node.js | 13 +++++++++++++ lib/defaults.node.js.map | 1 + lib/index.js | 6 ++++++ lib/index.js.map | 2 +- lib/pool.js | 10 ++++++---- lib/pool.js.map | 2 +- src/defaults.browser.js | 7 +++++++ src/defaults.js | 12 ++++++++++++ src/defaults.node.js | 7 +++++++ src/index.js | 10 ++++++---- src/pool.js | 4 ++-- test/spec-src/pool.spec.js | 16 ++++++++++------ test/spec/pool.spec.js | 8 ++++++-- test/spec/worker.spec.js | 2 +- 21 files changed, 141 insertions(+), 30 deletions(-) create mode 100644 lib/defaults.browser.js create mode 100644 lib/defaults.browser.js.map create mode 100644 lib/defaults.js create mode 100644 lib/defaults.js.map create mode 100644 lib/defaults.node.js create mode 100644 lib/defaults.node.js.map create mode 100644 src/defaults.browser.js create mode 100644 src/defaults.js create mode 100644 src/defaults.node.js diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 2adf7e48..7164828b 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -1,4 +1,17 @@ -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;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var c=t("eventemitter3"),f=r(c),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(f["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new f["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./pool"),u=r(a),c=t("./worker"),f=r(c);n.config=s["default"],n.Pool=u["default"],n["default"]={config:s["default"],Pool:u["default"],spawn:o,Worker:f["default"]}},{"./config":2,"./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),c=r(u),f=t("./"),l=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?8:arguments[0];o(this,e),t.call(this),this.threads=e.spawn(n),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new c["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=l,l.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(f.spawn());return e},e.exports=n["default"]},{"./":3,"./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if("function"==typeof f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,n),!0;case 4:return f.fn.call(f.context,e,n,r),!0;case 5:return f.fn.call(f.context,e,n,r,o),!0;case 6:return f.fn.call(f.context,e,n,r,o,s),!0}for(c=1,u=new Array(l-1);l>c;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;p>c;c++)switch(f[c].once&&this.removeListener(t,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,e);break;case 3:f[c].fn.call(f[c].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,c=s.length;c>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),c=r(f),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(c["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),f=t("./pool"),c=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),f=r(u),c=t("./defaults"),l=r(c),h=t("./"),p=function(t){function e(n){o(this,e),t.call(this),this.threads=e.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new f["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=p,p.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(h.spawn());return e},e.exports=n["default"]},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,o),!0;case 6:return c.fn.call(c.context,e,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,e);break;case 3:c[f].fn.call(c[f].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(f){i.call(new a(u),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"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C,CAAC;GAC5B;;AA/DkB,MAAI,WAiEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,OAAO,EAAE,CAAC;;AAEf,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,cAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SAzEkB,IAAI;;;qBAAJ,IAAI;;AA4EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.lastCreatedJob = null;\n\n this.on('newJob', this.handleNewJob.bind(this));\n }\n\n run(...args) {\n return (new Job(this)).run(...args);\n }\n\n send(...args) {\n if (!this.lastCreatedJob) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n // this will not alter the last job, but rather clone it and set this params on the new job\n return this.lastCreatedJob.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/defaults.browser.js b/src/defaults.browser.js new file mode 100644 index 00000000..22e7e80c --- /dev/null +++ b/src/defaults.browser.js @@ -0,0 +1,7 @@ +/*eslint-env browser*/ + +export default { + pool : { + size : navigator.hardwareConcurrency || 8 + } +}; diff --git a/src/defaults.js b/src/defaults.js new file mode 100644 index 00000000..72f45608 --- /dev/null +++ b/src/defaults.js @@ -0,0 +1,12 @@ +/*global module, require*/ +/* + * This file is only a stub to make './defaults' resolve the './defaults.node' module. + * Loading the browser defaults into the browser bundle is done in the gulpfile by + * configuring a browserify override. + */ + +if (typeof window === 'undefined') { + module.exports = require('./defaults.node'); +} else { + module.exports = require('./defaults.browser'); +} diff --git a/src/defaults.node.js b/src/defaults.node.js new file mode 100644 index 00000000..c257f005 --- /dev/null +++ b/src/defaults.node.js @@ -0,0 +1,7 @@ +import { cpus } from 'os'; + +export default { + pool : { + size : cpus().length + } +}; diff --git a/src/index.js b/src/index.js index ee982607..8f667e2a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,11 @@ import 'native-promise-only'; -import config from './config'; -import Pool from './pool'; -import Worker from './worker'; +import config from './config'; +import defaults from './defaults'; +import Pool from './pool'; +import Worker from './worker'; -export { config, Pool }; +export { config, defaults, Pool }; export function spawn(runnable = null, importScripts = []) { return new Worker(runnable, importScripts); @@ -12,6 +13,7 @@ export function spawn(runnable = null, importScripts = []) { export default { config, + defaults, Pool, spawn, Worker diff --git a/src/pool.js b/src/pool.js index 58425aff..e4edec0e 100644 --- a/src/pool.js +++ b/src/pool.js @@ -1,12 +1,12 @@ import EventEmitter from 'eventemitter3'; import Job from './job'; -import { cpus } from 'os'; +import defaults from './defaults'; import { spawn } from './'; export default class Pool extends EventEmitter { constructor(threads) { super(); - this.threads = Pool.spawn(threads || (cpus().length + 1)); + this.threads = Pool.spawn(threads || defaults.pool.size); this.idleThreads = this.threads.slice(); this.jobQueue = []; this.lastCreatedJob = null; diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js index 7e2cf866..f51aa958 100644 --- a/test/spec-src/pool.spec.js +++ b/test/spec-src/pool.spec.js @@ -1,7 +1,7 @@ -import async from 'async'; -import expect from 'expect.js'; -import EventEmitter from 'eventemitter3'; -import { Pool } from '../../lib/'; +import async from 'async'; +import expect from 'expect.js'; +import EventEmitter from 'eventemitter3'; +import { Pool, defaults } from '../../lib/'; let spawnedFakeWorkers = 0; @@ -54,11 +54,14 @@ function doTimes(callback, times) { describe('Pool', () => { const origSpawn = Pool.spawn; + const origDefaultSize = defaults.pool.size; + const fixedDefaultSize = 3; before(() => { Pool.spawn = (threadCount) => { return doTimes(() => new FakeWorker(), threadCount); }; + defaults.pool.size = fixedDefaultSize; }); beforeEach(() => { @@ -67,15 +70,16 @@ describe('Pool', () => { after(() => { Pool.spawn = origSpawn; + defaults.pool.size = origDefaultSize; }); it('can be created (w/o arguments)', () => { const pool = new Pool(); - expect(pool.threads.length).to.equal(8); + expect(pool.threads.length).to.equal(fixedDefaultSize); expect(pool.idleThreads).to.eql(pool.threads); - expect(spawnedFakeWorkers).to.equal(8); + expect(spawnedFakeWorkers).to.equal(fixedDefaultSize); }); it('can be created with arguments', () => { diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 0b34099e..2d6ba2d7 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -92,6 +92,8 @@ function doTimes(callback, times) { describe('Pool', function () { var origSpawn = _lib.Pool.spawn; + var origDefaultSize = _lib.defaults.pool.size; + var fixedDefaultSize = 3; before(function () { _lib.Pool.spawn = function (threadCount) { @@ -99,6 +101,7 @@ describe('Pool', function () { return new FakeWorker(); }, threadCount); }; + _lib.defaults.pool.size = fixedDefaultSize; }); beforeEach(function () { @@ -107,14 +110,15 @@ describe('Pool', function () { after(function () { _lib.Pool.spawn = origSpawn; + _lib.defaults.pool.size = origDefaultSize; }); it('can be created (w/o arguments)', function () { var pool = new _lib.Pool(); - (0, _expectJs2['default'])(pool.threads.length).to.equal(8); + (0, _expectJs2['default'])(pool.threads.length).to.equal(fixedDefaultSize); (0, _expectJs2['default'])(pool.idleThreads).to.eql(pool.threads); - (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(8); + (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(fixedDefaultSize); }); it('can be created with arguments', function () { diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 831451d2..fc932963 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -198,7 +198,7 @@ describe('Worker', function () { it('can use transferables', function (done) { // for some reason this test consumes extra-ordinarily much time when run on travis ci - this.timeout(5000); + this.timeout(6000); var arrayBuffer = new Uint8Array(1024 * 2); // 2 KB var arrayBufferClone = new Uint8Array(1024 * 2); From 4a9fbdd08380fa5865c3927467edd32eed523f5b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 16 Oct 2015 09:56:39 +0200 Subject: [PATCH 078/224] Version 0.5.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 696baec8..f03ae25a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.0", + "version": "0.5.1", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index 18d16911..9db31672 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.0", + "version": "0.5.1", "keywords": [ "threads", "web worker", From 38ede2ddc562c495846a0c2da0baa5ebfe33f3c8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 17 Oct 2015 09:50:29 +0200 Subject: [PATCH 079/224] Rename readme.md => README.md --- readme.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.md => README.md (100%) diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md From 4b06f5f1eb08cb33ce322633bae4acf048b61d2c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 17 Oct 2015 10:04:57 +0200 Subject: [PATCH 080/224] Rename README.md => index.md --- README.md => index.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.md => index.md (100%) diff --git a/README.md b/index.md similarity index 100% rename from README.md rename to index.md From 5641e811fed7acb73faa3c8de04f4d8cca2228e9 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 17 Oct 2015 10:05:43 +0200 Subject: [PATCH 081/224] Revert "Rename README.md => index.md" This reverts commit 4b06f5f1eb08cb33ce322633bae4acf048b61d2c. --- index.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename index.md => README.md (100%) diff --git a/index.md b/README.md similarity index 100% rename from index.md rename to README.md From 9d5a90f21fd352920a4a4a96c9d1d0de9e5cdd41 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 17 Oct 2015 10:06:11 +0200 Subject: [PATCH 082/224] Add index.md symlink --- index.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 index.md diff --git a/index.md b/index.md new file mode 120000 index 00000000..42061c01 --- /dev/null +++ b/index.md @@ -0,0 +1 @@ +README.md \ No newline at end of file From 7267a7ced4598bd970e3965474d440779c04664c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 17 Oct 2015 10:14:29 +0200 Subject: [PATCH 083/224] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b67982ae..82bdd7bd 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,7 @@ when run by node.js. Also supports browsers which do not support web workers. - ES6 and backwards-compatible -## How To - -### Basic use +## Basic usage Spawn threads to do the time-consuming work and let the parent thread focus on daily business! @@ -47,21 +45,21 @@ thread ``` -### Installation +## Installation -#### NPM (Node.js, Browserify, Webpack) +### NPM (Node.js, Browserify, Webpack) ```bash npm install --save threads ``` -#### Bower +### Bower ```bash bower install --save threads ``` -#### Script tag +### Script tag ```html @@ -70,6 +68,8 @@ bower install --save threads (where `__VERSION__` is the library's version to use, like `0.5.0`) +## How To + ### Thread code in separate files You don't have to write the thread's code inline. The file is expected to be a From f52906dcf9394a472cc2857e96d9a7f8b2d8174e Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Wed, 21 Oct 2015 14:24:07 +0100 Subject: [PATCH 084/224] Handle throwing null values --- lib/worker.node/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index 06d8c4c4..646c0c90 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -106,7 +106,7 @@ var Worker = (function (_EventEmitter) { Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { - console.error(error.stack || error); // eslint-disable-line no-console + console.error((error && error.stack) ? error.stack : error); // eslint-disable-line no-console } this.emit('error', error); }; @@ -116,4 +116,4 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; -//# sourceMappingURL=../worker.node/worker.js.map \ No newline at end of file +//# sourceMappingURL=../worker.node/worker.js.map From c910cd5857dd86e2c7ea4b43ce62691b2de8dcc6 Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Thu, 22 Oct 2015 10:10:43 +0100 Subject: [PATCH 085/224] Compat with electron --- src/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worker.js b/src/worker.js index 0e62c774..6a9bab4e 100644 --- a/src/worker.js +++ b/src/worker.js @@ -5,7 +5,7 @@ * configuring a browserify override. */ -if (typeof window === 'undefined') { +if (typeof process !== 'undefined' && 'pid' in process) { module.exports = require('./worker.node/worker'); } else { module.exports = require('./worker.browser/worker'); From 7a695f3068965e89d0de014725f7d399b2a260c9 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 22 Oct 2015 19:41:28 +0200 Subject: [PATCH 086/224] Improve node/browser distinction + fix linting --- lib/defaults.js | 4 ++-- lib/defaults.js.map | 2 +- lib/worker.js | 4 ++-- lib/worker.js.map | 2 +- lib/worker.node/worker.js | 4 ++-- src/defaults.js | 4 ++-- src/worker.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/defaults.js b/lib/defaults.js index 1ba3d7cf..153e2f9c 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -1,4 +1,4 @@ -/*global module, require*/ +/*eslint-env node*/ /* * This file is only a stub to make './defaults' resolve the './defaults.node' module. * Loading the browser defaults into the browser bundle is done in the gulpfile by @@ -7,7 +7,7 @@ 'use strict'; -if (typeof window === 'undefined') { +if (typeof process !== 'undefined' && 'pid' in process) { module.exports = require('./defaults.node'); } else { module.exports = require('./defaults.browser'); diff --git a/lib/defaults.js.map b/lib/defaults.js.map index 6b15cdca..79534d4f 100644 --- a/lib/defaults.js.map +++ b/lib/defaults.js.map @@ -1 +1 @@ -{"version":3,"sources":["defaults.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD","file":"defaults.js","sourcesContent":["/*global module, require*/\n/*\n * This file is only a stub to make './defaults' resolve the './defaults.node' module.\n * Loading the browser defaults into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof window === 'undefined') {\n module.exports = require('./defaults.node');\n} else {\n module.exports = require('./defaults.browser');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["defaults.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD","file":"defaults.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './defaults' resolve the './defaults.node' module.\n * Loading the browser defaults into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./defaults.node');\n} else {\n module.exports = require('./defaults.browser');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.js b/lib/worker.js index 8a858f4a..7e971b17 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -1,4 +1,4 @@ -/*global module, require*/ +/*eslint-env node*/ /* * This file is only a stub to make './worker' resolve the './worker.node/worker' module. * Loading the browser worker into the browser bundle is done in the gulpfile by @@ -7,7 +7,7 @@ 'use strict'; -if (typeof window === 'undefined') { +if (typeof process !== 'undefined' && 'pid' in process) { module.exports = require('./worker.node/worker'); } else { module.exports = require('./worker.browser/worker'); diff --git a/lib/worker.js.map b/lib/worker.js.map index bcce7316..d9e00533 100644 --- a/lib/worker.js.map +++ b/lib/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*global module, require*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof window === 'undefined') {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index 646c0c90..06d8c4c4 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -106,7 +106,7 @@ var Worker = (function (_EventEmitter) { Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { - console.error((error && error.stack) ? error.stack : error); // eslint-disable-line no-console + console.error(error.stack || error); // eslint-disable-line no-console } this.emit('error', error); }; @@ -116,4 +116,4 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; -//# sourceMappingURL=../worker.node/worker.js.map +//# sourceMappingURL=../worker.node/worker.js.map \ No newline at end of file diff --git a/src/defaults.js b/src/defaults.js index 72f45608..4d6f39c9 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -1,11 +1,11 @@ -/*global module, require*/ +/*eslint-env node*/ /* * This file is only a stub to make './defaults' resolve the './defaults.node' module. * Loading the browser defaults into the browser bundle is done in the gulpfile by * configuring a browserify override. */ -if (typeof window === 'undefined') { +if (typeof process !== 'undefined' && 'pid' in process) { module.exports = require('./defaults.node'); } else { module.exports = require('./defaults.browser'); diff --git a/src/worker.js b/src/worker.js index 6a9bab4e..77eb6396 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,4 +1,4 @@ -/*global module, require*/ +/*eslint-env node*/ /* * This file is only a stub to make './worker' resolve the './worker.node/worker' module. * Loading the browser worker into the browser bundle is done in the gulpfile by From b668982655b9bc108949f8fe32c0c000f498f172 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 22 Oct 2015 19:46:07 +0200 Subject: [PATCH 087/224] Version 0.5.2 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index f03ae25a..14924d9e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.1", + "version": "0.5.2", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index 9db31672..4bddcd19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.1", + "version": "0.5.2", "keywords": [ "threads", "web worker", From dc47650ba8e2f795f8b15fc9580ca4ad8325fbf9 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 24 Oct 2015 19:37:42 +0200 Subject: [PATCH 088/224] Improve thread pool documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 82bdd7bd..ffbf5fcf 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,15 @@ module.exports = function(input, done) { You can also create a thread pool that spawns a fixed no. of workers. Pass jobs to the thread pool which it will queue and pass to the next idle worker. +You can also pass the number threads to be spawned. Defaults to the number of +CPU cores. ```javascript import { Pool } from 'threads'; // ES5 syntax: var Pool = require('threads').Pool; const pool = new Pool(); +// Alternatively: new Pool() // Run a script const jobA = pool From 5135c49b770aac0959fbea393a66602dae5e08ef Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 11:52:54 +0100 Subject: [PATCH 089/224] Add coveralls config --- .travis.yml | 2 ++ package.json | 1 + 2 files changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8d7bc81f..7881c64e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,5 @@ env: - TRAVISCI=1 before_script: - sh -e /etc/init.d/xvfb start +after_success: + - istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage diff --git a/package.json b/package.json index 4bddcd19..92b88af8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "devDependencies": { "async": "^1.4.2", "browserify": "^9.0.8", + "coveralls": "^2.11.4", "expect.js": "^0.3.1", "gulp": "^3.8.11", "gulp-babel": "^5.2.0", From 2eb2b050e80da885437cc01cf706a6ec45864637 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 11:58:30 +0100 Subject: [PATCH 090/224] Fix coveralls integration --- .travis.yml | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7881c64e..02da589b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ env: before_script: - sh -e /etc/init.d/xvfb start after_success: - - istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage + - ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage diff --git a/package.json b/package.json index 92b88af8..718d92df 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^1.2.0", + "istanbul": "^0.4.0", "karma": "^0.13.9", "karma-browserify": "^4.3.0", "karma-chrome-launcher": "^0.2.0", From cce9615f21df03ac4fc30684ae061c366bd86f22 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 12:04:37 +0100 Subject: [PATCH 091/224] Add code climate config --- .travis.yml | 4 +++- package.json | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 02da589b..64859af7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,6 @@ env: before_script: - sh -e /etc/init.d/xvfb start after_success: - - ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage + - ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js + - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js + - ./node_modules/.bin/codeclimate-test-reporter < ./coverage/lcov.info diff --git a/package.json b/package.json index 718d92df..3e528e65 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "devDependencies": { "async": "^1.4.2", "browserify": "^9.0.8", + "codeclimate-test-reporter": "^0.1.1", "coveralls": "^2.11.4", "expect.js": "^0.3.1", "gulp": "^3.8.11", From b796409ea654221a0883fed2b18e1689d151eed9 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 12:13:08 +0100 Subject: [PATCH 092/224] Add code climate config --- .codeclimate.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..e9b551bf --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,7 @@ +engines: + eslint: + enabled: true + +ratings: + paths: + - "src/**/*.js" From cd97803b2359c52282ebe17ed672619cb5825aaa Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 12:18:10 +0100 Subject: [PATCH 093/224] Fix code climate config --- .codeclimate.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index e9b551bf..c48ac1ae 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -4,4 +4,9 @@ engines: ratings: paths: - - "src/**/*.js" + - "src/**/*.js" + +exclude_paths: +- "dist/**/*" +- "lib/**/*" +- "test/**/*" From 50470f833d4a29de94036b7e7746dcd3ae428a94 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 25 Oct 2015 12:23:58 +0100 Subject: [PATCH 094/224] Update README.md Add code climate badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ffbf5fcf..2d5c12dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # threads.js [![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) +[![Test Coverage](https://codeclimate.com/github/andywer/threads.js/badges/coverage.svg)](https://codeclimate.com/github/andywer/threads.js/coverage) +[![Code Climate](https://codeclimate.com/github/andywer/threads.js/badges/gpa.svg)](https://codeclimate.com/github/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) Javascript thread library. Uses web workers when run in browsers and child processes From 3c3890ae7bd0a31450d0e7ce3045aada7509f1af Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 26 Oct 2015 22:33:29 +0100 Subject: [PATCH 095/224] Implement progress handler --- README.md | 32 ++++++++++++++++++++++++++++++-- dist/slave.js | 6 +++++- dist/slave.min.js | 2 +- dist/threads.browser.js | 8 +++++++- dist/threads.browser.min.js | 2 +- lib/worker.browser/slave-code.js | 2 +- lib/worker.browser/worker.js | 6 ++++++ lib/worker.browser/worker.js.map | 2 +- lib/worker.node/slave.js | 6 +++++- lib/worker.node/slave.js.map | 2 +- lib/worker.node/worker.js | 6 ++++++ lib/worker.node/worker.js.map | 2 +- src/worker.browser/slave.js.txt | 6 +++++- src/worker.browser/worker.js | 6 ++++++ src/worker.node/slave.js | 6 +++++- src/worker.node/worker.js | 6 ++++++ test/spec-src/worker.spec.js | 21 +++++++++++++++++++++ test/spec/worker.spec.js | 21 +++++++++++++++++++++ 18 files changed, 129 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2d5c12dc..14dfdb6f 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,6 @@ Promise.all([ }); ``` - ### Transferable objects You can also use transferable objects to improve performance when passing large @@ -260,12 +259,41 @@ thread .send(jobData, [ largeArrayBuffer.buffer ]); ``` +### Progress update + +The thread can also notify the main thread about its current progress. + +```javascript +thread + .run(function(input, done, progress) { + setTimeout(done, 1000); + setTimeout(function() { progress(25); }, 250); + setTimeout(function() { progress(50); }, 500); + setTimeout(function() { progress(75); }, 750); + }) + .send() + .on('progress', function(progress) { + console.log(`Progress: ${progress}%`); + }) + .on('done', function() { + console.log(`Done.`); + }); +``` + +Output: + +``` +Progress: 25% +Progress: 50% +Progress: 75% +Done. +``` + ### Web worker fallback You can provide a fallback if the user's browser does not support web workers. See [webworker-fallback](https://github.com/andywer/webworker-fallback). This will not have any effect if used by node.js code. - ### Use external dependencies Not yet completely implemented. diff --git a/dist/slave.js b/dist/slave.js index 403205cb..4d4d5dac 100644 --- a/dist/slave.js +++ b/dist/slave.js @@ -12,6 +12,10 @@ function handlerDone() { this.postMessage({ response : args }); } +function handlerProgress(progress) { + this.postMessage({ progress : progress }); +} + function handlerDoneTransfer() { var args = Array.prototype.slice.call(arguments); var lastArg = args.pop(); @@ -51,6 +55,6 @@ self.onmessage = function (event) { var preparedHandlerDone = handlerDone.bind(this); preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); - handler.call(this, event.data.param, preparedHandlerDone); + handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this)); } }.bind(self); diff --git a/dist/slave.min.js b/dist/slave.min.js index f1f10b8a..7268281e 100644 --- a/dist/slave.min.js +++ b/dist/slave.min.js @@ -1 +1 @@ -function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n)}}.bind(self); \ No newline at end of file +function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 7164828b..8e78d9da 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -187,12 +187,18 @@ var Worker = (function (_EventEmitter) { Worker.prototype.handleMessage = function handleMessage(event) { if (event.data.error) { this.handleError(event.data.error); + } else if (event.data.progress) { + this.handleProgress(event.data.progress); } else { var responseArgs = convertToArray(event.data.response); this.emit.apply(this, ['message'].concat(responseArgs)); } }; + Worker.prototype.handleProgress = function handleProgress(progress) { + this.emit('progress', progress); + }; + Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { logError(error); @@ -560,7 +566,7 @@ Pool.spawn = function (threadCount) { module.exports = exports['default']; //# sourceMappingURL=pool.js.map },{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":7}],6:[function(require,module,exports){ -module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"; +module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"; },{}],7:[function(require,module,exports){ 'use strict'; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 37820be4..e00cd60d 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return o(n?n:t)},c,c.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),c=r(f),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(c["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),f=t("./pool"),c=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),f=r(u),c=t("./defaults"),l=r(c),h=t("./"),p=function(t){function e(n){o(this,e),t.call(this),this.threads=e.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new f["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=p,p.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(h.spawn());return e},e.exports=n["default"]},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone);\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,o),!0;case 6:return c.fn.call(c.context,e,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,e);break;case 3:c[f].fn.call(c[f].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(f){i.call(new a(u),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),c=r(f),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(c["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),f=t("./pool"),c=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),f=r(u),c=t("./defaults"),l=r(c),h=t("./"),p=function(t){function e(n){o(this,e),t.call(this),this.threads=e.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new f["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=p,p.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(h.spawn());return e},e.exports=n["default"]},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,o),!0;case 6:return c.fn.call(c.context,e,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,e);break;case 3:c[f].fn.call(c[f].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(f){i.call(new a(u),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;yBAClB,cAAc;;;;sBAEV,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAED,IAAM,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;;AAGtF,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,Q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AAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM,EAAK;AACtC,YACG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACxB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAC1B,CAAC,CAAC;GACJ;;AA/EkB,QAAM,WAiFzB,aAAa,GAAA,uBAAC,KAAK,EAAE;AACnB,QAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;AAC9B,UAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1C,MAAM;AACL,UAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;KACvC;GACF;;AA1FkB,QAAM,WA4FzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AA9FkB,QAAM,WAgGzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SA1GkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCode from './slave-code';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\nconst slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js index 8a639e32..095f2ea7 100644 --- a/lib/worker.node/slave.js +++ b/lib/worker.node/slave.js @@ -56,6 +56,10 @@ messageHandlerDone.transfer = function () { messageHandlerDone.apply(undefined, args); }; +function messageHandlerProgress(progress) { + process.send({ progress: progress }); +} + process.on('message', function (data) { if (data.initByScript) { messageHandler = require(data.script); @@ -70,7 +74,7 @@ process.on('message', function (data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, messageHandlerDone); + messageHandler(data.param, messageHandlerDone, messageHandlerProgress); } }); //# sourceMappingURL=../worker.node/slave.js.map \ No newline at end of file diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map index 2d5090ac..bffec0f8 100644 --- a/lib/worker.node/slave.js.map +++ b/lib/worker.node/slave.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;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C;;AAGF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;GAChD;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHand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;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,kBAAI,IAAI,CAAC,CAAC;CAC7B,CAAC;;AAEF,SAAS,sBAAsB,CAAC,QAAQ,EAAE;AACxC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAR,QAAQ,EAAE,CAAC,CAAC;CAC5B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;GACxE;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\nfunction messageHandlerProgress(progress) {\n process.send({ progress });\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone, messageHandlerProgress);\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index 06d8c4c4..a2a4096b 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -99,11 +99,17 @@ var Worker = (function (_EventEmitter) { error.stack = message.error.stack; this.handleError(error); + } else if (message.progress) { + this.handleProgress(message.progress); } else { this.emit.apply(this, ['message'].concat(message.response)); } }; + Worker.prototype.handleProgress = function handleProgress(progress) { + this.emit('progress', progress); + }; + Worker.prototype.handleError = function handleError(error) { if (!this.listeners('error', true)) { console.error(error.stack || error); // eslint-disable-line no-console diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index fe0a2463..39b07ede 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,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\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAA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,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AA9EkB,QAAM,WAgFzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SArFkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index 403205cb..4d4d5dac 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -12,6 +12,10 @@ function handlerDone() { this.postMessage({ response : args }); } +function handlerProgress(progress) { + this.postMessage({ progress : progress }); +} + function handlerDoneTransfer() { var args = Array.prototype.slice.call(arguments); var lastArg = args.pop(); @@ -51,6 +55,6 @@ self.onmessage = function (event) { var preparedHandlerDone = handlerDone.bind(this); preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); - handler.call(this, event.data.param, preparedHandlerDone); + handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this)); } }.bind(self); diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 8b762a68..7475355a 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -126,12 +126,18 @@ export default class Worker extends EventEmitter { handleMessage(event) { if (event.data.error) { this.handleError(event.data.error); + } else if (event.data.progress) { + this.handleProgress(event.data.progress); } else { const responseArgs = convertToArray(event.data.response); this.emit('message', ...responseArgs); } } + handleProgress(progress) { + this.emit('progress', progress); + } + handleError(error) { if (!this.listeners('error', true)) { logError(error); diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index 72ce467e..b354c29c 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -46,6 +46,10 @@ messageHandlerDone.transfer = function(...args) { messageHandlerDone(...args); }; +function messageHandlerProgress(progress) { + process.send({ progress }); +} + process.on('message', function(data) { if (data.initByScript) { @@ -61,6 +65,6 @@ process.on('message', function(data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, messageHandlerDone); + messageHandler(data.param, messageHandlerDone, messageHandlerProgress); } }); diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index fa687952..87426fc9 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -74,11 +74,17 @@ export default class Worker extends EventEmitter { error.stack = message.error.stack; this.handleError(error); + } else if (message.progress) { + this.handleProgress(message.progress); } else { this.emit('message', ...message.response); } } + handleProgress(progress) { + this.emit('progress', progress); + } + handleError(error) { if (!this.listeners('error', true)) { console.error(error.stack || error); // eslint-disable-line no-console diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index d8cae78f..63ed387d 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -11,6 +11,12 @@ function echoThread(param, done) { done(param); } +function progressThread(param, done, progress) { + progress(0.3); + progress(0.6); + done(); +} + function canSendAndReceive(worker, dataToSend, expectToRecv, done) { worker .once('message', (data) => { @@ -162,6 +168,21 @@ describe('Worker', () => { }); }); + it('can update progress', done => { + const progressUpdates = []; + const worker = spawn(progressThread); + + worker.on('progress', progress => { + progressUpdates.push(progress); + }); + worker.send(); + + worker.on('message', () => { + expect(progressUpdates).to.eql([ 0.3, 0.6 ]); + done(); + }); + }); + if (env === 'node') { diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index fc932963..672747c9 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -26,6 +26,12 @@ function echoThread(param, done) { done(param); } +function progressThread(param, done, progress) { + progress(0.3); + progress(0.6); + done(); +} + function canSendAndReceive(worker, dataToSend, expectToRecv, done) { worker.once('message', function (data) { (0, _expectJs2['default'])(data).to.eql(expectToRecv); @@ -163,6 +169,21 @@ describe('Worker', function () { }); }); + it('can update progress', function (done) { + var progressUpdates = []; + var worker = (0, _.spawn)(progressThread); + + worker.on('progress', function (progress) { + progressUpdates.push(progress); + }); + worker.send(); + + worker.on('message', function () { + (0, _expectJs2['default'])(progressUpdates).to.eql([0.3, 0.6]); + done(); + }); + }); + if (env === 'node') { it('thread code can use setTimeout, setInterval', function (done) { From 35342ae713fd73873b0102e242f1eb8a79347dd7 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 27 Oct 2015 16:34:57 +0100 Subject: [PATCH 096/224] Version 0.5.3 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 14924d9e..072e7ee7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.2", + "version": "0.5.3", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index 3e528e65..650802eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.2", + "version": "0.5.3", "keywords": [ "threads", "web worker", From b8cd62db76fddc3ca886806490f4b6c34da7dc99 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 27 Oct 2015 16:36:33 +0100 Subject: [PATCH 097/224] Update version in ``` -(where `__VERSION__` is the library's version to use, like `0.5.0`) +(where `__VERSION__` is the library's version to use, like `0.5.3`) ## How To From 189feac7b97eb054fe79152f57b4b22fd029f3e2 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 28 Oct 2015 20:43:11 +0100 Subject: [PATCH 098/224] Update readme: Use traditional require() --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index be110dba..32662b90 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ Spawn threads to do the time-consuming work and let the parent thread focus on daily business! ```javascript -import { spawn } from 'threads'; -// ES5 syntax: var spawn = require('threads').spawn; +const spawn = require('threads').spawn; const thread = spawn(function(input, done) { // Everything we do here will be run in parallel in another execution context. @@ -79,8 +78,9 @@ commonjs module (so something that uses `module.exports = ...`), for node and browser. ```javascript -import { config, spawn } from 'threads'; -// ES5 syntax: var config = require('threads').config, spawn = require('threads').spawn; +const threads = require('threads'); +const config = threads.config; +const spawn = threads.spawn; // Set base paths to thread scripts config.set({ @@ -117,8 +117,7 @@ You can also pass the number threads to be spawned. Defaults to the number of CPU cores. ```javascript -import { Pool } from 'threads'; -// ES5 syntax: var Pool = require('threads').Pool; +const Pool = require('threads').Pool; const pool = new Pool(); // Alternatively: new Pool() @@ -307,8 +306,7 @@ To do: ## Configuration ```javascript -import { config } from 'threads'; -// ES5 syntax: var config = require('threads').config +const config = require('threads').config; // These configuration properties are all optional config.set({ From 42024998da1fb1d3dda2081bc11ab8e498ce0899 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 9 Dec 2015 11:09:07 +0100 Subject: [PATCH 099/224] Fix webpack issue --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 650802eb..91e02181 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,10 @@ "dependencies": { "eventemitter3": "^1.1.1", "native-promise-only": "^0.8.1" + }, + "browser": { + "child_process": false, + "os": false, + "path": false } } From 5b4e9b67638f58f5b362b3266c9cf3506513d8c0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 24 Dec 2015 11:50:41 +0100 Subject: [PATCH 100/224] More thoughtful data URI creation --- dist/threads.browser.js | 68 +++++++++++++++++++----- dist/threads.browser.min.js | 2 +- lib/worker.browser/slave-code-uri.js | 35 ++++++++++++ lib/worker.browser/slave-code-uri.js.map | 1 + lib/worker.browser/worker.js | 12 ++--- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/slave-code-uri.js | 25 +++++++++ src/worker.browser/worker.js | 4 +- 8 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 lib/worker.browser/slave-code-uri.js create mode 100644 lib/worker.browser/slave-code-uri.js.map create mode 100644 src/worker.browser/slave-code-uri.js diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 8e78d9da..cac660cb 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -11,6 +11,7 @@ exports["default"] = { }; module.exports = exports["default"]; //# sourceMappingURL=defaults.browser.js.map + },{}],1:[function(require,module,exports){ /*eslint-env browser, amd, commonjs*/ /*global module*/ @@ -35,6 +36,7 @@ if (typeof define === 'function') { module.exports = _index2['default']; } //# sourceMappingURL=bundle.browser.js.map + },{"./index":3}],"./worker":[function(require,module,exports){ 'use strict'; @@ -50,9 +52,9 @@ var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3); -var _slaveCode = require('./slave-code'); +var _slaveCodeUri = require('./slave-code-uri'); -var _slaveCode2 = _interopRequireDefault(_slaveCode); +var _slaveCodeUri2 = _interopRequireDefault(_slaveCodeUri); var _config = require('../config'); @@ -60,8 +62,6 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); - function prependScriptUrl(scriptUrl) { var prefix = _config.getConfig().basepath.web; return prefix ? prefix + '/' + scriptUrl : scriptUrl; @@ -112,12 +112,12 @@ var Worker = (function (_EventEmitter) { Worker.prototype.initWorker = function initWorker() { try { - this.worker = new window.Worker(slaveCodeDataUri); + this.worker = new window.Worker(_slaveCodeUri2['default']); } catch (error) { var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; if (slaveScriptUrl) { // try using the slave script file instead of the data URI - this.worker = new window.Worker(slaveCodeDataUri); + this.worker = new window.Worker(_slaveCodeUri2['default']); } else { // re-throw throw error; @@ -216,8 +216,9 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; -//# sourceMappingURL=../worker.browser/worker.js.map -},{"../config":2,"./slave-code":6,"eventemitter3":7}],2:[function(require,module,exports){ +//# sourceMappingURL=worker.js.map + +},{"../config":2,"./slave-code-uri":6,"eventemitter3":8}],2:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -278,6 +279,7 @@ function setConfig() { return config.set.apply(config, arguments); } //# sourceMappingURL=config.js.map + },{}],3:[function(require,module,exports){ 'use strict'; @@ -323,7 +325,8 @@ exports['default'] = { Worker: _worker2['default'] }; //# sourceMappingURL=index.js.map -},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(require,module,exports){ + +},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -435,7 +438,8 @@ var Job = (function (_EventEmitter) { exports['default'] = Job; module.exports = exports['default']; //# sourceMappingURL=job.js.map -},{"eventemitter3":7}],5:[function(require,module,exports){ + +},{"eventemitter3":8}],5:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -565,9 +569,47 @@ Pool.spawn = function (threadCount) { }; module.exports = exports['default']; //# sourceMappingURL=pool.js.map -},{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":7}],6:[function(require,module,exports){ + +},{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":8}],6:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _slaveCode = require('./slave-code'); + +var _slaveCode2 = _interopRequireDefault(_slaveCode); + +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); +var createBlobURL = window.createBlobURL || window.createObjectURL; + +if (!createBlobURL) { + var _URL = window.URL || window.webkitURL; + + if (_URL) { + createBlobURL = _URL.createObjectURL; + } else { + throw new Error('No Blob creation implementation found.'); + } +} + +if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') { + var blobBuilder = new window.BlobBuilder(); + blobBuilder.append(_slaveCode2['default']); + slaveCodeDataUri = createBlobURL(blobBuilder.getBlob()); +} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') { + var blob = new window.Blob([_slaveCode2['default']], { type: 'text/javascript' }); + slaveCodeDataUri = createBlobURL(blob); +} + +exports['default'] = slaveCodeDataUri; +module.exports = exports['default']; +//# sourceMappingURL=slave-code-uri.js.map + +},{"./slave-code":7}],7:[function(require,module,exports){ module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ 'use strict'; // @@ -831,7 +873,7 @@ if ('undefined' !== typeof module) { module.exports = EventEmitter; } -},{}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ (function (global){ /*! Native Promise Only v0.8.1 (c) Kyle Simpson diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index e00cd60d..dcd07856 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return o(n?n:t)},c,c.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),c=r(f),l=t("./slave-code"),h=r(l),p=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d="data:text/javascript;charset=utf-8,"+encodeURI(h["default"]),y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(d)}catch(t){var e=p.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(d)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(s)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(s)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=a(t.data.response);this.emit.apply(this,["message"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||u(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(c["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code":6,eventemitter3:7}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),f=t("./pool"),c=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":8}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Cannot call .run() without arguments.");return this.runArgs=e,this},e.prototype.send=function(){if(0===this.runArgs.length)throw new Error("Cannot .send() before .run().");for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,e)}return this.sendArgs=e,this.parameterSet=!0,this.emit("readyToRun"),this},e.prototype.executeOn=function(t){var e,n;return(e=(n=t.once("message",this.emit.bind(this,"done")).once("error",this.emit.bind(this,"error"))).run.apply(n,this.runArgs)).send.apply(e,this.sendArgs),this.thread=t,this},e.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},e.prototype.clone=function n(){var n=new e(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},e.prototype.hasSendParameter=function(){return this.parameterSet},e.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},e}(a["default"]);n["default"]=u,e.exports=n["default"]},{eventemitter3:7}],5:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=t("./job"),f=r(u),c=t("./defaults"),l=r(c),h=t("./"),p=function(t){function e(n){o(this,e),t.call(this),this.threads=e.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(e,t),e.prototype.run=function(){var t;return(t=new f["default"](this)).run.apply(t,arguments)},e.prototype.send=function(){var t;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(t=this.lastCreatedJob).send.apply(t,arguments)},e.prototype.killAll=function(){this.threads.forEach(function(t){t.kill()})},e.prototype.queueJob=function(t){this.jobQueue.push(t),this.dequeue()},e.prototype.dequeue=function(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var t=this.jobQueue.shift(),e=this.idleThreads.shift();t.on("done",this.handleJobSuccess.bind(this,e,t)).on("error",this.handleJobError.bind(this,e,t)),t.executeOn(e)}},e.prototype.handleNewJob=function(t){this.lastCreatedJob=t,t.on("readyToRun",this.queueJob.bind(this,t))},e.prototype.handleJobSuccess=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",e].concat(r)),this.handleJobDone(t)},e.prototype.handleJobError=function(t,e,n){this.emit("error",e,n),this.handleJobDone(t)},e.prototype.handleJobDone=function(t){var e=this;this.idleThreads.push(t),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){e.emit("finished")},0)},e}(a["default"]);n["default"]=p,p.spawn=function(t){for(var e=[],n=0;t>n;n++)e.push(h.spawn());return e},e.exports=n["default"]},{"./":3,"./defaults":"./defaults","./job":4,eventemitter3:7}],6:[function(t,e,n){e.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],7:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=i?i+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(t,e,n,r,o,s){var a=i?i+t:t;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,r),!0;case 5:return c.fn.call(c.context,e,n,r,o),!0;case 6:return c.fn.call(c.context,e,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,e);break;case 3:c[f].fn.call(c[f].context,e,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new r(e,n||this),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new r(e,n||this,!0),s=i?i+t:t;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,r){var o=i?i+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(e)if(s.fn)(s.fn!==e||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==e||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[i?i+t:t]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof e&&(e.exports=o)},{}],8:[function(t,e,n){(function(t){!function(t,n,r){n[t]=n[t]||r(),"undefined"!=typeof e&&e.exports?e.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof t?t:this,function(){"use strict";function t(t,e){h.add(t,e),l||(l=d(h.drain))}function e(t){var e,n=typeof t;return null==t||"object"!=n&&"function"!=n||(e=t.then),"function"==typeof e?e:!1}function n(){for(var t=0;t0&&t(n,u))}catch(f){i.call(new a(u),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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},t.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAA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GkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/slave-code-uri.js b/src/worker.browser/slave-code-uri.js new file mode 100644 index 00000000..135594b7 --- /dev/null +++ b/src/worker.browser/slave-code-uri.js @@ -0,0 +1,25 @@ +import slaveCode from './slave-code'; + +let slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode); +let createBlobURL = window.createBlobURL || window.createObjectURL; + +if (!createBlobURL) { + const URL = window.URL || window.webkitURL; + + if (URL) { + createBlobURL = URL.createObjectURL; + } else { + throw new Error('No Blob creation implementation found.'); + } +} + +if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') { + const blobBuilder = new window.BlobBuilder(); + blobBuilder.append(slaveCode); + slaveCodeDataUri = createBlobURL(blobBuilder.getBlob()); +} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') { + const blob = new window.Blob([ slaveCode ], { type: 'text/javascript' }); + slaveCodeDataUri = createBlobURL(blob); +} + +export default slaveCodeDataUri; diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 7475355a..b3188f12 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -1,5 +1,5 @@ import EventEmitter from 'eventemitter3'; -import slaveCode from './slave-code'; +import slaveCodeDataUri from './slave-code-uri'; import { getConfig } from '../config'; @@ -8,8 +8,6 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } -const slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode); - function prependScriptUrl(scriptUrl) { const prefix = getConfig().basepath.web; From 01c3b6a7f95b35b53f60a03cb61c76af4e7ed7e2 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 27 Jan 2016 12:19:18 +0100 Subject: [PATCH 101/224] Very minor differences in babel output --- lib/bundle.browser.js | 2 +- lib/config.js | 2 +- lib/defaults.browser.js | 2 +- lib/defaults.js | 2 +- lib/defaults.node.js | 2 +- lib/index.js | 2 +- lib/job.js | 2 +- lib/pool.js | 2 +- lib/worker.js | 2 +- lib/worker.node/slave.js | 2 +- lib/worker.node/worker.js | 2 +- test/spec/pool.spec.js | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/bundle.browser.js b/lib/bundle.browser.js index 533fdcd4..ebb54a6c 100644 --- a/lib/bundle.browser.js +++ b/lib/bundle.browser.js @@ -20,4 +20,4 @@ if (typeof define === 'function') { } else if (typeof module === 'object') { module.exports = _index2['default']; } -//# sourceMappingURL=bundle.browser.js.map \ No newline at end of file +//# sourceMappingURL=bundle.browser.js.map diff --git a/lib/config.js b/lib/config.js index 4db53b38..69c58e7d 100644 --- a/lib/config.js +++ b/lib/config.js @@ -57,4 +57,4 @@ function getConfig() { function setConfig() { return config.set.apply(config, arguments); } -//# sourceMappingURL=config.js.map \ No newline at end of file +//# sourceMappingURL=config.js.map diff --git a/lib/defaults.browser.js b/lib/defaults.browser.js index 2e6c340e..6449ef8e 100644 --- a/lib/defaults.browser.js +++ b/lib/defaults.browser.js @@ -9,4 +9,4 @@ exports["default"] = { } }; module.exports = exports["default"]; -//# sourceMappingURL=defaults.browser.js.map \ No newline at end of file +//# sourceMappingURL=defaults.browser.js.map diff --git a/lib/defaults.js b/lib/defaults.js index 153e2f9c..b46d4890 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -12,4 +12,4 @@ if (typeof process !== 'undefined' && 'pid' in process) { } else { module.exports = require('./defaults.browser'); } -//# sourceMappingURL=defaults.js.map \ No newline at end of file +//# sourceMappingURL=defaults.js.map diff --git a/lib/defaults.node.js b/lib/defaults.node.js index 09646a79..3cecd468 100644 --- a/lib/defaults.node.js +++ b/lib/defaults.node.js @@ -10,4 +10,4 @@ exports['default'] = { } }; module.exports = exports['default']; -//# sourceMappingURL=defaults.node.js.map \ No newline at end of file +//# sourceMappingURL=defaults.node.js.map diff --git a/lib/index.js b/lib/index.js index 868da514..8c4558c2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -41,4 +41,4 @@ exports['default'] = { spawn: spawn, Worker: _worker2['default'] }; -//# sourceMappingURL=index.js.map \ No newline at end of file +//# sourceMappingURL=index.js.map diff --git a/lib/job.js b/lib/job.js index c589ea07..a8300786 100644 --- a/lib/job.js +++ b/lib/job.js @@ -108,4 +108,4 @@ var Job = (function (_EventEmitter) { exports['default'] = Job; module.exports = exports['default']; -//# sourceMappingURL=job.js.map \ No newline at end of file +//# sourceMappingURL=job.js.map diff --git a/lib/pool.js b/lib/pool.js index fffc2f5d..3a3a2883 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -126,4 +126,4 @@ Pool.spawn = function (threadCount) { return threads; }; module.exports = exports['default']; -//# sourceMappingURL=pool.js.map \ No newline at end of file +//# sourceMappingURL=pool.js.map diff --git a/lib/worker.js b/lib/worker.js index 7e971b17..795c88c0 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -12,4 +12,4 @@ if (typeof process !== 'undefined' && 'pid' in process) { } else { module.exports = require('./worker.browser/worker'); } -//# sourceMappingURL=worker.js.map \ No newline at end of file +//# sourceMappingURL=worker.js.map diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js index 095f2ea7..4db936e1 100644 --- a/lib/worker.node/slave.js +++ b/lib/worker.node/slave.js @@ -77,4 +77,4 @@ process.on('message', function (data) { messageHandler(data.param, messageHandlerDone, messageHandlerProgress); } }); -//# sourceMappingURL=../worker.node/slave.js.map \ No newline at end of file +//# sourceMappingURL=slave.js.map diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index a2a4096b..d64c06a0 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -122,4 +122,4 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; -//# sourceMappingURL=../worker.node/worker.js.map \ No newline at end of file +//# sourceMappingURL=worker.js.map diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 2d6ba2d7..9f1cbb32 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -2,7 +2,7 @@ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } From 23ae0ec89def21085eb29ec1baebddec4cf35b56 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 27 Jan 2016 12:54:53 +0100 Subject: [PATCH 102/224] Make job return a promise, even if thread is not set yet --- dist/threads.browser.js | 33 +++++++++++++++++++++++++++++---- dist/threads.browser.min.js | 2 +- lib/job.js | 33 +++++++++++++++++++++++++++++---- lib/job.js.map | 2 +- src/job.js | 29 +++++++++++++++++++++++++---- test/spec-src/job.spec.js | 31 ++++++++++++++++++++----------- test/spec-src/pool.spec.js | 8 ++++++++ test/spec/job.spec.js | 27 +++++++++++++++++---------- test/spec/pool.spec.js | 9 +++++++++ 9 files changed, 139 insertions(+), 35 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index cac660cb..8dbb8650 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -345,12 +345,21 @@ var Job = (function (_EventEmitter) { _inherits(Job, _EventEmitter); function Job(pool) { + var _this = this; + _classCallCheck(this, Job); _EventEmitter.call(this); this.pool = pool; this.thread = null; + this.promiseBoundToThread = false; + this.promiseControlMethods = {}; + this.jobPromise = new Promise(function (resolve, reject) { + _this.promiseControlMethods.resolve = resolve; + _this.promiseControlMethods.reject = reject; + }); + this.runArgs = []; this.clearSendParameter(); @@ -398,15 +407,31 @@ var Job = (function (_EventEmitter) { (_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); + if (!this.promiseBoundToThread) { + this.bindPromiseTo(thread.promise()); + } + this.thread = thread; return this; }; + Job.prototype.bindPromiseTo = function bindPromiseTo(anotherPromise) { + var _this2 = this; + + anotherPromise.then(function (result) { + _this2.promiseControlMethods.resolve(result); + return result; + })['catch'](function () { + var _promiseControlMethods; + + (_promiseControlMethods = _this2.promiseControlMethods).reject.apply(_promiseControlMethods, arguments); + }); + + this.promiseBoundToThread = true; + }; + Job.prototype.promise = function promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); + return this.jobPromise; }; Job.prototype.clone = function clone() { diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index dcd07856..4660d5f2 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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},t.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){var r=this;o(this,t),e.call(this),this.pool=n,this.thread=null,this.promiseBoundToThread=!1,this.promiseControlMethods={},this.jobPromise=new Promise(function(e,t){r.promiseControlMethods.resolve=e,r.promiseControlMethods.reject=t}),this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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.promiseBoundToThread||this.bindPromiseTo(e.promise()),this.thread=e,this},t.prototype.bindPromiseTo=function(e){var t=this;e.then(function(e){return t.promiseControlMethods.resolve(e),e})["catch"](function(){var e;(e=t.promiseControlMethods).reject.apply(e,arguments)}),this.promiseBoundToThread=!0},t.prototype.promise=function(){return this.jobPromise},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;;;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,Q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,KAAK,EAAQ,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;AACD,QAAI,IAAI,CAAC,YAAY,EAAE;AACrB,WAAK,CAAC,IAAI,MAAA,CAAV,KAAK,EAAS,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;;AAED,WAAO,KAAK,CAAC;GACd;;AAxFkB,KAAG,WA0FtB,gBAAgB,GAAA,4BAAG;AACjB,WAAO,IAAI,CAAC,YAAY,CAAC;GAC1B;;AA5FkB,KAAG,WA8FtB,kBAAkB,GAAA,8BAAG;AACnB,QAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,WAAO,IAAI,CAAC;GACb;;SAlGkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.promiseBoundToThread = false;\n this.promiseControlMethods = {};\n this.jobPromise = new Promise((resolve, reject) => {\n this.promiseControlMethods.resolve = resolve;\n this.promiseControlMethods.reject = reject;\n });\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n if (!this.promiseBoundToThread) {\n this.bindPromiseTo(thread.promise());\n }\n\n this.thread = thread;\n return this;\n }\n\n bindPromiseTo(anotherPromise) {\n anotherPromise\n .then(result => {\n this.promiseControlMethods.resolve(result);\n return result;\n })\n .catch((...errors) => {\n this.promiseControlMethods.reject(...errors);\n });\n\n this.promiseBoundToThread = true;\n }\n\n promise() {\n return this.jobPromise;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/job.js b/src/job.js index aa490fe4..0a03d5f0 100644 --- a/src/job.js +++ b/src/job.js @@ -7,6 +7,13 @@ export default class Job extends EventEmitter { this.pool = pool; this.thread = null; + this.promiseBoundToThread = false; + this.promiseControlMethods = {}; + this.jobPromise = new Promise((resolve, reject) => { + this.promiseControlMethods.resolve = resolve; + this.promiseControlMethods.reject = reject; + }); + this.runArgs = []; this.clearSendParameter(); @@ -46,15 +53,29 @@ export default class Job extends EventEmitter { .run(...this.runArgs) .send(...this.sendArgs); + if (!this.promiseBoundToThread) { + this.bindPromiseTo(thread.promise()); + } + this.thread = thread; return this; } + bindPromiseTo(anotherPromise) { + anotherPromise + .then(result => { + this.promiseControlMethods.resolve(result); + return result; + }) + .catch((...errors) => { + this.promiseControlMethods.reject(...errors); + }); + + this.promiseBoundToThread = true; + } + promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); + return this.jobPromise; } clone() { diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index bfac9ed2..58a1c3a8 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -4,17 +4,23 @@ import EventEmitter from 'eventemitter3'; import Job from '../../lib/job'; -const fakeThreadPromise = new Promise(() => {}); - function noop() { return this; } +function createThreadPromise() { + return new Promise((resolve, reject) => { + this + .once('message', resolve) + .once('error', reject); + }); +} + function createFakeThread(response) { const thread = new EventEmitter(); thread.run = noop; - thread.promise = () => fakeThreadPromise; + thread.promise = createThreadPromise; if (response.error) { thread.send = function() { @@ -74,9 +80,10 @@ describe('Job', () => { it('can be executed', () => { const thread = { - once : noop, - run : noop, - send : noop + once : noop, + run : noop, + send : noop, + promise : createThreadPromise }; const mock = sinon.mock(thread); @@ -198,21 +205,23 @@ describe('Job', () => { const promise = job .run(noop) - .send() - .executeOn(thread) .promise(); - expect(promise).to.equal(fakeThreadPromise); + job + .send() + .executeOn(thread); + + expect(promise).to.be.a(Promise); }); - it('prevents promise without .executeOn()', () => { + it('returns a promise without .executeOn()', () => { const job = new Job(pool); job .run(noop) .send(); - expect(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + expect(job.promise()).to.be.a(Promise); }); }); diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js index f51aa958..c2539907 100644 --- a/test/spec-src/pool.spec.js +++ b/test/spec-src/pool.spec.js @@ -36,6 +36,14 @@ class FakeWorker extends EventEmitter { this.emit('exit'); return this; } + + promise() { + return new Promise((resolve, reject) => { + this + .once('message', resolve) + .once('error', reject); + }); + } } function noop() { return this; } diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 76e63835..67f4ec75 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -20,19 +20,23 @@ var _libJob = require('../../lib/job'); var _libJob2 = _interopRequireDefault(_libJob); -var fakeThreadPromise = new Promise(function () {}); - function noop() { return this; } +function createThreadPromise() { + var _this = this; + + return new Promise(function (resolve, reject) { + _this.once('message', resolve).once('error', reject); + }); +} + function createFakeThread(response) { var thread = new _eventemitter32['default'](); thread.run = noop; - thread.promise = function () { - return fakeThreadPromise; - }; + thread.promise = createThreadPromise; if (response.error) { thread.send = function () { @@ -98,7 +102,8 @@ describe('Job', function () { var thread = { once: noop, run: noop, - send: noop + send: noop, + promise: createThreadPromise }; var mock = _sinon2['default'].mock(thread); @@ -205,16 +210,18 @@ describe('Job', function () { response: ['foo bar'] }); - var promise = job.run(noop).send().executeOn(thread).promise(); + var promise = job.run(noop).promise(); + + job.send().executeOn(thread); - (0, _expectJs2['default'])(promise).to.equal(fakeThreadPromise); + (0, _expectJs2['default'])(promise).to.be.a(Promise); }); - it('prevents promise without .executeOn()', function () { + it('returns a promise without .executeOn()', function () { var job = new _libJob2['default'](pool); job.run(noop).send(); - (0, _expectJs2['default'])(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + (0, _expectJs2['default'])(job.promise()).to.be.a(Promise); }); }); \ No newline at end of file diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 9f1cbb32..67c83f57 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -70,6 +70,15 @@ var FakeWorker = (function (_EventEmitter) { this.emit('exit'); return this; } + }, { + key: 'promise', + value: function promise() { + var _this2 = this; + + return new Promise(function (resolve, reject) { + _this2.once('message', resolve).once('error', reject); + }); + } }]); return FakeWorker; From aed40e17bea9348ab18dc8d68774a8df5c43f9b0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 29 Feb 2016 19:59:58 +0100 Subject: [PATCH 103/224] Version 0.5.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91e02181..f8a4aee7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.3", + "version": "0.5.4", "keywords": [ "threads", "web worker", From 61284affc275bb9269102bba17afa14d93dccec8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 29 Feb 2016 20:06:18 +0100 Subject: [PATCH 104/224] Bower version 0.5.4 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 072e7ee7..01438ddd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.3", + "version": "0.5.4", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ From a45ac85078084805b760522adf03ff1f4412570e Mon Sep 17 00:00:00 2001 From: Alexander Mays Date: Sat, 19 Mar 2016 16:18:34 -0400 Subject: [PATCH 105/224] Fixed the pool promise issues and the race conditions with Jobs/Pools. Jobs no longer 'clone', they're created as needed by the Pool. Signed-off-by: Alexander Mays --- .gitignore | 1 + dist/slave.min.js | 2 +- dist/threads.browser.js | 77 ++++++++++----------------- dist/threads.browser.min.js | 2 +- lib/job.js | 52 ++++++------------ lib/job.js.map | 2 +- lib/pool.js | 27 +++++----- lib/pool.js.map | 2 +- src/job.js | 48 +++++------------ src/pool.js | 26 +++++---- test/spec-src/job.spec.js | 29 ++++++---- test/spec-src/pool-functional.spec.js | 37 +++++++++++++ test/spec/job.spec.js | 27 ++++++---- test/spec/pool-functional.spec.js | 42 +++++++++++++++ 14 files changed, 206 insertions(+), 168 deletions(-) create mode 100644 test/spec-src/pool-functional.spec.js create mode 100644 test/spec/pool-functional.spec.js diff --git a/.gitignore b/.gitignore index 3c3629e6..5171c540 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +npm-debug.log \ No newline at end of file diff --git a/dist/slave.min.js b/dist/slave.min.js index 7268281e..048865a0 100644 --- a/dist/slave.min.js +++ b/dist/slave.min.js @@ -1 +1 @@ -function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file +function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var o=r.data.method;this.module.exports=Function.apply(null,o.args.concat(o.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var t=this.module.exports;if("function"!=typeof t)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),t.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file diff --git a/dist/threads.browser.js b/dist/threads.browser.js index cac660cb..59888685 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -352,7 +352,7 @@ var Job = (function (_EventEmitter) { this.thread = null; this.runArgs = []; - this.clearSendParameter(); + this.sendArgs = []; pool.emit('newJob', this); } @@ -379,15 +379,7 @@ var Job = (function (_EventEmitter) { args[_key2] = arguments[_key2]; } - if (this.hasSendParameter()) { - var _clone$clearSendParameter; - - // do not alter this job, clone it and set send param instead - return (_clone$clearSendParameter = this.clone().clearSendParameter()).send.apply(_clone$clearSendParameter, args); - } - this.sendArgs = args; - this.parameterSet = true; this.emit('readyToRun'); return this; @@ -399,37 +391,25 @@ var Job = (function (_EventEmitter) { (_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); this.thread = thread; + + this.emit('threadChanged'); return this; }; Job.prototype.promise = function promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); - }; - - Job.prototype.clone = function clone() { - var clone = new Job(this.pool); - - if (this.runArgs.length > 0) { - clone.run.apply(clone, this.runArgs); - } - if (this.parameterSet) { - clone.send.apply(clone, this.sendArgs); - } - - return clone; - }; - - Job.prototype.hasSendParameter = function hasSendParameter() { - return this.parameterSet; - }; + var _this = this; - Job.prototype.clearSendParameter = function clearSendParameter() { - this.parameterSet = false; - this.sendArgs = []; - return this; + // Always return a promise + return new Promise(function (resolve) { + // If the thread isn't set, listen for the threadChanged event + if (!_this.thread) { + _this.once('threadChanged', function () { + resolve(_this.thread.promise()); + }); + } else { + resolve(_this.thread.promise()); + } + }); }; return Job; @@ -474,26 +454,25 @@ var Pool = (function (_EventEmitter) { this.threads = Pool.spawn(threads || _defaults2['default'].pool.size); this.idleThreads = this.threads.slice(); this.jobQueue = []; - this.lastCreatedJob = null; + this.runArgs = []; + this.jobHistory = []; this.on('newJob', this.handleNewJob.bind(this)); } - Pool.prototype.run = function run() { - var _ref; - - return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + Pool.prototype.run = function run(args) { + this.runArgs = args; + return this; }; Pool.prototype.send = function send() { - var _lastCreatedJob; - - if (!this.lastCreatedJob) { + if (!this.runArgs) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - // this will not alter the last job, but rather clone it and set this params on the new job - return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + var job = new _job2['default'](this); + job.run(this.runArgs); + return job.send.apply(job, arguments); }; Pool.prototype.killAll = function killAll() { @@ -509,20 +488,20 @@ var Pool = (function (_EventEmitter) { Pool.prototype.dequeue = function dequeue() { if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; + return this.once('threadAvailable', this.dequeue); } var job = this.jobQueue.shift(); var thread = this.idleThreads.shift(); - job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + job.once('done', this.handleJobSuccess.bind(this, thread, job)).once('error', this.handleJobError.bind(this, thread, job)); job.executeOn(thread); }; Pool.prototype.handleNewJob = function handleNewJob(job) { this.lastCreatedJob = job; - job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() }; Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { @@ -543,7 +522,7 @@ var Pool = (function (_EventEmitter) { var _this = this; this.idleThreads.push(thread); - this.dequeue(); + this.emit('threadAvailable'); if (this.idleThreads.length === this.threads.length) { // run deferred to give other job.on('done') handlers time to run first diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index dcd07856..58f3705a 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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},t.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var u=e("eventemitter3"),c=r(u),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].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}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),f=r(a),u=e("./pool"),c=r(u),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=f["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:f["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),f=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=f,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),f=e("./job"),u=r(f),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.jobHistory=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new u["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=window.URL||window.webkitURL;if(!f)throw new Error("No Blob creation implementation found.");a=f.createObjectURL}if("function"==typeof window.BlobBuilder&&"function"==typeof a){var u=new window.BlobBuilder;u.append(i["default"]),s=a(u.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var f,u,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(u=1,f=new Array(l-1);l>u;u++)f[u-1]=arguments[u];c.fn.apply(c.context,f)}else{var h,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;default:if(!f)for(h=1,f=new Array(l-1);l>h;h++)f[h-1]=arguments[h];c[u].fn.apply(c[u].context,f)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var f=0,u=s.length;u>f;f++)(s[f].fn!==t||r&&!s[f].once||n&&s[f].context!==n)&&a.push(s[f]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,f))}catch(u){i.call(new a(f),u)}}}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 0) { - clone.run.apply(clone, this.runArgs); - } - if (this.parameterSet) { - clone.send.apply(clone, this.sendArgs); - } - - return clone; - }; - - Job.prototype.hasSendParameter = function hasSendParameter() { - return this.parameterSet; - }; - - Job.prototype.clearSendParameter = function clearSendParameter() { - this.parameterSet = false; - this.sendArgs = []; - return this; + var _this = this; + + // Always return a promise + return new Promise(function (resolve) { + // If the thread isn't set, listen for the threadChanged event + if (!_this.thread) { + _this.once('threadChanged', function () { + resolve(_this.thread.promise()); + }); + } else { + resolve(_this.thread.promise()); + } + }); }; return Job; diff --git a/lib/job.js.map b/lib/job.js.map index 60c4e0df..faa2c091 100644 --- a/lib/job.js.map +++ b/lib/job.js.map @@ -1 +1 @@ -{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,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;GACb;;AA/CkB,KAAG,WAiDtB,OAAO,GAAA,mBAAG;AACR,QAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAChB,YAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;AACD,WAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;GAC9B;;AAtDkB,KAAG,WAwDtB,KAAK,GAAA,iBAAG;AACN,QAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;AAEjC,QAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,WAAK,CAAC,GAAG,MAAA,CAAT,KAAK,EAAQ,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;AACD,QAAI,IAAI,CAAC,YAAY,EAAE;AACrB,WAAK,CAAC,IAAI,MAAA,CAAV,KAAK,EAAS,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;;AAED,WAAO,KAAK,CAAC;GACd;;AAnEkB,KAAG,WAqEtB,gBAAgB,GAAA,4BAAG;AACjB,WAAO,IAAI,CAAC,YAAY,CAAC;GAC1B;;AAvEkB,KAAG,WAyEtB,kBAAkB,GAAA,8BAAG;AACnB,QAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,WAAO,IAAI,CAAC;GACb;;SA7EkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n return this;\n }\n\n promise() {\n if (!this.thread) {\n throw new Error('Cannot return promise, since job is not executed.');\n }\n return this.thread.promise();\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;;AAEnB,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;AAVkB,KAAG,WAYtB,GAAG,GAAA,eAAU;sCAAN,IAAI;AAAJ,UAAI;;;AACT,QAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,YAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;KAC1D;;AAED,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAnBkB,KAAG,WAqBtB,IAAI,GAAA,gB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{\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.sendArgs = [];\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n this.sendArgs = args;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n\n this.emit('threadChanged');\n return this;\n }\n\n promise() {\n // Always return a promise\n return new Promise((resolve) => {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js index 3a3a2883..6698e545 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -32,26 +32,25 @@ var Pool = (function (_EventEmitter) { this.threads = Pool.spawn(threads || _defaults2['default'].pool.size); this.idleThreads = this.threads.slice(); this.jobQueue = []; - this.lastCreatedJob = null; + this.runArgs = []; + this.jobHistory = []; this.on('newJob', this.handleNewJob.bind(this)); } - Pool.prototype.run = function run() { - var _ref; - - return (_ref = new _job2['default'](this)).run.apply(_ref, arguments); + Pool.prototype.run = function run(args) { + this.runArgs = args; + return this; }; Pool.prototype.send = function send() { - var _lastCreatedJob; - - if (!this.lastCreatedJob) { + if (!this.runArgs) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - // this will not alter the last job, but rather clone it and set this params on the new job - return (_lastCreatedJob = this.lastCreatedJob).send.apply(_lastCreatedJob, arguments); + var job = new _job2['default'](this); + job.run(this.runArgs); + return job.send.apply(job, arguments); }; Pool.prototype.killAll = function killAll() { @@ -67,20 +66,20 @@ var Pool = (function (_EventEmitter) { Pool.prototype.dequeue = function dequeue() { if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; + return this.once('threadAvailable', this.dequeue); } var job = this.jobQueue.shift(); var thread = this.idleThreads.shift(); - job.on('done', this.handleJobSuccess.bind(this, thread, job)).on('error', this.handleJobError.bind(this, thread, job)); + job.once('done', this.handleJobSuccess.bind(this, thread, job)).once('error', this.handleJobError.bind(this, thread, job)); job.executeOn(thread); }; Pool.prototype.handleNewJob = function handleNewJob(job) { this.lastCreatedJob = job; - job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() }; Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { @@ -101,7 +100,7 @@ var Pool = (function (_EventEmitter) { var _this = this; this.idleThreads.push(thread); - this.dequeue(); + this.emit('threadAvailable'); if (this.idleThreads.length === this.threads.length) { // run deferred to give other job.on('done') handlers time to run first diff --git a/lib/pool.js.map b/lib/pool.js.map index 3e79227f..34f418e6 100644 --- a/lib/pool.js.map +++ b/lib/pool.js.map @@ -1 +1 @@ -{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,sBAAS,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,cAAc,GAAG,IAAI,CAAC;;AAE3B,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI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AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.lastCreatedJob = null;\n\n this.on('newJob', this.handleNewJob.bind(this));\n }\n\n run(...args) {\n return (new Job(this)).run(...args);\n }\n\n send(...args) {\n if (!this.lastCreatedJob) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n // this will not alter the last job, but rather clone it and set this params on the new job\n return this.lastCreatedJob.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .on('done', this.handleJobSuccess.bind(this, thread, job))\n .on('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.dequeue();\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,sBAAS,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,UAAU,GAAG,EAAE,CAAC;;AAErB,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;GAEjD;;AAXkB,MAAI,WAavB,GAAG,GAAA,aAAC,IAAI,EAAE;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAhBkB,MAAI,WAkBvB,IAAI,GAAA,gBAAU;AACZ,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;KACvG;;AAED,QAAI,GAAG,GAAG,qBAAQ,IAAI,CAAC,CAAC;AACxB,OAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtB,WAAO,GAAG,CAAC,IAAI,MAAA,CAAR,GAAG,YAAc,CAAC;GAC1B;;AA1BkB,MAAI,WA4BvB,OAAO,GAAA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AAG,EAAmB;sCAAd,YAAY;AAAZ,kBAAY;;;AAC3C,QAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,EAAE,GAAG,SAAK,YAAY,EAAC,CAAC;AACxC,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AA9DkB,MAAI,WAgEvB,cAAc,GAAA,wBAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE;AACjC,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAnEkB,MAAI,WAqEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,cAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA7EkB,IAAI;;;qBAAJ,IAAI;;AAgFzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n this.jobHistory = [];\n\n this.on('newJob', this.handleNewJob.bind(this));\n\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return this.once('threadAvailable', this.dequeue);\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', this.handleJobSuccess.bind(this, thread, job))\n .once('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/job.js b/src/job.js index aa490fe4..c407b2d9 100644 --- a/src/job.js +++ b/src/job.js @@ -8,7 +8,7 @@ export default class Job extends EventEmitter { this.thread = null; this.runArgs = []; - this.clearSendParameter(); + this.sendArgs = []; pool.emit('newJob', this); } @@ -27,13 +27,7 @@ export default class Job extends EventEmitter { throw new Error('Cannot .send() before .run().'); } - if (this.hasSendParameter()) { - // do not alter this job, clone it and set send param instead - return this.clone().clearSendParameter().send(...args); - } - this.sendArgs = args; - this.parameterSet = true; this.emit('readyToRun'); return this; @@ -47,36 +41,22 @@ export default class Job extends EventEmitter { .send(...this.sendArgs); this.thread = thread; + + this.emit('threadChanged'); return this; } promise() { - if (!this.thread) { - throw new Error('Cannot return promise, since job is not executed.'); - } - return this.thread.promise(); - } - - clone() { - const clone = new Job(this.pool); - - if (this.runArgs.length > 0) { - clone.run(...this.runArgs); - } - if (this.parameterSet) { - clone.send(...this.sendArgs); - } - - return clone; - } - - hasSendParameter() { - return this.parameterSet; - } - - clearSendParameter() { - this.parameterSet = false; - this.sendArgs = []; - return this; + // Always return a promise + return new Promise((resolve) => { + // If the thread isn't set, listen for the threadChanged event + if (!this.thread) { + this.once('threadChanged', () => { + resolve(this.thread.promise()); + }); + } else { + resolve(this.thread.promise()); + } + }); } } diff --git a/src/pool.js b/src/pool.js index e4edec0e..3d9b0cb2 100644 --- a/src/pool.js +++ b/src/pool.js @@ -9,22 +9,26 @@ export default class Pool extends EventEmitter { this.threads = Pool.spawn(threads || defaults.pool.size); this.idleThreads = this.threads.slice(); this.jobQueue = []; - this.lastCreatedJob = null; + this.runArgs = []; + this.jobHistory = []; this.on('newJob', this.handleNewJob.bind(this)); + } - run(...args) { - return (new Job(this)).run(...args); + run(args) { + this.runArgs = args; + return this; } send(...args) { - if (!this.lastCreatedJob) { + if (!this.runArgs) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - // this will not alter the last job, but rather clone it and set this params on the new job - return this.lastCreatedJob.send(...args); + let job = new Job(this); + job.run(this.runArgs); + return job.send(...args); } killAll() { @@ -40,22 +44,22 @@ export default class Pool extends EventEmitter { dequeue() { if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; + return this.once('threadAvailable', this.dequeue); } const job = this.jobQueue.shift(); const thread = this.idleThreads.shift(); job - .on('done', this.handleJobSuccess.bind(this, thread, job)) - .on('error', this.handleJobError.bind(this, thread, job)); + .once('done', this.handleJobSuccess.bind(this, thread, job)) + .once('error', this.handleJobError.bind(this, thread, job)); job.executeOn(thread); } handleNewJob(job) { this.lastCreatedJob = job; - job.on('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() } handleJobSuccess(thread, job, ...responseArgs) { @@ -70,7 +74,7 @@ export default class Pool extends EventEmitter { handleJobDone(thread) { this.idleThreads.push(thread); - this.dequeue(); + this.emit('threadAvailable'); if (this.idleThreads.length === this.threads.length) { // run deferred to give other job.on('done') handlers time to run first diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index bfac9ed2..cc63b2ae 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -4,7 +4,11 @@ import EventEmitter from 'eventemitter3'; import Job from '../../lib/job'; -const fakeThreadPromise = new Promise(() => {}); +const fakeThreadPromise = new Promise((resolve) => { + setTimeout(() => { + resolve(100); + }); +}); function noop() { return this; @@ -45,7 +49,7 @@ describe('Job', () => { it('can be created', () => { const job = new Job(pool); - expect(job.hasSendParameter()).to.equal(false); + expect(job.sendArgs).to.eql([]); sinon.assert.calledOnce(pool.emit); sinon.assert.calledWith(pool.emit, 'newJob', job); }); @@ -130,7 +134,7 @@ describe('Job', () => { sinon.assert.calledWith(job.emit, 'error', error); }); - it('can clone empty job', () => { + xit('can clone empty job', () => { const job = new Job(pool); const clone = job.clone(); @@ -139,7 +143,7 @@ describe('Job', () => { expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('can clone with runnable (w/o parameter)', () => { + xit('can clone with runnable (w/o parameter)', () => { const job = new Job(pool); const runnable = noop; const importScripts = []; @@ -152,7 +156,7 @@ describe('Job', () => { expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('can clone with runnable & parameter', () => { + xit('can clone with runnable & parameter', () => { const job = new Job(pool); const runnable = noop; const importScripts = []; @@ -170,7 +174,7 @@ describe('Job', () => { expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('clones on 2nd .send()', () => { + xit('clones on 2nd .send()', () => { const job = new Job(pool); const runnable = noop; const paramA = { foo : 'bar' }; @@ -190,7 +194,7 @@ describe('Job', () => { expect(job.hasSendParameter()).to.equal(true); }); - it('proxies the promise', () => { + it('proxies the promise', (done) => { const job = new Job(pool); const thread = createFakeThread({ response : [ 'foo bar' ] @@ -202,17 +206,22 @@ describe('Job', () => { .executeOn(thread) .promise(); - expect(promise).to.equal(fakeThreadPromise); + Promise + .all([promise, fakeThreadPromise]) + .then((results) => { + expect(results[0]).to.equal(results[1]); + done(); + }); }); - it('prevents promise without .executeOn()', () => { + it('Creates a promise even if there is no thread', () => { const job = new Job(pool); job .run(noop) .send(); - expect(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + expect(job.promise() instanceof Promise).to.equal(true); }); }); diff --git a/test/spec-src/pool-functional.spec.js b/test/spec-src/pool-functional.spec.js new file mode 100644 index 00000000..e849298a --- /dev/null +++ b/test/spec-src/pool-functional.spec.js @@ -0,0 +1,37 @@ +import expect from 'expect.js'; +import { Pool } from '../../lib/'; + +describe('Pool (functional test)', () => { + const pool = new Pool(); + const jobs = [], promises = []; + + const handler = (input, done) => { + done(input); + }; + + pool.run(handler); + + it('can send data and run promisified', () => { + for (let i = 0; i < 10; i++) { + const job = pool.send(i); + if (jobs.indexOf(job) > -1) { + throw new Error('pool.send() returns the same job twice'); + } + + jobs.push(job); + promises.push(job.promise()); + } + }); + + it('responds as expected', done => { + Promise + .all(promises) + .then(responses => { + expect(responses.sort()).to.eql([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]); + done(); + }) + .catch(error => { + done(error); + }); + }); +}); diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 76e63835..820d71bd 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -20,7 +20,11 @@ var _libJob = require('../../lib/job'); var _libJob2 = _interopRequireDefault(_libJob); -var fakeThreadPromise = new Promise(function () {}); +var fakeThreadPromise = new Promise(function (resolve) { + setTimeout(function () { + resolve(100); + }); +}); function noop() { return this; @@ -63,7 +67,7 @@ describe('Job', function () { it('can be created', function () { var job = new _libJob2['default'](pool); - (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(false); + (0, _expectJs2['default'])(job.sendArgs).to.eql([]); _sinon2['default'].assert.calledOnce(pool.emit); _sinon2['default'].assert.calledWith(pool.emit, 'newJob', job); }); @@ -143,7 +147,7 @@ describe('Job', function () { _sinon2['default'].assert.calledWith(job.emit, 'error', error); }); - it('can clone empty job', function () { + xit('can clone empty job', function () { var job = new _libJob2['default'](pool); var clone = job.clone(); @@ -152,7 +156,7 @@ describe('Job', function () { (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('can clone with runnable (w/o parameter)', function () { + xit('can clone with runnable (w/o parameter)', function () { var job = new _libJob2['default'](pool); var runnable = noop; var importScripts = []; @@ -165,7 +169,7 @@ describe('Job', function () { (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('can clone with runnable & parameter', function () { + xit('can clone with runnable & parameter', function () { var job = new _libJob2['default'](pool); var runnable = noop; var importScripts = []; @@ -181,7 +185,7 @@ describe('Job', function () { (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); }); - it('clones on 2nd .send()', function () { + xit('clones on 2nd .send()', function () { var job = new _libJob2['default'](pool); var runnable = noop; var paramA = { foo: 'bar' }; @@ -199,7 +203,7 @@ describe('Job', function () { (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(true); }); - it('proxies the promise', function () { + it('proxies the promise', function (done) { var job = new _libJob2['default'](pool); var thread = createFakeThread({ response: ['foo bar'] @@ -207,14 +211,17 @@ describe('Job', function () { var promise = job.run(noop).send().executeOn(thread).promise(); - (0, _expectJs2['default'])(promise).to.equal(fakeThreadPromise); + Promise.all([promise, fakeThreadPromise]).then(function (results) { + (0, _expectJs2['default'])(results[0]).to.equal(results[1]); + done(); + }); }); - it('prevents promise without .executeOn()', function () { + it('Creates a promise even if there is no thread', function () { var job = new _libJob2['default'](pool); job.run(noop).send(); - (0, _expectJs2['default'])(job.promise).to.throwError(/Cannot return promise, since job is not executed/); + (0, _expectJs2['default'])(job.promise() instanceof Promise).to.equal(true); }); }); \ No newline at end of file diff --git a/test/spec/pool-functional.spec.js b/test/spec/pool-functional.spec.js new file mode 100644 index 00000000..05352d01 --- /dev/null +++ b/test/spec/pool-functional.spec.js @@ -0,0 +1,42 @@ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _expectJs = require('expect.js'); + +var _expectJs2 = _interopRequireDefault(_expectJs); + +var _lib = require('../../lib/'); + +describe('Pool (functional test)', function () { + var pool = new _lib.Pool(); + var jobs = [], + promises = []; + + var handler = function handler(input, done) { + done(input); + }; + + pool.run(handler); + + it('can send data and run promisified', function () { + for (var i = 0; i < 10; i++) { + var job = pool.send(i); + if (jobs.indexOf(job) > -1) { + throw new Error('pool.send() returns the same job twice'); + } + + jobs.push(job); + promises.push(job.promise()); + } + }); + + it('responds as expected', function (done) { + Promise.all(promises).then(function (responses) { + (0, _expectJs2['default'])(responses.sort()).to.eql([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + done(); + })['catch'](function (error) { + done(error); + }); + }); +}); \ No newline at end of file From b70f294543f49b424524d0ff384eac16736229ac Mon Sep 17 00:00:00 2001 From: Alexander Mays Date: Sat, 19 Mar 2016 16:19:11 -0400 Subject: [PATCH 106/224] Removed useless jobHistory property Signed-off-by: Alexander Mays --- src/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pool.js b/src/pool.js index 3d9b0cb2..0908971d 100644 --- a/src/pool.js +++ b/src/pool.js @@ -10,7 +10,6 @@ export default class Pool extends EventEmitter { this.idleThreads = this.threads.slice(); this.jobQueue = []; this.runArgs = []; - this.jobHistory = []; this.on('newJob', this.handleNewJob.bind(this)); From aab3f4e4ee271f5c8beb2c28d2c53e1b34478f4e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 20 Mar 2016 18:48:31 +0100 Subject: [PATCH 107/224] Remove job.clone() tests (job.clone() has been removed) --- test/spec-src/job.spec.js | 60 --------------------------------------- test/spec/job.spec.js | 56 ------------------------------------ 2 files changed, 116 deletions(-) diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index cc63b2ae..71f32c88 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -134,66 +134,6 @@ describe('Job', () => { sinon.assert.calledWith(job.emit, 'error', error); }); - xit('can clone empty job', () => { - const job = new Job(pool); - const clone = job.clone(); - - expect(clone.runArgs).to.eql(job.runArgs); - expect(clone.sendArgs).to.eql(job.sendArgs); - expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('can clone with runnable (w/o parameter)', () => { - const job = new Job(pool); - const runnable = noop; - const importScripts = []; - - job.run(runnable, importScripts); - const clone = job.clone(); - - expect(clone.runArgs).to.eql(job.runArgs); - expect(clone.sendArgs).to.eql(job.sendArgs); - expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('can clone with runnable & parameter', () => { - const job = new Job(pool); - const runnable = noop; - const importScripts = []; - const param = 'some data'; - const transferables = []; - - job - .run(runnable, importScripts) - .send(param, transferables); - - const clone = job.clone(); - - expect(clone.runArgs).to.eql(job.runArgs); - expect(clone.sendArgs).to.eql(job.sendArgs); - expect(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('clones on 2nd .send()', () => { - const job = new Job(pool); - const runnable = noop; - const paramA = { foo : 'bar' }; - const paramB = 'foo bar'; - - job - .run(runnable) - .send(paramA); - - const clone = job.send(paramB); - - expect(clone).not.to.equal(job); - expect(clone.runArgs).to.eql(job.runArgs); - expect(clone.sendArgs).to.eql([ paramB ]); - expect(clone.hasSendParameter()).to.equal(true); - expect(job.sendArgs).to.eql([ paramA ]); - expect(job.hasSendParameter()).to.equal(true); - }); - it('proxies the promise', (done) => { const job = new Job(pool); const thread = createFakeThread({ diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 820d71bd..193697e6 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -147,62 +147,6 @@ describe('Job', function () { _sinon2['default'].assert.calledWith(job.emit, 'error', error); }); - xit('can clone empty job', function () { - var job = new _libJob2['default'](pool); - var clone = job.clone(); - - (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); - (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); - (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('can clone with runnable (w/o parameter)', function () { - var job = new _libJob2['default'](pool); - var runnable = noop; - var importScripts = []; - - job.run(runnable, importScripts); - var clone = job.clone(); - - (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); - (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); - (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('can clone with runnable & parameter', function () { - var job = new _libJob2['default'](pool); - var runnable = noop; - var importScripts = []; - var param = 'some data'; - var transferables = []; - - job.run(runnable, importScripts).send(param, transferables); - - var clone = job.clone(); - - (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); - (0, _expectJs2['default'])(clone.sendArgs).to.eql(job.sendArgs); - (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(job.hasSendParameter()); - }); - - xit('clones on 2nd .send()', function () { - var job = new _libJob2['default'](pool); - var runnable = noop; - var paramA = { foo: 'bar' }; - var paramB = 'foo bar'; - - job.run(runnable).send(paramA); - - var clone = job.send(paramB); - - (0, _expectJs2['default'])(clone).not.to.equal(job); - (0, _expectJs2['default'])(clone.runArgs).to.eql(job.runArgs); - (0, _expectJs2['default'])(clone.sendArgs).to.eql([paramB]); - (0, _expectJs2['default'])(clone.hasSendParameter()).to.equal(true); - (0, _expectJs2['default'])(job.sendArgs).to.eql([paramA]); - (0, _expectJs2['default'])(job.hasSendParameter()).to.equal(true); - }); - it('proxies the promise', function (done) { var job = new _libJob2['default'](pool); var thread = createFakeThread({ From e460e6857fad4e38587a85ff5071bbc8e01e769c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 20 Mar 2016 18:50:35 +0100 Subject: [PATCH 108/224] Update transpiled/bundled files --- dist/slave.min.js | 2 +- dist/threads.browser.js | 1 - dist/threads.browser.min.js | 2 +- lib/pool.js | 1 - lib/pool.js.map | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/slave.min.js b/dist/slave.min.js index 048865a0..7268281e 100644 --- a/dist/slave.min.js +++ b/dist/slave.min.js @@ -1 +1 @@ -function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var o=r.data.method;this.module.exports=Function.apply(null,o.args.concat(o.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var t=this.module.exports;if("function"!=typeof t)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),t.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file +function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 59888685..0944ee7e 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -455,7 +455,6 @@ var Pool = (function (_EventEmitter) { this.idleThreads = this.threads.slice(); this.jobQueue = []; this.runArgs = []; - this.jobHistory = []; this.on('newJob', this.handleNewJob.bind(this)); } diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 58f3705a..61d1195b 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var f="function"==typeof require&&require;if(!a&&f)return f(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var u=e("eventemitter3"),c=r(u),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].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}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),f=r(a),u=e("./pool"),c=r(u),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=f["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:f["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),f=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=f,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),f=e("./job"),u=r(f),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.jobHistory=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new u["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=window.URL||window.webkitURL;if(!f)throw new Error("No Blob creation implementation found.");a=f.createObjectURL}if("function"==typeof window.BlobBuilder&&"function"==typeof a){var u=new window.BlobBuilder;u.append(i["default"]),s=a(u.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var f,u,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(u=1,f=new Array(l-1);l>u;u++)f[u-1]=arguments[u];c.fn.apply(c.context,f)}else{var h,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;default:if(!f)for(h=1,f=new Array(l-1);l>h;h++)f[h-1]=arguments[h];c[u].fn.apply(c[u].context,f)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var f=0,u=s.length;u>f;f++)(s[f].fn!==t||r&&!s[f].once||n&&s[f].context!==n)&&a.push(s[f]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,f))}catch(u){i.call(new a(f),u)}}}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;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new f["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return this.once('threadAvailable', this.dequeue);\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', this.handleJobSuccess.bind(this, thread, job))\n .once('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;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O,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,cAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', this.handleNewJob.bind(this));\n\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return this.once('threadAvailable', this.dequeue);\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', this.handleJobSuccess.bind(this, thread, job))\n .once('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file From 8a96c1297a3524e959ae39d23f14b0aa52920d7b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Mar 2016 18:34:42 +0100 Subject: [PATCH 109/224] Version 0.6.0 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 01438ddd..e55dd7e4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.4", + "version": "0.6.0", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index f8a4aee7..6236648e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.5.4", + "version": "0.6.0", "keywords": [ "threads", "web worker", From e19cc13f6de01c3f3f1d52a0b5124c88cf7db74c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Mar 2016 18:39:19 +0100 Subject: [PATCH 110/224] Update readme: Add changelog for 0.6.0 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 32662b90..5366400e 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,13 @@ config.set({ }); ``` +## Changelog + +### 0.6.0 + +Fixes promise and async issues. `Job.clone()` has been dropped. +Credit goes to https://github.com/maysale01 + ## License From 3e5dba4d5e0da080abfd7fb5f538f466169bc7f4 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Mar 2016 18:49:41 +0100 Subject: [PATCH 111/224] Revert "Make job return a promise, even if thread is not set yet" This reverts commit 23ae0ec89def21085eb29ec1baebddec4cf35b56. --- dist/threads.browser.js | 33 ++++----------------------------- dist/threads.browser.min.js | 2 +- lib/job.js | 33 ++++----------------------------- lib/job.js.map | 2 +- src/job.js | 29 ++++------------------------- test/spec-src/job.spec.js | 31 +++++++++++-------------------- test/spec-src/pool.spec.js | 8 -------- test/spec/job.spec.js | 27 ++++++++++----------------- test/spec/pool.spec.js | 9 --------- 9 files changed, 35 insertions(+), 139 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 8dbb8650..cac660cb 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -345,21 +345,12 @@ var Job = (function (_EventEmitter) { _inherits(Job, _EventEmitter); function Job(pool) { - var _this = this; - _classCallCheck(this, Job); _EventEmitter.call(this); this.pool = pool; this.thread = null; - this.promiseBoundToThread = false; - this.promiseControlMethods = {}; - this.jobPromise = new Promise(function (resolve, reject) { - _this.promiseControlMethods.resolve = resolve; - _this.promiseControlMethods.reject = reject; - }); - this.runArgs = []; this.clearSendParameter(); @@ -407,31 +398,15 @@ var Job = (function (_EventEmitter) { (_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); - if (!this.promiseBoundToThread) { - this.bindPromiseTo(thread.promise()); - } - this.thread = thread; return this; }; - Job.prototype.bindPromiseTo = function bindPromiseTo(anotherPromise) { - var _this2 = this; - - anotherPromise.then(function (result) { - _this2.promiseControlMethods.resolve(result); - return result; - })['catch'](function () { - var _promiseControlMethods; - - (_promiseControlMethods = _this2.promiseControlMethods).reject.apply(_promiseControlMethods, arguments); - }); - - this.promiseBoundToThread = true; - }; - Job.prototype.promise = function promise() { - return this.jobPromise; + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); + } + return this.thread.promise(); }; Job.prototype.clone = function clone() { diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 4660d5f2..dcd07856 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){var r=this;o(this,t),e.call(this),this.pool=n,this.thread=null,this.promiseBoundToThread=!1,this.promiseControlMethods={},this.jobPromise=new Promise(function(e,t){r.promiseControlMethods.resolve=e,r.promiseControlMethods.reject=t}),this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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.promiseBoundToThread||this.bindPromiseTo(e.promise()),this.thread=e,this},t.prototype.bindPromiseTo=function(e){var t=this;e.then(function(e){return t.promiseControlMethods.resolve(e),e})["catch"](function(){var e;(e=t.promiseControlMethods).reject.apply(e,arguments)}),this.promiseBoundToThread=!0},t.prototype.promise=function(){return this.jobPromise},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.clearSendParameter(),n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;n++)t[n]=arguments[n];if(this.hasSendParameter()){var r;return(r=this.clone().clearSendParameter()).send.apply(r,t)}return this.sendArgs=t,this.parameterSet=!0,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},t.prototype.promise=function(){if(!this.thread)throw new Error("Cannot return promise, since job is not executed.");return this.thread.promise()},t.prototype.clone=function n(){var n=new t(this.pool);return this.runArgs.length>0&&n.run.apply(n,this.runArgs),this.parameterSet&&n.send.apply(n,this.sendArgs),n},t.prototype.hasSendParameter=function(){return this.parameterSet},t.prototype.clearSendParameter=function(){return this.parameterSet=!1,this.sendArgs=[],this},t}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.lastCreatedJob=null,this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(){var e;return(e=new f["default"](this)).run.apply(e,arguments)},t.prototype.send=function(){var e;if(!this.lastCreatedJob)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");return(e=this.lastCreatedJob).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(){if(0!==this.jobQueue.length&&0!==this.idleThreads.length){var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.on("done",this.handleJobSuccess.bind(this,t,e)).on("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)}},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.on("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.dequeue(),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 {\n this.promiseControlMethods.resolve = resolve;\n this.promiseControlMethods.reject = reject;\n });\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n if (!this.promiseBoundToThread) {\n this.bindPromiseTo(thread.promise());\n }\n\n this.thread = thread;\n return this;\n }\n\n bindPromiseTo(anotherPromise) {\n anotherPromise\n .then(result => {\n this.promiseControlMethods.resolve(result);\n return result;\n })\n .catch((...errors) => {\n this.promiseControlMethods.reject(...errors);\n });\n\n this.promiseBoundToThread = true;\n }\n\n promise() {\n return this.jobPromise;\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,kBAAkB,EAAE,CAAC;;AAE1B,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;AAVkB,KAAG,WAYtB,GAAG,GAAA,eAAU;sCAAN,IAAI;AAAJ,UAAI;;;AACT,QAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,YAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;KAC1D;;AAED,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAnBkB,KAAG,WAqBtB,IAAI,GAAA,gBAAU;AACZ,QAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,YAAM,IAA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AAC3B,WAAK,CAAC,GAAG,MAAA,CAAT,KAAK,EAAQ,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;AACD,QAAI,IAAI,CAAC,YAAY,EAAE;AACrB,WAAK,CAAC,IAAI,MAAA,CAAV,KAAK,EAAS,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;;AAED,WAAO,KAAK,CAAC;GACd;;AAnEkB,KAAG,WAqEtB,gBAAgB,GAAA,4BAAG;AACjB,WAAO,IAAI,CAAC,YAAY,CAAC;GAC1B;;AAvEkB,KAAG,WAyEtB,kBAAkB,GAAA,8BAAG;AACnB,QAAI,CAAC,YAAY,GAAI,KAAK,CAAC;AAC3B,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,WAAO,IAAI,CAAC;GACb;;SA7EkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.clearSendParameter();\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n if (this.hasSendParameter()) {\n // do not alter this job, clone it and set send param instead\n return this.clone().clearSendParameter().send(...args);\n }\n\n this.sendArgs = args;\n this.parameterSet = true;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n return this;\n }\n\n promise() {\n if (!this.thread) {\n throw new Error('Cannot return promise, since job is not executed.');\n }\n return this.thread.promise();\n }\n\n clone() {\n const clone = new Job(this.pool);\n\n if (this.runArgs.length > 0) {\n clone.run(...this.runArgs);\n }\n if (this.parameterSet) {\n clone.send(...this.sendArgs);\n }\n\n return clone;\n }\n\n hasSendParameter() {\n return this.parameterSet;\n }\n\n clearSendParameter() {\n this.parameterSet = false;\n this.sendArgs = [];\n return this;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/job.js b/src/job.js index 0a03d5f0..aa490fe4 100644 --- a/src/job.js +++ b/src/job.js @@ -7,13 +7,6 @@ export default class Job extends EventEmitter { this.pool = pool; this.thread = null; - this.promiseBoundToThread = false; - this.promiseControlMethods = {}; - this.jobPromise = new Promise((resolve, reject) => { - this.promiseControlMethods.resolve = resolve; - this.promiseControlMethods.reject = reject; - }); - this.runArgs = []; this.clearSendParameter(); @@ -53,29 +46,15 @@ export default class Job extends EventEmitter { .run(...this.runArgs) .send(...this.sendArgs); - if (!this.promiseBoundToThread) { - this.bindPromiseTo(thread.promise()); - } - this.thread = thread; return this; } - bindPromiseTo(anotherPromise) { - anotherPromise - .then(result => { - this.promiseControlMethods.resolve(result); - return result; - }) - .catch((...errors) => { - this.promiseControlMethods.reject(...errors); - }); - - this.promiseBoundToThread = true; - } - promise() { - return this.jobPromise; + if (!this.thread) { + throw new Error('Cannot return promise, since job is not executed.'); + } + return this.thread.promise(); } clone() { diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js index 58a1c3a8..bfac9ed2 100644 --- a/test/spec-src/job.spec.js +++ b/test/spec-src/job.spec.js @@ -4,23 +4,17 @@ import EventEmitter from 'eventemitter3'; import Job from '../../lib/job'; +const fakeThreadPromise = new Promise(() => {}); + function noop() { return this; } -function createThreadPromise() { - return new Promise((resolve, reject) => { - this - .once('message', resolve) - .once('error', reject); - }); -} - function createFakeThread(response) { const thread = new EventEmitter(); thread.run = noop; - thread.promise = createThreadPromise; + thread.promise = () => fakeThreadPromise; if (response.error) { thread.send = function() { @@ -80,10 +74,9 @@ describe('Job', () => { it('can be executed', () => { const thread = { - once : noop, - run : noop, - send : noop, - promise : createThreadPromise + once : noop, + run : noop, + send : noop }; const mock = sinon.mock(thread); @@ -205,23 +198,21 @@ describe('Job', () => { const promise = job .run(noop) - .promise(); - - job .send() - .executeOn(thread); + .executeOn(thread) + .promise(); - expect(promise).to.be.a(Promise); + expect(promise).to.equal(fakeThreadPromise); }); - it('returns a promise without .executeOn()', () => { + it('prevents promise without .executeOn()', () => { const job = new Job(pool); job .run(noop) .send(); - expect(job.promise()).to.be.a(Promise); + expect(job.promise).to.throwError(/Cannot return promise, since job is not executed/); }); }); diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js index c2539907..f51aa958 100644 --- a/test/spec-src/pool.spec.js +++ b/test/spec-src/pool.spec.js @@ -36,14 +36,6 @@ class FakeWorker extends EventEmitter { this.emit('exit'); return this; } - - promise() { - return new Promise((resolve, reject) => { - this - .once('message', resolve) - .once('error', reject); - }); - } } function noop() { return this; } diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 67f4ec75..76e63835 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -20,23 +20,19 @@ var _libJob = require('../../lib/job'); var _libJob2 = _interopRequireDefault(_libJob); +var fakeThreadPromise = new Promise(function () {}); + function noop() { return this; } -function createThreadPromise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); -} - function createFakeThread(response) { var thread = new _eventemitter32['default'](); thread.run = noop; - thread.promise = createThreadPromise; + thread.promise = function () { + return fakeThreadPromise; + }; if (response.error) { thread.send = function () { @@ -102,8 +98,7 @@ describe('Job', function () { var thread = { once: noop, run: noop, - send: noop, - promise: createThreadPromise + send: noop }; var mock = _sinon2['default'].mock(thread); @@ -210,18 +205,16 @@ describe('Job', function () { response: ['foo bar'] }); - var promise = job.run(noop).promise(); - - job.send().executeOn(thread); + var promise = job.run(noop).send().executeOn(thread).promise(); - (0, _expectJs2['default'])(promise).to.be.a(Promise); + (0, _expectJs2['default'])(promise).to.equal(fakeThreadPromise); }); - it('returns a promise without .executeOn()', function () { + it('prevents promise without .executeOn()', function () { var job = new _libJob2['default'](pool); job.run(noop).send(); - (0, _expectJs2['default'])(job.promise()).to.be.a(Promise); + (0, _expectJs2['default'])(job.promise).to.throwError(/Cannot return promise, since job is not executed/); }); }); \ No newline at end of file diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 67c83f57..9f1cbb32 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -70,15 +70,6 @@ var FakeWorker = (function (_EventEmitter) { this.emit('exit'); return this; } - }, { - key: 'promise', - value: function promise() { - var _this2 = this; - - return new Promise(function (resolve, reject) { - _this2.once('message', resolve).once('error', reject); - }); - } }]); return FakeWorker; From 80da63400f283d9abeaa0c77c3107a091c7bcffb Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 21 Mar 2016 18:55:06 +0100 Subject: [PATCH 112/224] Update node versions to test --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 64859af7..9d921bec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: node_js node_js: - 0.12 - - 4.0 + - 4 + - 5 env: global: - CHROME_BIN=chromium-browser From 509f492ffdac572bf311aa8cddadc1e7c632eb3e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 17 Jun 2016 07:58:52 +0200 Subject: [PATCH 113/224] Rename npm script: `npm run compile` => `npm run build` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6236648e..d8692509 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "url": "https://github.com/andywer/thread.js.git" }, "scripts": { - "compile": "./node_modules/.bin/gulp dist", + "build": "./node_modules/.bin/gulp dist", "test": "./node_modules/.bin/gulp test" }, "devDependencies": { From 20d3d2866cce7cb8cb8fca2c37ead08b34796a5d Mon Sep 17 00:00:00 2001 From: Julian Thatcher Date: Fri, 17 Jun 2016 16:02:46 +1000 Subject: [PATCH 114/224] Update README.md examples --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5366400e..62fcd53e 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,10 @@ a very simple use case where you keep feeding numbers to the background task and it will return the minimum and maximum of all values you ever passed. ```javascript +const threads = require('threads'); +const spawn = threads.spawn; +const thread = spawn(function() {}); + thread .run(function minmax(int, done) { if (typeof this.min === 'undefined') { @@ -240,6 +244,10 @@ See [Transferable Objects: Lightning Fast!](http://updates.html5rocks.com/2011/1 Both features will be ignored by node.js version for now. ```javascript +const threads = require('threads'); +const spawn = threads.spawn; +const thread = spawn(function() {}); + const largeArrayBuffer = new Uint8Array(1024 * 1024 * 32); // 32MB const jobData = { label : 'huge thing', data: largeArrayBuffer.buffer }; @@ -263,6 +271,10 @@ thread The thread can also notify the main thread about its current progress. ```javascript +const threads = require('threads'); +const spawn = threads.spawn; +const thread = spawn(function() {}); + thread .run(function(input, done, progress) { setTimeout(done, 1000); @@ -274,8 +286,9 @@ thread .on('progress', function(progress) { console.log(`Progress: ${progress}%`); }) - .on('done', function() { + .on('message', function() { console.log(`Done.`); + thread.kill(); }); ``` From d7d6dee6d77b5c885d540787a6ddd98e2bf95e36 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 17 Jun 2016 08:14:44 +0200 Subject: [PATCH 115/224] Event alias: `.on('message')` <=> `.on('done')` --- dist/threads.browser.js | 1 + dist/threads.browser.min.js | 2 +- lib/worker.browser/worker.js | 1 + lib/worker.browser/worker.js.map | 2 +- lib/worker.node/worker.js | 1 + lib/worker.node/worker.js.map | 2 +- src/worker.browser/worker.js | 1 + src/worker.node/worker.js | 1 + test/spec-src/worker.spec.js | 15 +++++++++++++++ test/spec/worker.spec.js | 15 +++++++++++++++ 10 files changed, 38 insertions(+), 3 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 0944ee7e..ba7fea8f 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -192,6 +192,7 @@ var Worker = (function (_EventEmitter) { } else { var responseArgs = convertToArray(event.data.response); this.emit.apply(this, ['message'].concat(responseArgs)); + this.emit.apply(this, ['done'].concat(responseArgs)); // this one is just for convenience } }; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 61d1195b..c3077f75 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(e.data.response);this.emit.apply(this,["message"].concat(t))}},t.prototype.handleProgress=function(e){this.emit("progress",e)},t.prototype.handleError=function(e){this.listeners("error",!0)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new f["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(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)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new f["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error',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GzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SA3GkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? prefix + '/' + scriptUrl : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js index d64c06a0..e24ff56c 100644 --- a/lib/worker.node/worker.js +++ b/lib/worker.node/worker.js @@ -103,6 +103,7 @@ var Worker = (function (_EventEmitter) { this.handleProgress(message.progress); } else { this.emit.apply(this, ['message'].concat(message.response)); + this.emit.apply(this, ['done'].concat(message.response)); // this one is just for convenience } }; diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index 39b07ede..c0e66591 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC3B;GACF;;AAZkB,QAAM,WAczB,GAAG,GAAA,aAAC,KAAK,EAAE;AACT,QAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,UAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB,MAAM;AACL,UAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB;AACD,WAAO,IAAI,CAA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IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,WAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;;AAElC,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KACzB,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;AAC3B,UAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;KACvC,MAAM;AACL,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;KAC3C;GACF;;AA1EkB,QAAM,WA4EzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AA9EkB,QAAM,WAgFzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SArFkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,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,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAtFkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n this.emit('done', ...message.response); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index b3188f12..4597d421 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -129,6 +129,7 @@ export default class Worker extends EventEmitter { } else { const responseArgs = convertToArray(event.data.response); this.emit('message', ...responseArgs); + this.emit('done', ...responseArgs); // this one is just for convenience } } diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 87426fc9..63239500 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -78,6 +78,7 @@ export default class Worker extends EventEmitter { this.handleProgress(message.progress); } else { this.emit('message', ...message.response); + this.emit('done', ...message.response); // this one is just for convenience } } diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js index 63ed387d..bb6936c6 100644 --- a/test/spec-src/worker.spec.js +++ b/test/spec-src/worker.spec.js @@ -183,6 +183,21 @@ describe('Worker', () => { }); }); + it('does also emit "done" event', done => { + const progressUpdates = []; + const worker = spawn(progressThread); + + worker.on('progress', progress => { + progressUpdates.push(progress); + }); + worker.send(); + + worker.on('done', () => { + expect(progressUpdates).to.eql([ 0.3, 0.6 ]); + done(); + }); + }); + if (env === 'node') { diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 672747c9..196c8e03 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -184,6 +184,21 @@ describe('Worker', function () { }); }); + it('does also emit "done" event', function (done) { + var progressUpdates = []; + var worker = (0, _.spawn)(progressThread); + + worker.on('progress', function (progress) { + progressUpdates.push(progress); + }); + worker.send(); + + worker.on('done', function () { + (0, _expectJs2['default'])(progressUpdates).to.eql([0.3, 0.6]); + done(); + }); + }); + if (env === 'node') { it('thread code can use setTimeout, setInterval', function (done) { From 10554892bd21de6769380d37d77368c47f80d7c0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 17 Jun 2016 08:16:21 +0200 Subject: [PATCH 116/224] Remove extraneous blank lines from karma config --- karma.conf.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 27b9787d..834b4893 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,7 +2,6 @@ module.exports = function(config) { config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -42,33 +41,25 @@ module.exports = function(config) { // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress'], - // web server port port: 9876, - // enable / disable colors in the output (reporters and logs) colors: true, - // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_DEBUG, - // enable / disable watching file and executing tests whenever any file changes autoWatch: true, - - browserNoActivityTimeout: 10000, - // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: process.env.TRAVISCI ? ['Firefox'] : ['ChromeInsecure', 'Firefox'], - customLaunchers: { ChromeInsecure: { base: 'Chrome', @@ -76,7 +67,6 @@ module.exports = function(config) { } }, - // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: true From d371e5defe20cc1ccbf40f18a3fc5f4b71ceb70b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 17 Jun 2016 08:18:15 +0200 Subject: [PATCH 117/224] Use `.on('done')` in progress example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62fcd53e..19ce8aab 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ thread .on('progress', function(progress) { console.log(`Progress: ${progress}%`); }) - .on('message', function() { + .on('done', function() { console.log(`Done.`); thread.kill(); }); @@ -343,7 +343,7 @@ Credit goes to https://github.com/maysale01 ## License -This library is published under the MIT license. See [LICENSE](https://raw.githubusercontent.com/andywer/thread.js/master/LICENSE) for details. +This library is published under the MIT license. See [LICENSE](./LICENSE) for details. __Have fun and build something awesome!__ From d8874d0c79d687d4b984f83c127ac235f96721ad Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 17 Jun 2016 08:34:00 +0200 Subject: [PATCH 118/224] Version 0.6.1 --- README.md | 5 +++++ bower.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 19ce8aab..e1f3669e 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,11 @@ config.set({ ## Changelog +### 0.6.1 + +Added alias for threads: Event `done` as alias for `message`. Updated README example code. +Credit goes to https://github.com/andrakis + ### 0.6.0 Fixes promise and async issues. `Job.clone()` has been dropped. diff --git a/bower.json b/bower.json index e55dd7e4..11431550 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.6.0", + "version": "0.6.1", "main": "dist/thread.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index d8692509..20fd9b30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.6.0", + "version": "0.6.1", "keywords": [ "threads", "web worker", From 079f35a0df323f8d3cd0aae1932f08bb729c5dfb Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Tue, 21 Jun 2016 23:05:31 -0700 Subject: [PATCH 119/224] Node 6 support --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9d921bec..45e831d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ node_js: - 0.12 - 4 - 5 + - 6 env: global: - CHROME_BIN=chromium-browser From 59b67348b3643d4421967b187111797242ed36a8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 22 Jun 2016 20:41:33 +0200 Subject: [PATCH 120/224] Add `npm run build` to travis procedure --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 45e831d9..d8b2215b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,24 @@ language: node_js + node_js: - 0.12 - 4 - 5 - 6 + env: global: - CHROME_BIN=chromium-browser - DISPLAY=:99.0 - TRAVISCI=1 + before_script: - sh -e /etc/init.d/xvfb start + +script: + - npm run build + - npm test + after_success: - ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -x "lib/worker.js" -x "lib/defaults.js" -- -R spec test/spec/*.spec.js - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js From 63fd2bf0d633f74b3a0fcf657f206ed8b416ea96 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 16 Jul 2016 22:01:42 +0200 Subject: [PATCH 121/224] More careful joining of basepath and path. #23 --- dist/slave.min.js | 2 +- dist/threads.browser.js | 49 ++++++++++++++++++++++++++++---- dist/threads.browser.min.js | 2 +- lib/worker.browser/worker.js | 12 +++++++- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 12 +++++++- 6 files changed, 68 insertions(+), 11 deletions(-) diff --git a/dist/slave.min.js b/dist/slave.min.js index 7268281e..048865a0 100644 --- a/dist/slave.min.js +++ b/dist/slave.min.js @@ -1 +1 @@ -function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var t=r.data.method;this.module.exports=Function.apply(null,t.args.concat(t.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var o=this.module.exports;if("function"!=typeof o)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),o.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file +function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var o=r.data.method;this.module.exports=Function.apply(null,o.args.concat(o.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var t=this.module.exports;if("function"!=typeof t)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),t.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file diff --git a/dist/threads.browser.js b/dist/threads.browser.js index ba7fea8f..ddb68ad0 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -62,9 +62,19 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } +function joinPaths(path1, path2) { + if (!path1 || !path2) { + return path1 + path2; + } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') { + return path1 + path2; + } else { + return path1 + '/' + path2; + } +} + function prependScriptUrl(scriptUrl) { var prefix = _config.getConfig().basepath.web; - return prefix ? prefix + '/' + scriptUrl : scriptUrl; + return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl; } function convertToArray(input) { @@ -591,6 +601,8 @@ module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disa },{}],8:[function(require,module,exports){ 'use strict'; +var has = Object.prototype.hasOwnProperty; + // // We store our EE objects in a plain object whose properties are event names. // If `Object.create(null)` is not supported we prefix the event names with a @@ -606,7 +618,7 @@ var prefix = typeof Object.create !== 'function' ? '~' : false; * * @param {Function} fn Event handler to be called. * @param {Mixed} context Context for function execution. - * @param {Boolean} once Only emit once + * @param {Boolean} [once=false] Only emit once * @api private */ function EE(fn, context, once) { @@ -625,13 +637,38 @@ function EE(fn, context, once) { function EventEmitter() { /* Nothing to set */ } /** - * Holds the assigned EventEmitters by name. + * Hold the assigned EventEmitters by name. * * @type {Object} * @private */ EventEmitter.prototype._events = undefined; +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @api public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var events = this._events + , names = [] + , name; + + if (!events) return names; + + for (name in events) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + /** * Return a list of assigned event listeners. * @@ -717,8 +754,8 @@ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { * Register a new EventListener for the given event. * * @param {String} event Name of the event. - * @param {Functon} fn Callback function. - * @param {Mixed} context The context of the function. + * @param {Function} fn Callback function. + * @param {Mixed} [context=this] The context of the function. * @api public */ EventEmitter.prototype.on = function on(event, fn, context) { @@ -742,7 +779,7 @@ EventEmitter.prototype.on = function on(event, fn, context) { * * @param {String} event Name of the event. * @param {Function} fn Callback function. - * @param {Mixed} context The context of the function. + * @param {Mixed} [context=this] The context of the function. * @api public */ EventEmitter.prototype.once = function once(event, fn, context) { diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index c3077f75..b6174c5e 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?e.filename.substr(0,50)+"...":e.filename;console.error(e.message+" @"+t+":"+e.lineno)}else console.error(e)}n.__esModule=!0;var f=e("eventemitter3"),c=r(f),l=e("./slave-code-uri"),h=r(l),p=e("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var d=function(e){function t(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,t),e.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(t,e),t.prototype.initWorker=function(){try{this.worker=new window.Worker(h["default"])}catch(e){var t=p.getConfig().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(h["default"])}},t.prototype.run=function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof e?this.runMethod(e,t):this.runScripts(e,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(s)})},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(s)})},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){e.once("message",t).once("error",n)})},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=a(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)||u(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(c["default"]);n["default"]=d,t.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],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],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof e[o]&&"object"!=typeof e[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(e[o],i,s)}else{if("object"==typeof e[o])throw new Error("Expected config property to be an object: "+s.join("."));e[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(e){if("object"!=typeof e)throw new Error("Expected config object.");r(s,e)}};n["default"]=a},{}],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]?null:arguments[0],t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](e,t)}n.__esModule=!0,n.spawn=o,e("native-promise-only");var i=e("./config"),s=r(i),a=e("./defaults"),u=r(a),f=e("./pool"),c=r(f),l=e("./worker"),h=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["default"],spawn:o,Worker:h["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("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 s=e("eventemitter3"),a=r(s),u=function(e){function t(n){o(this,t),e.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(t,e),t.prototype.run=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;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;e>n;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}(a["default"]);n["default"]=u,t.exports=n["default"]},{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("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 s=e("eventemitter3"),a=r(s),u=e("./job"),f=r(u),c=e("./defaults"),l=r(c),h=e("./"),p=function(e){function t(n){o(this,t),e.call(this),this.threads=t.spawn(n||l["default"].pool.size),this.idleThreads=this.threads.slice(),this.jobQueue=[],this.runArgs=[],this.on("newJob",this.handleNewJob.bind(this))}return i(t,e),t.prototype.run=function(e){return this.runArgs=e,this},t.prototype.send=function(){if(!this.runArgs)throw new Error("Pool.send() called without prior Pool.run(). You need to define what to run first.");var e=new f["default"](this);return e.run(this.runArgs),e.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(){if(0===this.jobQueue.length||0===this.idleThreads.length)return this.once("threadAvailable",this.dequeue);var e=this.jobQueue.shift(),t=this.idleThreads.shift();e.once("done",this.handleJobSuccess.bind(this,t,e)).once("error",this.handleJobError.bind(this,t,e)),e.executeOn(t)},t.prototype.handleNewJob=function(e){this.lastCreatedJob=e,e.once("readyToRun",this.queueJob.bind(this,e))},t.prototype.handleJobSuccess=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];this.emit.apply(this,["done",t].concat(r)),this.handleJobDone(e)},t.prototype.handleJobError=function(e,t,n){this.emit("error",t,n),this.handleJobDone(e)},t.prototype.handleJobDone=function(e){var t=this;this.idleThreads.push(e),this.emit("threadAvailable"),this.idleThreads.length===this.threads.length&&setTimeout(function(){t.emit("finished")},0)},t}(a["default"]);n["default"]=p,p.spawn=function(e){for(var t=[],n=0;e>n;n++)t.push(h.spawn());return t},t.exports=n["default"]},{"./":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 f=new window.BlobBuilder;f.append(i["default"]),s=a(f.getBlob())}else if("function"==typeof window.Blob&&"function"==typeof a){var c=new window.Blob([i["default"]],{type:"text/javascript"});s=a(c)}n["default"]=s,t.exports=n["default"]},{"./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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(e,t,n){"use strict";function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){}var i="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(e,t){var n=i?i+e:e,r=this._events&&this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);s>o;o++)a[o]=r[o].fn;return a},o.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events||!this._events[a])return!1;var u,f,c=this._events[a],l=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,s),!0}for(f=1,u=new Array(l-1);l>f;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h,p=c.length;for(f=0;p>f;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;default:if(!u)for(h=1,u=new Array(l-1);l>h;h++)u[h-1]=arguments[h];c[f].fn.apply(c[f].context,u)}}return!0},o.prototype.on=function(e,t,n){var o=new r(t,n||this),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(e,t,n){var o=new r(t,n||this,!0),s=i?i+e:e;return this._events||(this._events=i?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events||!this._events[o])return this;var s=this._events[o],a=[];if(t)if(s.fn)(s.fn!==t||r&&!s.once||n&&s.context!==n)&&a.push(s);else for(var u=0,f=s.length;f>u;u++)(s[u].fn!==t||r&&!s[u].once||n&&s[u].context!==n)&&a.push(s[u]);return a.length?this._events[o]=1===a.length?a[0]:a:delete this._events[o],this},o.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[i?i+e:e]:this._events=i?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=i,"undefined"!=typeof t&&(t.exports=o)},{}],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){h.add(e,t),l||(l=d(h.drain))}function t(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t?t:!1}function n(){for(var e=0;e0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var u=t("eventemitter3"),l=r(u),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=f(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),f=r(a),c=t("./pool"),u=r(c),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=f["default"],n.Pool=u["default"],n["default"]={config:s["default"],defaults:f["default"],Pool:u["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),f=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,f))}catch(c){i.call(new a(f),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAGD,SAAS,SAAS,CAAE,KAAK,EAAE,KAAK,EAAE;AAChC,MAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;AACpB,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM;AACL,WAAO,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;GAC5B;CACF;;AAED,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CA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emitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 4597d421..8c36c4b8 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -9,9 +9,19 @@ if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { } +function joinPaths (path1, path2) { + if (!path1 || !path2) { + return path1 + path2; + } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') { + return path1 + path2; + } else { + return path1 + '/' + path2; + } +} + function prependScriptUrl(scriptUrl) { const prefix = getConfig().basepath.web; - return prefix ? prefix + '/' + scriptUrl : scriptUrl; + return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl; } function convertToArray(input) { From b30dd49d5610b744b694619869e5fdf15d09bb1b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 14:20:24 +0200 Subject: [PATCH 122/224] Add test case for running a lot of jobs in the pool --- test/spec-src/pool.spec.js | 22 ++++++++++++++++++++++ test/spec/pool.spec.js | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js index f51aa958..76900169 100644 --- a/test/spec-src/pool.spec.js +++ b/test/spec-src/pool.spec.js @@ -227,4 +227,26 @@ describe('Pool', () => { ], done); }); + it('can run a lot of jobs', (done) => { + const pool = new Pool(3); + let calledJob = 0; + + function onDone () { + calledJob++; + // pool.dequeue(); // <- this fixes it + } + + for (let jobIndex = 0; jobIndex < 50; jobIndex++) { + pool + .run(noop) + .send({ jobIndex }) + .on('done', onDone); + } + + pool.once('finished', () => { + expect(calledJob).to.equal(50); + done(); + }); + }); + }); diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 9f1cbb32..7dbbcbe5 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -250,4 +250,23 @@ describe('Pool', function () { _async2['default'].series([part1, part2], done); }); + + it('can run a lot of jobs', function (done) { + var pool = new _lib.Pool(3); + var calledJob = 0; + + function onDone() { + calledJob++; + // pool.dequeue(); // <- this fixes it + } + + for (var jobIndex = 0; jobIndex < 50; jobIndex++) { + pool.run(noop).send({ jobIndex: jobIndex }).on('done', onDone); + } + + pool.once('finished', function () { + (0, _expectJs2['default'])(calledJob).to.equal(50); + done(); + }); + }); }); \ No newline at end of file From 09abf1918286cb7393af27e0660cefaba557604d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 14:20:52 +0200 Subject: [PATCH 123/224] Fix pool event handling - Pool not executing jobs should be fixed - Registers one 'threadAvailable' listener instead of one per job --- dist/threads.browser.js | 41 +++++++++++++++++++++++++++++-------- dist/threads.browser.min.js | 2 +- lib/pool.js | 41 +++++++++++++++++++++++++++++-------- lib/pool.js.map | 2 +- src/pool.js | 12 +++++------ 5 files changed, 74 insertions(+), 24 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index ddb68ad0..7ebe46c6 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -459,6 +459,8 @@ var Pool = (function (_EventEmitter) { _inherits(Pool, _EventEmitter); function Pool(threads) { + var _this = this; + _classCallCheck(this, Pool); _EventEmitter.call(this); @@ -467,7 +469,12 @@ var Pool = (function (_EventEmitter) { this.jobQueue = []; this.runArgs = []; - this.on('newJob', this.handleNewJob.bind(this)); + this.on('newJob', function (job) { + return _this.handleNewJob(job); + }); + this.on('threadAvailable', function () { + return _this.dequeue(); + }); } Pool.prototype.run = function run(args) { @@ -497,26 +504,44 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.dequeue = function dequeue() { + var _this2 = this; + if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return this.once('threadAvailable', this.dequeue); + return; } var job = this.jobQueue.shift(); var thread = this.idleThreads.shift(); - job.once('done', this.handleJobSuccess.bind(this, thread, job)).once('error', this.handleJobError.bind(this, thread, job)); + job.once('done', function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _this2.handleJobSuccess.apply(_this2, [thread, job].concat(args)); + }).once('error', function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return _this2.handleJobError.apply(_this2, [thread, job].concat(args)); + }); job.executeOn(thread); }; Pool.prototype.handleNewJob = function handleNewJob(job) { + var _this3 = this; + this.lastCreatedJob = job; - job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + job.once('readyToRun', function () { + return _this3.queueJob(job); + }); // triggered by job.send() }; Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { - for (var _len = arguments.length, responseArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - responseArgs[_key - 2] = arguments[_key]; + for (var _len3 = arguments.length, responseArgs = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { + responseArgs[_key3 - 2] = arguments[_key3]; } this.emit.apply(this, ['done', job].concat(responseArgs)); @@ -529,7 +554,7 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.handleJobDone = function handleJobDone(thread) { - var _this = this; + var _this4 = this; this.idleThreads.push(thread); this.emit('threadAvailable'); @@ -537,7 +562,7 @@ var Pool = (function (_EventEmitter) { if (this.idleThreads.length === this.threads.length) { // run deferred to give other job.on('done') handlers time to run first setTimeout(function () { - _this.emit('finished'); + _this4.emit('finished'); }, 0); } }; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index b6174c5e..52ea0f85 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var f="function"==typeof require&&require;if(!a&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return o(n?n:t)},u,u.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var u=t("eventemitter3"),l=r(u),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=f(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),f=r(a),c=t("./pool"),u=r(c),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=f["default"],n.Pool=u["default"],n["default"]={config:s["default"],defaults:f["default"],Pool:u["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),f=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,f))}catch(c){i.call(new a(f),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var u=t("eventemitter3"),l=r(u),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=c(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||f(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),c=r(a),f=t("./pool"),u=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=c["default"],n.Pool=u["default"],n["default"]={config:s["default"],defaults:c["default"],Pool:u["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),c=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,c))}catch(f){i.call(new a(c),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - responseArgs[_key - 2] = arguments[_key]; + for (var _len3 = arguments.length, responseArgs = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { + responseArgs[_key3 - 2] = arguments[_key3]; } this.emit.apply(this, ['done', job].concat(responseArgs)); @@ -96,7 +121,7 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.handleJobDone = function handleJobDone(thread) { - var _this = this; + var _this4 = this; this.idleThreads.push(thread); this.emit('threadAvailable'); @@ -104,7 +129,7 @@ var Pool = (function (_EventEmitter) { if (this.idleThreads.length === this.threads.length) { // run deferred to give other job.on('done') handlers time to run first setTimeout(function () { - _this.emit('finished'); + _this4.emit('finished'); }, 0); } }; diff --git a/lib/pool.js.map b/lib/pool.js.map index a7e0a6c0..fb22d694 100644 --- a/lib/pool.js.map +++ b/lib/pool.js.map @@ -1 +1 @@ -{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,sBAAS,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;;AAElB,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;GAEjD;;AAVkB,MAAI,WAYvB,GAAG,GAAA,aAAC,IAAI,EAAE;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAfkB,MAAI,WAiBvB,IAAI,GAAA,gBAAU;AACZ,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;KACvG;;AAED,QAAI,GAAG,GAAG,qBAAQ,IAAI,CAAC,CAAC;AACxB,OAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtB,WAAO,GAAG,CAAC,IAAI,MAAA,CAAR,GAAG,YAAc,CAAC;GAC1B;;AAzBkB,MAAI,WA2BvB,OAAO,GAAA,mBAAG;AACR,QAAI,CAAC,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;AAAZ,kBAAY;;;AAC3C,QAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,EAAE,GAAG,SAAK,YAAY,EAAC,CAAC;AACxC,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AA7DkB,MAAI,WA+DvB,cAAc,GAAA,wBAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE;AACjC,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,cAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', this.handleNewJob.bind(this));\n\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return this.once('threadAvailable', this.dequeue);\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', this.handleJobSuccess.bind(this, thread, job))\n .once('error', this.handleJobError.bind(this, thread, job));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;;;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OA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C;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,eAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/pool.js b/src/pool.js index 0908971d..d5e864ff 100644 --- a/src/pool.js +++ b/src/pool.js @@ -11,8 +11,8 @@ export default class Pool extends EventEmitter { this.jobQueue = []; this.runArgs = []; - this.on('newJob', this.handleNewJob.bind(this)); - + this.on('newJob', (job) => this.handleNewJob(job)); + this.on('threadAvailable', () => this.dequeue()); } run(args) { @@ -43,22 +43,22 @@ export default class Pool extends EventEmitter { dequeue() { if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return this.once('threadAvailable', this.dequeue); + return; } const job = this.jobQueue.shift(); const thread = this.idleThreads.shift(); job - .once('done', this.handleJobSuccess.bind(this, thread, job)) - .once('error', this.handleJobError.bind(this, thread, job)); + .once('done', (...args) => this.handleJobSuccess(thread, job, ...args)) + .once('error', (...args) => this.handleJobError(thread, job, ...args)); job.executeOn(thread); } handleNewJob(job) { this.lastCreatedJob = job; - job.once('readyToRun', this.queueJob.bind(this, job)); // triggered by job.send() + job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send() } handleJobSuccess(thread, job, ...responseArgs) { From 62f0ad31b46e661ec495b9b950a2abcb23ae9089 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 14:32:09 +0200 Subject: [PATCH 124/224] Remove out-commented line --- test/spec-src/pool.spec.js | 1 - test/spec/pool.spec.js | 1 - 2 files changed, 2 deletions(-) diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js index 76900169..78af6032 100644 --- a/test/spec-src/pool.spec.js +++ b/test/spec-src/pool.spec.js @@ -233,7 +233,6 @@ describe('Pool', () => { function onDone () { calledJob++; - // pool.dequeue(); // <- this fixes it } for (let jobIndex = 0; jobIndex < 50; jobIndex++) { diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 7dbbcbe5..30fe3343 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -257,7 +257,6 @@ describe('Pool', function () { function onDone() { calledJob++; - // pool.dequeue(); // <- this fixes it } for (var jobIndex = 0; jobIndex < 50; jobIndex++) { From 7e1174eefce9ed5b321e05de33e7da2e194352a5 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 14:47:28 +0200 Subject: [PATCH 125/224] Improve browser worker performance (#24) - Don't re-initialize worker with new logic if new logic === old logic --- dist/threads.browser.js | 20 ++++++++++++++++++++ dist/threads.browser.min.js | 2 +- lib/worker.browser/worker.js | 20 ++++++++++++++++++++ lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 21 +++++++++++++++++++++ 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 7ebe46c6..c0dca691 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -111,6 +111,10 @@ var Worker = (function (_EventEmitter) { _EventEmitter.call(this); + // used by `run()` to decide if the worker must be re-initialized + this.currentRunnable = null; + this.currentImportScripts = []; + this.initWorker(); this.worker.addEventListener('message', this.handleMessage.bind(this)); this.worker.addEventListener('error', this.handleError.bind(this)); @@ -138,11 +142,20 @@ var Worker = (function (_EventEmitter) { Worker.prototype.run = function run(toRun) { var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + if (this.alreadyInitializedToRun(toRun, importScripts)) { + // don't re-initialize with the new logic if it already has been + return this; + } + if (typeof toRun === 'function') { this.runMethod(toRun, importScripts); } else { this.runScripts(toRun, importScripts); } + + this.currentRunnable = toRun; + this.currentImportScripts = importScripts; + return this; }; @@ -194,6 +207,13 @@ var Worker = (function (_EventEmitter) { }); }; + Worker.prototype.alreadyInitializedToRun = function alreadyInitializedToRun(toRun, importScripts) { + var runnablesMatch = this.currentRunnable === toRun; + var importScriptsMatch = this.currentImportScripts === importScripts || importScripts.length === 0 && this.currentImportScripts.length === 0; + + return runnablesMatch && importScriptsMatch; + }; + Worker.prototype.handleMessage = function handleMessage(event) { if (event.data.error) { this.handleError(event.data.error); diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 52ea0f85..195e62e5 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return o(n?n:t)},u,u.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var u=t("eventemitter3"),l=r(u),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return"function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=c(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||f(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),c=r(a),f=t("./pool"),u=r(f),l=t("./worker"),h=r(l);n.config=s["default"],n.defaults=c["default"],n.Pool=u["default"],n["default"]={config:s["default"],defaults:c["default"],Pool:u["default"],spawn:o,Worker:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),c=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,c))}catch(f){i.call(new a(c),f)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAGD,SAAS,SAAS,CAAE,KAAK,EAAE,KAAK,EAAE;AAChC,MAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;AACpB,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM;AACL,WAAO,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;GAC5B;CACF;;AAED,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;CAC1D;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;AAC7B,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,KAAK,GAAG,CAAC,CAAC;;AAEd,SAAO,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;AAC1C,eAAW,CAAC,IAAI,CA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AC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhIkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 8c36c4b8..7c220329 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -54,6 +54,10 @@ export default class Worker extends EventEmitter { constructor(initialScript = null, importScripts = []) { super(); + // used by `run()` to decide if the worker must be re-initialized + this.currentRunnable = null; + this.currentImportScripts = []; + this.initWorker(); this.worker.addEventListener('message', this.handleMessage.bind(this)); this.worker.addEventListener('error', this.handleError.bind(this)); @@ -79,11 +83,20 @@ export default class Worker extends EventEmitter { } run(toRun, importScripts = []) { + if (this.alreadyInitializedToRun(toRun, importScripts)) { + // don't re-initialize with the new logic if it already has been + return this; + } + if (typeof toRun === 'function') { this.runMethod(toRun, importScripts); } else { this.runScripts(toRun, importScripts); } + + this.currentRunnable = toRun; + this.currentImportScripts = importScripts; + return this; } @@ -131,6 +144,14 @@ export default class Worker extends EventEmitter { }); } + alreadyInitializedToRun(toRun, importScripts) { + const runnablesMatch = this.currentRunnable === toRun; + const importScriptsMatch = this.currentImportScripts === importScripts + || (importScripts.length === 0 && this.currentImportScripts.length === 0); + + return runnablesMatch && importScriptsMatch; + } + handleMessage(event) { if (event.data.error) { this.handleError(event.data.error); From 15ad0f0672bab372a71df0be7c1cedef518efa06 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 16:35:30 +0200 Subject: [PATCH 126/224] Add 0.7.0 description to changelog --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e1f3669e..2632b196 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,11 @@ config.set({ ## Changelog +### 0.7.0 + +Fixes a critical issue that prevented thread pools from running all jobs. +Also brings some major performance improvements for browser (web worker) - based setups. + ### 0.6.1 Added alias for threads: Event `done` as alias for `message`. Updated README example code. From 58713a7a2c394d04bea37cc6b2af7a7a5ed10666 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 16:35:46 +0200 Subject: [PATCH 127/224] 0.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20fd9b30..4674eac9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.6.1", + "version": "0.7.0", "keywords": [ "threads", "web worker", From fcdbccfe9bdf56bed9eb9cd919afb78b3a747dfd Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 16:45:07 +0200 Subject: [PATCH 128/224] Fix stupid bug (used wrong variable in web worker fallback) --- dist/threads.browser.js | 2 +- dist/threads.browser.min.js | 2 +- lib/worker.browser/worker.js | 2 +- lib/worker.browser/worker.js.map | 2 +- src/worker.browser/worker.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index c0dca691..2dba7e04 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -131,7 +131,7 @@ var Worker = (function (_EventEmitter) { var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; if (slaveScriptUrl) { // try using the slave script file instead of the data URI - this.worker = new window.Worker(_slaveCodeUri2['default']); + this.worker = new window.Worker(slaveScriptUrl); } else { // re-throw throw error; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 195e62e5..aa0414ec 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(e)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAA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oBAAoB,CAAC,MAAM,KAAK,CAAC,AAAC,CAAC;;AAE5E,WAAO,cAAc,IAAI,kBAAkB,CAAC;GAC7C;;AApGkB,QAAM,WAsGzB,aAAa,GAAA,uBAAC,KAAK,EAAE;AACnB,QAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE;AACpB,UAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;AAC9B,UAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1C,MAAM;AACL,UAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;AACtC,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,SAAK,YAAY,EAAC,CAAC;KACpC;GACF;;AAhHkB,QAAM,WAkHzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AApHkB,QAAM,WAsHzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhIkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveScriptUrl);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 7c220329..b848a05b 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -74,7 +74,7 @@ export default class Worker extends EventEmitter { const slaveScriptUrl = getConfig().fallback.slaveScriptUrl; if (slaveScriptUrl) { // try using the slave script file instead of the data URI - this.worker = new window.Worker(slaveCodeDataUri); + this.worker = new window.Worker(slaveScriptUrl); } else { // re-throw throw error; From e98b8caa928a4ee3373956b51f38386865c8d507 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 17 Jul 2016 16:49:49 +0200 Subject: [PATCH 129/224] Add a small thank-you note for FlorianBruckner --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2632b196..06f2e70a 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,7 @@ config.set({ Fixes a critical issue that prevented thread pools from running all jobs. Also brings some major performance improvements for browser (web worker) - based setups. +Thank you, https://github.com/FlorianBruckner, for reporting the issues and helping to debug them! ### 0.6.1 From e79a3839ba3399a7772f5b4721b0dcd0f76576bf Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 18 Aug 2016 16:04:20 +0200 Subject: [PATCH 130/224] Fix memory leak issue --- dist/threads.browser.js | 20 +++++++++++++------- dist/threads.browser.min.js | 2 +- lib/job.js | 7 ++++++- lib/job.js.map | 2 +- lib/pool.js | 13 +++++++------ lib/pool.js.map | 2 +- src/job.js | 7 ++++++- src/pool.js | 13 ++++++------- 8 files changed, 41 insertions(+), 25 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 2dba7e04..820b532e 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -422,7 +422,6 @@ var Job = (function (_EventEmitter) { (_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); this.thread = thread; - this.emit('threadChanged'); return this; }; @@ -443,6 +442,12 @@ var Job = (function (_EventEmitter) { }); }; + Job.prototype.destroy = function destroy() { + this.removeAllListeners(); + delete this.runArgs; + delete this.sendArgs; + }; + return Job; })(_eventemitter32['default']); @@ -503,13 +508,14 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.send = function send() { + var _job$run; + if (!this.runArgs) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } var job = new _job2['default'](this); - job.run(this.runArgs); - return job.send.apply(job, arguments); + return (_job$run = job.run(this.runArgs)).send.apply(_job$run, arguments); }; Pool.prototype.killAll = function killAll() { @@ -553,7 +559,6 @@ var Pool = (function (_EventEmitter) { Pool.prototype.handleNewJob = function handleNewJob(job) { var _this3 = this; - this.lastCreatedJob = job; job.once('readyToRun', function () { return _this3.queueJob(job); }); // triggered by job.send() @@ -565,17 +570,18 @@ var Pool = (function (_EventEmitter) { } this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread); + this.handleJobDone(thread, job); }; Pool.prototype.handleJobError = function handleJobError(thread, job, error) { this.emit('error', job, error); - this.handleJobDone(thread); + this.handleJobDone(thread, job); }; - Pool.prototype.handleJobDone = function handleJobDone(thread) { + Pool.prototype.handleJobDone = function handleJobDone(thread, job) { var _this4 = this; + job.destroy(); // to prevent memory leak this.idleThreads.push(thread); this.emit('threadAvailable'); diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index aa0414ec..099f3e26 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(e)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(e)}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;;;;;;;6BACyB,eAAe;;;;IAEnB,GAAG;YAAH,GAAG;;AACX,WADQ,GAAG,CACV,IAAI,EAAE;0BADC,GAAG;;AAEpB,4BAAO,CAAC;AACR,QAAI,CAAC,IAAI,GAAK,IAAI,CAAC;AACnB,QAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;AAEnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;;AAEnB,QAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;GAC3B;;AAVkB,KAAG,WAYtB,GAAG,GAAA,eAAU;sCAAN,IAAI;AAAJ,UAAI;;;AACT,QAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,YAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;KAC1D;;AAED,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAnBkB,KAAG,WAqBtB,IAAI,GAAA,gBAAU;AACZ,QAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,YAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;;uCAHK,IAAI;AAAJ,UAAI;;;AAKV,QAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;;AAErB,QAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxB,WAAO,IAAI,CAAC;GACb;;AA9BkB,KAAG,WAgCtB,SAAS,GAAA,mBAAC,MAAM,EAAE;;;AAChB,6BAAA,qBAAA,MAAM,CACH,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAC7C,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAC5C,GAAG,MAAA,oBAAI,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,MAAA,wBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;;AAE1B,QAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,WAAO,IAAI,CAAC;GACb;;AA1CkB,KAAG,WA4CtB,OAAO,GAAA,mBAAG;;;;AAER,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAK;;AAE9B,UAAI,CAAC,MAAK,MAAM,EAAE;AAChB,cAAK,IAAI,CAAC,eAAe,EAAE,YAAM;AAC/B,iBAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;SAChC,CAAC,CAAC;OACJ,MAAM;AACL,eAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;OAChC;KACF,CAAC,CAAC;GACJ;;AAxDkB,KAAG,WA0DtB,OAAO,GAAC,mBAAG;AACT,QAAI,CAAC,kBAAkB,EAAE,CAAC;AAC1B,WAAO,IAAI,CAAC,OAAO,CAAC;AACpB,WAAO,IAAI,CAAC,QAAQ,CAAC;GACtB;;SA9DkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.sendArgs = [];\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n this.sendArgs = args;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n this.emit('threadChanged');\n return this;\n }\n\n promise() {\n // Always return a promise\n return new Promise((resolve) => {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n\n destroy () {\n this.removeAllListeners();\n delete this.runArgs;\n delete this.sendArgs;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js index eb140a58..7ec1152b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -50,13 +50,14 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.send = function send() { + var _job$run; + if (!this.runArgs) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } var job = new _job2['default'](this); - job.run(this.runArgs); - return job.send.apply(job, arguments); + return (_job$run = job.run(this.runArgs)).send.apply(_job$run, arguments); }; Pool.prototype.killAll = function killAll() { @@ -100,7 +101,6 @@ var Pool = (function (_EventEmitter) { Pool.prototype.handleNewJob = function handleNewJob(job) { var _this3 = this; - this.lastCreatedJob = job; job.once('readyToRun', function () { return _this3.queueJob(job); }); // triggered by job.send() @@ -112,17 +112,18 @@ var Pool = (function (_EventEmitter) { } this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread); + this.handleJobDone(thread, job); }; Pool.prototype.handleJobError = function handleJobError(thread, job, error) { this.emit('error', job, error); - this.handleJobDone(thread); + this.handleJobDone(thread, job); }; - Pool.prototype.handleJobDone = function handleJobDone(thread) { + Pool.prototype.handleJobDone = function handleJobDone(thread, job) { var _this4 = this; + job.destroy(); // to prevent memory leak this.idleThreads.push(thread); this.emit('threadAvailable'); diff --git a/lib/pool.js.map b/lib/pool.js.map index fb22d694..f31b6df0 100644 --- a/lib/pool.js.map +++ b/lib/pool.js.map @@ -1 +1 @@ -{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;;;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,sBAAS,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;;AAElB,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAC,GAAG;aAAK,MAAK,YAAY,CAAC,GAAG,CAAC;KAAA,CAAC,CAAC;AACnD,QAAI,CAAC,EAAE,CAAC,iBAAiB,EAAE;aAAM,MAAK,OAAO,EAAE;KAAA,CAAC,CAAC;GAClD;;AAVkB,MAAI,WAYvB,GAAG,GAAA,aAAC,IAAI,EAAE;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAfkB,MAAI,WAiBvB,IAAI,GAAA,gBAAU;AACZ,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;KACvG;;AAED,QAAI,GAAG,GAAG,qBAAQ,IAAI,CAAC,CAAC;AACxB,OAAG,CAAC,G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\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,O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M,EAAE,GAAG,EAAE,KAAK,EAAE;AACjC,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;GACjC;;AAhEkB,MAAI,WAkEvB,aAAa,GAAA,uBAAC,MAAM,EAAE,GAAG,EAAE;;;AACzB,OAAG,CAAC,OAAO,EAAE,CAAC;AACd,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,eAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA3EkB,IAAI;;;qBAAJ,IAAI;;AA8EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n const job = new Job(this);\n return job.run(this.runArgs).send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread, job);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread, job);\n }\n\n handleJobDone(thread, job) {\n job.destroy(); // to prevent memory leak\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/job.js b/src/job.js index c407b2d9..c79c2986 100644 --- a/src/job.js +++ b/src/job.js @@ -41,7 +41,6 @@ export default class Job extends EventEmitter { .send(...this.sendArgs); this.thread = thread; - this.emit('threadChanged'); return this; } @@ -59,4 +58,10 @@ export default class Job extends EventEmitter { } }); } + + destroy () { + this.removeAllListeners(); + delete this.runArgs; + delete this.sendArgs; + } } diff --git a/src/pool.js b/src/pool.js index d5e864ff..9bf038a4 100644 --- a/src/pool.js +++ b/src/pool.js @@ -25,9 +25,8 @@ export default class Pool extends EventEmitter { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - let job = new Job(this); - job.run(this.runArgs); - return job.send(...args); + const job = new Job(this); + return job.run(this.runArgs).send(...args); } killAll() { @@ -57,21 +56,21 @@ export default class Pool extends EventEmitter { } handleNewJob(job) { - this.lastCreatedJob = job; job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send() } handleJobSuccess(thread, job, ...responseArgs) { this.emit('done', job, ...responseArgs); - this.handleJobDone(thread); + this.handleJobDone(thread, job); } handleJobError(thread, job, error) { this.emit('error', job, error); - this.handleJobDone(thread); + this.handleJobDone(thread, job); } - handleJobDone(thread) { + handleJobDone(thread, job) { + job.destroy(); // to prevent memory leak this.idleThreads.push(thread); this.emit('threadAvailable'); From 3b63455c97d032db991f5789a0cfdc01a5378186 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 21 Sep 2016 10:08:48 +0200 Subject: [PATCH 131/224] Add FAQ to README. See #28 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2632b196..fc2a57d7 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,14 @@ config.set({ }); ``` + +## FAQ: Frequently Asked Questions + +#### Node: `require()`-ing relative paths in worker does not work (`Error: Cannot find module`) + +**Solution**: Pass down `__dirname` to worker and use it in `require()` (see [Issue 28](https://github.com/andywer/threads.js/issues/28#issuecomment-248505917)) + + ## Changelog ### 0.7.0 From b8ea07b4060c6da0461a6bc3207fe8b9c3e53d84 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 4 Nov 2016 14:25:13 +0100 Subject: [PATCH 132/224] Pool.run should accept vararg Pool.run should also accept an vararg args array. Otherwise it is not possible to define scripts. The array needs to be expanded before it is passed to job.run. --- dist/threads.browser.js | 20 ++++++++++++-------- dist/threads.browser.min.js | 2 +- lib/bundle.browser.js.map | 2 +- lib/config.js.map | 2 +- lib/defaults.browser.js.map | 2 +- lib/defaults.js.map | 2 +- lib/defaults.node.js.map | 2 +- lib/index.js.map | 2 +- lib/job.js.map | 2 +- lib/pool.js | 20 ++++++++++++-------- lib/pool.js.map | 2 +- lib/worker.browser/slave-code-uri.js.map | 2 +- lib/worker.browser/worker.js.map | 2 +- lib/worker.js.map | 2 +- lib/worker.node/slave.js.map | 2 +- lib/worker.node/worker.js.map | 2 +- src/pool.js | 4 ++-- 17 files changed, 40 insertions(+), 32 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index c0dca691..36249b62 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -497,7 +497,11 @@ var Pool = (function (_EventEmitter) { }); } - Pool.prototype.run = function run(args) { + Pool.prototype.run = function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + this.runArgs = args; return this; }; @@ -508,7 +512,7 @@ var Pool = (function (_EventEmitter) { } var job = new _job2['default'](this); - job.run(this.runArgs); + job.run.apply(job, this.runArgs); return job.send.apply(job, arguments); }; @@ -534,14 +538,14 @@ var Pool = (function (_EventEmitter) { var thread = this.idleThreads.shift(); job.once('done', function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } return _this2.handleJobSuccess.apply(_this2, [thread, job].concat(args)); }).once('error', function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; } return _this2.handleJobError.apply(_this2, [thread, job].concat(args)); @@ -560,8 +564,8 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { - for (var _len3 = arguments.length, responseArgs = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { - responseArgs[_key3 - 2] = arguments[_key3]; + for (var _len4 = arguments.length, responseArgs = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { + responseArgs[_key4 - 2] = arguments[_key4]; } this.emit.apply(this, ['done', job].concat(responseArgs)); diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 195e62e5..3420d1b7 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;AACD,UAAQ,EAAG;AACT,kBAAc,EAAG,EAAE;GACpB;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAAE;;AAC1D,QAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AACvC,QAAI,QAAQ,GAAG,MAAM,CAAE,OAAO,CAAE,CAAC;AACjC,QAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC,CAAC;;AAE/D,QAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAChC,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,WAAW,IAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AACvF,cAAM,IAAI,KAAK,CAAC,gDAAgD,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OACpG;AACD,qBAAe,CAAC,OAAO,CAAE,OAAO,CAAE,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;KACrE,MAAM;AACL,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AAC1C,cAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OAChG;AACD,aAAO,CAAE,OAAO,CAAE,GAAG,QAAQ,CAAC;KAC/B;GACF,CAAC,CAAC;CACJ;;AAED,IAAM,MAAM,GAAG;AACb,KAAG,EAAE;WAAM,aAAa;GAAA;;AAExB,KAAG,EAAE,aAAC,SAAS,EAAK;AAClB,QAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,YAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;;AAED,mBAAe,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;GAC3C;CACF,CAAC;;qBAEa,MAAM;;AAEd,SAAS,SAAS,GAAI;AAC3B,SAAO,MAAM,CAAC,GAAG,EAAE,CAAC;CACrB;;AAEM,SAAS,SAAS,GAAW;AAClC,SAAO,MAAM,CAAC,GAAG,MAAA,CAAV,MAAM,YAAa,CAAC;CAC5B","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n },\n fallback : {\n slaveScriptUrl : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"]} \ No newline at end of file diff --git a/lib/defaults.browser.js.map b/lib/defaults.browser.js.map index 3a91dcfa..eadc6688 100644 --- a/lib/defaults.browser.js.map +++ b/lib/defaults.browser.js.map @@ -1 +1 @@ -{"version":3,"sources":["defaults.browser.js"],"names":[],"mappings":";;;;;qBAEe;AACb,MAAI,EAAG;AACL,QAAI,EAAG,SAAS,CAAC,mBAAmB,IAAI,CAAC;GAC1C;CACF","file":"defaults.browser.js","sourcesContent":["/*eslint-env browser*/\n\nexport default {\n pool : {\n size : navigator.hardwareConcurrency || 8\n }\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["defaults.browser.js"],"names":[],"mappings":";;;;;qBAEe;AACb,MAAI,EAAG;AACL,QAAI,EAAG,SAAS,CAAC,mBAAmB,IAAI,CAAC;GAC1C;CACF","file":"defaults.browser.js","sourcesContent":["/*eslint-env browser*/\n\nexport default {\n pool : {\n size : navigator.hardwareConcurrency || 8\n }\n};\n"]} \ No newline at end of file diff --git a/lib/defaults.js.map b/lib/defaults.js.map index 79534d4f..59e8bd34 100644 --- a/lib/defaults.js.map +++ b/lib/defaults.js.map @@ -1 +1 @@ -{"version":3,"sources":["defaults.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD","file":"defaults.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './defaults' resolve the './defaults.node' module.\n * Loading the browser defaults into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./defaults.node');\n} else {\n module.exports = require('./defaults.browser');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["defaults.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD","file":"defaults.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './defaults' resolve the './defaults.node' module.\n * Loading the browser defaults into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./defaults.node');\n} else {\n module.exports = require('./defaults.browser');\n}\n"]} \ No newline at end of file diff --git a/lib/defaults.node.js.map b/lib/defaults.node.js.map index 16cfc066..c123d3fc 100644 --- a/lib/defaults.node.js.map +++ b/lib/defaults.node.js.map @@ -1 +1 @@ -{"version":3,"sources":["defaults.node.js"],"names":[],"mappings":";;;;kBAAqB,IAAI;;qBAEV;AACb,MAAI,EAAG;AACL,QAAI,EAAG,UAAM,CAAC,MAAM;GACrB;CACF","file":"defaults.node.js","sourcesContent":["import { cpus } from 'os';\n\nexport default {\n pool : {\n size : cpus().length\n }\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["defaults.node.js"],"names":[],"mappings":";;;;kBAAqB,IAAI;;qBAEV;AACb,MAAI,EAAG;AACL,QAAI,EAAG,UAAM,CAAC,MAAM;GACrB;CACF","file":"defaults.node.js","sourcesContent":["import { cpus } from 'os';\n\nexport default {\n pool : {\n size : cpus().length\n }\n};\n"]} \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map index 9881919d..a6e9931e 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;QAAO,qBAAqB;;sBAEP,UAAU;;;;wBACV,YAAY;;;;oBACZ,QAAQ;;;;sBACR,UAAU;;;;QAEtB,MAAM;QAAE,QAAQ;QAAE,IAAI;;AAExB,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,UAAQ,uBAAA;AACR,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["import 'native-promise-only';\n\nimport config from './config';\nimport defaults from './defaults';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, defaults, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n defaults,\n Pool,\n spawn,\n Worker\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;QAAO,qBAAqB;;sBAEP,UAAU;;;;wBACV,YAAY;;;;oBACZ,QAAQ;;;;sBACR,UAAU;;;;QAEtB,MAAM;QAAE,QAAQ;QAAE,IAAI;;AAExB,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,UAAQ,uBAAA;AACR,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["import 'native-promise-only';\n\nimport config from './config';\nimport defaults from './defaults';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, defaults, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n defaults,\n Pool,\n spawn,\n Worker\n};\n"]} \ No newline at end of file diff --git a/lib/job.js.map b/lib/job.js.map index faa2c091..2c8afb7c 100644 --- a/lib/job.js.map +++ b/lib/job.js.map @@ -1 +1 @@ -{"version":3,"sources":["job.js"],"names":[],"mappings":";;;;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OAAO,CAAC,EACpB,IAAI,MAAA,wBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;;AAE1B,QAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;AAErB,QAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,WAAO,IAAI,CAAC;GACb;;AA3CkB,KAAG,WA6CtB,OAAO,GAAA,mBAAG;;;;AAER,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAK;;AAE9B,UAAI,CAAC,MAAK,MAAM,EAAE;AAChB,cAAK,IAAI,CAAC,eAAe,EAAE,YAAM;AAC/B,iBAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;SAChC,CAAC,CAAC;OACJ,MAAM;AACL,eAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;OAChC;KACF,CAAC,CAAC;GACJ;;SAzDkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.sendArgs = [];\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n this.sendArgs = args;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n\n this.emit('threadChanged');\n return this;\n }\n\n promise() {\n // Always return a promise\n return new Promise((resolve) => {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n}\n"],"sour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AAE,OAAO,CAAC,CAAC,EAC5C,GAAG,MAAA,oBAAI,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,MAAA,wBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;;AAE1B,QAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;AAErB,QAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,WAAO,IAAI,CAAC;GACb;;AA3CkB,KAAG,WA6CtB,OAAO,GAAA,mBAAG;;;;AAER,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAK;;AAE9B,UAAI,CAAC,MAAK,MAAM,EAAE;AAChB,cAAK,IAAI,CAAC,eAAe,EAAE,YAAM;AAC/B,iBAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;SAChC,CAAC,CAAC;OACJ,MAAM;AACL,eAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;OAChC;KACF,CAAC,CAAC;GACJ;;SAzDkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.sendArgs = [];\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n this.sendArgs = args;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n\n this.emit('threadChanged');\n return this;\n }\n\n promise() {\n // Always return a promise\n return new Promise((resolve) => {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n}\n"]} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js index eb140a58..e06ef55f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -44,7 +44,11 @@ var Pool = (function (_EventEmitter) { }); } - Pool.prototype.run = function run(args) { + Pool.prototype.run = function run() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + this.runArgs = args; return this; }; @@ -55,7 +59,7 @@ var Pool = (function (_EventEmitter) { } var job = new _job2['default'](this); - job.run(this.runArgs); + job.run.apply(job, this.runArgs); return job.send.apply(job, arguments); }; @@ -81,14 +85,14 @@ var Pool = (function (_EventEmitter) { var thread = this.idleThreads.shift(); job.once('done', function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } return _this2.handleJobSuccess.apply(_this2, [thread, job].concat(args)); }).once('error', function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; } return _this2.handleJobError.apply(_this2, [thread, job].concat(args)); @@ -107,8 +111,8 @@ var Pool = (function (_EventEmitter) { }; Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { - for (var _len3 = arguments.length, responseArgs = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { - responseArgs[_key3 - 2] = arguments[_key3]; + for (var _len4 = arguments.length, responseArgs = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { + responseArgs[_key4 - 2] = arguments[_key4]; } this.emit.apply(this, ['done', job].concat(responseArgs)); diff --git a/lib/pool.js.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AAY;;;AAC3C,QAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,EAAE,GAAG,SAAK,YAAY,EAAC,CAAC;AACxC,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AA7DkB,MAAI,WA+DvB,cAAc,GAAA,wBAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE;AACjC,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,eAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;;;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OA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O,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,eAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(...args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(...this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"]} \ No newline at end of file diff --git a/lib/worker.browser/slave-code-uri.js.map b/lib/worker.browser/slave-code-uri.js.map index 7b28b441..6d30b794 100644 --- a/lib/worker.browser/slave-code-uri.js.map +++ b/lib/worker.browser/slave-code-uri.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/slave-code-uri.js"],"names":[],"mappings":";;;;;;yBAAsB,cAAc;;;;AAEpC,IAAI,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;AACpF,IAAI,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,eAAe,CAAC;;AAEnE,IAAI,CAAC,aAAa,EAAE;AAClB,MAAM,IAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC;;AAE3C,MAAI,IAAG,EAAE;AACP,iBAAa,GAAG,IAAG,CAAC,eAAe,CAAC;GACrC,MAAM;AACL,UAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;GAC3D;CACF;;AAED,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7C,aAAW,CAAC,MAAM,wBAAW,CAAC;AAC9B,kBAAgB,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;CACzD,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,wBAAa,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACzE,kBAAgB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;CACxC;;qBAEc,gBAAgB","file":"worker.browser/slave-code-uri.js","sourcesContent":["import slaveCode from './slave-code';\n\nlet slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\nlet createBlobURL = window.createBlobURL || window.createObjectURL;\n\nif (!createBlobURL) {\n const URL = window.URL || window.webkitURL;\n\n if (URL) {\n createBlobURL = URL.createObjectURL;\n } else {\n throw new Error('No Blob creation implementation found.');\n }\n}\n\nif (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') {\n const blobBuilder = new window.BlobBuilder();\n blobBuilder.append(slaveCode);\n slaveCodeDataUri = createBlobURL(blobBuilder.getBlob());\n} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') {\n const blob = new window.Blob([ slaveCode ], { type: 'text/javascript' });\n slaveCodeDataUri = createBlobURL(blob);\n}\n\nexport default slaveCodeDataUri;\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/slave-code-uri.js"],"names":[],"mappings":";;;;;;yBAAsB,cAAc;;;;AAEpC,IAAI,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;AACpF,IAAI,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,eAAe,CAAC;;AAEnE,IAAI,CAAC,aAAa,EAAE;AAClB,MAAM,IAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC;;AAE3C,MAAI,IAAG,EAAE;AACP,iBAAa,GAAG,IAAG,CAAC,eAAe,CAAC;GACrC,MAAM;AACL,UAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;GAC3D;CACF;;AAED,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7C,aAAW,CAAC,MAAM,wBAAW,CAAC;AAC9B,kBAAgB,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;CACzD,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,wBAAa,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACzE,kBAAgB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;CACxC;;qBAEc,gBAAgB","file":"slave-code-uri.js","sourcesContent":["import slaveCode from './slave-code';\n\nlet slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\nlet createBlobURL = window.createBlobURL || window.createObjectURL;\n\nif (!createBlobURL) {\n const URL = window.URL || window.webkitURL;\n\n if (URL) {\n createBlobURL = URL.createObjectURL;\n } else {\n throw new Error('No Blob creation implementation found.');\n }\n}\n\nif (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') {\n const blobBuilder = new window.BlobBuilder();\n blobBuilder.append(slaveCode);\n slaveCodeDataUri = createBlobURL(blobBuilder.getBlob());\n} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') {\n const blob = new window.Blob([ slaveCode ], { type: 'text/javascript' });\n slaveCodeDataUri = createBlobURL(blob);\n}\n\nexport default slaveCodeDataUri;\n"]} \ No newline at end of file diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map index 1b741896..3da2af74 100644 --- a/lib/worker.browser/worker.js.map +++ b/lib/worker.browser/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAGD,SAAS,SAAS,CAAE,KAAK,EAAE,KAAK,EAAE;AAChC,MAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;AACpB,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM;AACL,WAAO,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;GAC5B;CACF;;AAED,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;CAC1D;;AAED,SAAS,cAAc,CAAC,KAAK,EAAE;A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QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AApHkB,QAAM,WAsHzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhIkB,MAAM;;;qBAAN,MAAM","file":"worker.browser/worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAGD,SAAS,SAAS,CAAE,KAAK,EAAE,KAAK,EAAE;AAChC,MAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;AACpB,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM;AACL,WAAO,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;GAC5B;CACF;;AAED,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MAAM,MAAM,GAAG,mBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACxC,SAAO,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS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AY,EAAC,CAAC;KACpC;GACF;;AAhHkB,QAAM,WAkHzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AApHkB,QAAM,WAsHzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhIkB,MAAM;;;qBAAN,MAAM","file":"worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"]} \ No newline at end of file diff --git a/lib/worker.js.map b/lib/worker.js.map index d9e00533..0f63909d 100644 --- a/lib/worker.js.map +++ b/lib/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"]} \ No newline at end of file diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map index bffec0f8..a7fd0f30 100644 --- a/lib/worker.node/slave.js.map +++ b/lib/worker.node/slave.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,SAAS,kBAAkB,GAAU;oCAAN,IAAI;AAAJ,QAAI;;;AACjC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAClC;;AAED,kBAAkB,CAAC,QAAQ,GAAG,YAAkB;qCAAN,IAAI;AAAJ,QAAI;;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,kBAAI,IAAI,CAAC,CAAC;CAC7B,CAAC;;AAEF,SAAS,sBAAsB,CAAC,QAAQ,EAAE;AACxC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAR,QAAQ,EAAE,CAAC,CAAC;CAC5B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;GACxE;CACF,CAAC,CAAC","file":"worker.node/slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\nfunction messageHandlerProgress(progress) {\n process.send({ progress });\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone, messageHandlerProgress);\n }\n});\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAA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AE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;GACxE;CACF,CAAC,CAAC","file":"slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\nfunction messageHandlerProgress(progress) {\n process.send({ progress });\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone, messageHandlerProgress);\n }\n});\n"]} \ No newline at end of file diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map index c0e66591..8aed3cf3 100644 --- a/lib/worker.node/worker.js.map +++ b/lib/worker.node/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;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AT,IAAI,GAAM,SAAS,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;AAC1C,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;KACxC;GACF;;AA3EkB,QAAM,WA6EzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AA/EkB,QAAM,WAiFzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAtFkB,MAAM;;;qBAAN,MAAM","file":"worker.node/worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n this.emit('done', ...message.response); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["worker.node/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;oBACf,MAAM;;;;6BACN,eAAe;;;;sBAEd,WAAW;;IAGhB,MAAM;YAAN,MAAM;;AACd,WADQ,MAAM,CACb,eAAe,EAAgB;QAAd,OAAO,yDAAG,EAAE;;0BADtB,MAAM;;AAEvB,4BAAO,CAAC;;AAER,QAAI,CAAC,KAAK,GAAG,2BAAM,IAAI,CAAC,kBAAK,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACvE,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,QAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;AAEpD,QAAI,eAAe,EAAE;AACnB,UAAI,CAAC,GAAG,CAAC,eAAe,CAA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nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n this.emit('done', ...message.response); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"]} \ No newline at end of file diff --git a/src/pool.js b/src/pool.js index d5e864ff..52f17959 100644 --- a/src/pool.js +++ b/src/pool.js @@ -15,7 +15,7 @@ export default class Pool extends EventEmitter { this.on('threadAvailable', () => this.dequeue()); } - run(args) { + run(...args) { this.runArgs = args; return this; } @@ -26,7 +26,7 @@ export default class Pool extends EventEmitter { } let job = new Job(this); - job.run(this.runArgs); + job.run(...this.runArgs); return job.send(...args); } From e17fcd88d0eeee9f1934d1577acc2f9df4bb01fc Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 4 Nov 2016 16:09:41 +0100 Subject: [PATCH 133/224] Add 0.7.1 to changelog --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index fc2a57d7..f9b3be2b 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,11 @@ config.set({ ## Changelog +### 0.7.1 + +`Pool.prototype.run()` now accepts more than one parameter. See [#31](https://github.com/andywer/threads.js/pull/31). +Credit goes to https://github.com/DatenMetzgerX + ### 0.7.0 Fixes a critical issue that prevented thread pools from running all jobs. From b72abb9120c444f179db5d3229a3495c87191fef Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 4 Nov 2016 16:09:59 +0100 Subject: [PATCH 134/224] 0.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4674eac9..5d64128d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.7.0", + "version": "0.7.1", "keywords": [ "threads", "web worker", From 3607e08ff31e4591e0108948157b08f72f72baf3 Mon Sep 17 00:00:00 2001 From: ChiperSoft Date: Wed, 9 Nov 2016 13:13:03 -0800 Subject: [PATCH 135/224] Fix memory leak in worker.promise --- src/worker.browser/worker.js | 14 ++++++++++++-- src/worker.node/worker.js | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 7c220329..f07c7f8c 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -138,9 +138,19 @@ export default class Worker extends EventEmitter { promise() { return new Promise((resolve, reject) => { + let resolved, rejected; + resolved = (result) => { + this.removeListener('error', rejected); + resolve(result); + }; + rejected = (err) => { + this.removeListener('message', resolved); + reject(err); + }; + this - .once('message', resolve) - .once('error', reject); + .once('message', resolved) + .once('error', rejected); }); } diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 63239500..2e290da7 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -62,9 +62,19 @@ export default class Worker extends EventEmitter { promise() { return new Promise((resolve, reject) => { + let resolved, rejected; + resolved = (result) => { + this.removeListener('error', rejected); + resolve(result); + }; + rejected = (err) => { + this.removeListener('message', resolved); + reject(err); + }; + this - .once('message', resolve) - .once('error', reject); + .once('message', resolved) + .once('error', rejected); }); } From 138c0e2979bae4264182331593f68bd1d9d0d27b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 12:12:01 +0100 Subject: [PATCH 136/224] Gitignore lib/ dir, but still publish it --- .gitignore | 5 +- .npmignore | 2 + lib/bundle.browser.js | 23 --- lib/bundle.browser.js.map | 1 - lib/config.js | 60 ------- lib/config.js.map | 1 - lib/defaults.browser.js | 12 -- lib/defaults.browser.js.map | 1 - lib/defaults.js | 15 -- lib/defaults.js.map | 1 - lib/defaults.node.js | 13 -- lib/defaults.node.js.map | 1 - lib/index.js | 44 ----- lib/index.js.map | 1 - lib/job.js | 91 ---------- lib/job.js.map | 1 - lib/pool.js | 156 ----------------- lib/pool.js.map | 1 - lib/worker.browser/slave-code-uri.js | 35 ---- lib/worker.browser/slave-code-uri.js.map | 1 - lib/worker.browser/slave-code.js | 1 - lib/worker.browser/worker.js | 210 ----------------------- lib/worker.browser/worker.js.map | 1 - lib/worker.js | 15 -- lib/worker.js.map | 1 - lib/worker.node/slave.js | 80 --------- lib/worker.node/slave.js.map | 1 - lib/worker.node/worker.js | 126 -------------- lib/worker.node/worker.js.map | 1 - 29 files changed, 5 insertions(+), 896 deletions(-) create mode 100644 .npmignore delete mode 100644 lib/bundle.browser.js delete mode 100644 lib/bundle.browser.js.map delete mode 100644 lib/config.js delete mode 100644 lib/config.js.map delete mode 100644 lib/defaults.browser.js delete mode 100644 lib/defaults.browser.js.map delete mode 100644 lib/defaults.js delete mode 100644 lib/defaults.js.map delete mode 100644 lib/defaults.node.js delete mode 100644 lib/defaults.node.js.map delete mode 100644 lib/index.js delete mode 100644 lib/index.js.map delete mode 100644 lib/job.js delete mode 100644 lib/job.js.map delete mode 100644 lib/pool.js delete mode 100644 lib/pool.js.map delete mode 100644 lib/worker.browser/slave-code-uri.js delete mode 100644 lib/worker.browser/slave-code-uri.js.map delete mode 100644 lib/worker.browser/slave-code.js delete mode 100644 lib/worker.browser/worker.js delete mode 100644 lib/worker.browser/worker.js.map delete mode 100644 lib/worker.js delete mode 100644 lib/worker.js.map delete mode 100644 lib/worker.node/slave.js delete mode 100644 lib/worker.node/slave.js.map delete mode 100644 lib/worker.node/worker.js delete mode 100644 lib/worker.node/worker.js.map diff --git a/.gitignore b/.gitignore index 5171c540..613e1f83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -node_modules -npm-debug.log \ No newline at end of file +lib/ +node_modules/ +npm-debug.log diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..60ebcdb6 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +test/ +npm-debug.log diff --git a/lib/bundle.browser.js b/lib/bundle.browser.js deleted file mode 100644 index ebb54a6c..00000000 --- a/lib/bundle.browser.js +++ /dev/null @@ -1,23 +0,0 @@ -/*eslint-env browser, amd, commonjs*/ -/*global module*/ - -'use strict'; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _index = require('./index'); - -var _index2 = _interopRequireDefault(_index); - -if (typeof window === 'object') { - window.thread = _index2['default']; -} - -if (typeof define === 'function') { - define([], function () { - return _index2['default']; - }); -} else if (typeof module === 'object') { - module.exports = _index2['default']; -} -//# sourceMappingURL=bundle.browser.js.map diff --git a/lib/bundle.browser.js.map b/lib/bundle.browser.js.map deleted file mode 100644 index f75c2a78..00000000 --- a/lib/bundle.browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["bundle.browser.js"],"names":[],"mappings":";;;;;;;qBAGsB,SAAS;;;;AAE/B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC9B,QAAM,CAAC,MAAM,qBAAY,CAAC;CAC3B;;AAED,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;AAChC,QAAM,CAAC,EAAE,EAAE,YAAW;AAAE,8BAAiB;GAAE,CAAC,CAAC;CAC9C,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AACrC,QAAM,CAAC,OAAO,qBAAY,CAAC;CAC5B","file":"bundle.browser.js","sourcesContent":["/*eslint-env browser, amd, commonjs*/\n/*global module*/\n\nimport threadLib from './index';\n\nif (typeof window === 'object') {\n window.thread = threadLib;\n}\n\nif (typeof define === 'function') {\n define([], function() { return threadLib; });\n} else if (typeof module === 'object') {\n module.exports = threadLib;\n}\n"]} \ No newline at end of file diff --git a/lib/config.js b/lib/config.js deleted file mode 100644 index 69c58e7d..00000000 --- a/lib/config.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; - -exports.__esModule = true; -exports.getConfig = getConfig; -exports.setConfig = setConfig; -var configuration = { - basepath: { - node: '', - web: '' - }, - fallback: { - slaveScriptUrl: '' - } -}; - -function configDeepMerge(destObj, srcObj) { - var ancestorProps = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; - - Object.keys(srcObj).forEach(function (propKey) { - var srcValue = srcObj[propKey]; - var ancestorPropsAndThis = ancestorProps.concat([propKey]); - - if (typeof srcValue === 'object') { - if (typeof destObj[propKey] !== 'undefined' && typeof destObj[propKey] !== 'object') { - throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.')); - } - configDeepMerge(destObj[propKey], srcValue, ancestorPropsAndThis); - } else { - if (typeof destObj[propKey] === 'object') { - throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.')); - } - destObj[propKey] = srcValue; - } - }); -} - -var config = { - get: function get() { - return configuration; - }, - - set: function set(newConfig) { - if (typeof newConfig !== 'object') { - throw new Error('Expected config object.'); - } - - configDeepMerge(configuration, newConfig); - } -}; - -exports['default'] = config; - -function getConfig() { - return config.get(); -} - -function setConfig() { - return config.set.apply(config, arguments); -} -//# sourceMappingURL=config.js.map diff --git a/lib/config.js.map b/lib/config.js.map deleted file mode 100644 index 11932b8c..00000000 --- a/lib/config.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["config.js"],"names":[],"mappings":";;;;;AAAA,IAAI,aAAa,GAAG;AAClB,UAAQ,EAAG;AACT,QAAI,EAAG,EAAE;AACT,OAAG,EAAI,EAAE;GACV;AACD,UAAQ,EAAG;AACT,kBAAc,EAAG,EAAE;GACpB;CACF,CAAC;;AAEF,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAsB;MAApB,aAAa,yDAAG,EAAE;;AAC1D,QAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AACvC,QAAI,QAAQ,GAAG,MAAM,CAAE,OAAO,CAAE,CAAC;AACjC,QAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC,CAAC;;AAE/D,QAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAChC,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,WAAW,IAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AACvF,cAAM,IAAI,KAAK,CAAC,gDAAgD,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OACpG;AACD,qBAAe,CAAC,OAAO,CAAE,OAAO,CAAE,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;KACrE,MAAM;AACL,UAAI,OAAO,OAAO,CAAE,OAAO,CAAE,KAAK,QAAQ,EAAE;AAC1C,cAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;OAChG;AACD,aAAO,CAAE,OAAO,CAAE,GAAG,QAAQ,CAAC;KAC/B;GACF,CAAC,CAAC;CACJ;;AAED,IAAM,MAAM,GAAG;AACb,KAAG,EAAE;WAAM,aAAa;GAAA;;AAExB,KAAG,EAAE,aAAC,SAAS,EAAK;AAClB,QAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,YAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;;AAED,mBAAe,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;GAC3C;CACF,CAAC;;qBAEa,MAAM;;AAEd,SAAS,SAAS,GAAI;AAC3B,SAAO,MAAM,CAAC,GAAG,EAAE,CAAC;CACrB;;AAEM,SAAS,SAAS,GAAW;AAClC,SAAO,MAAM,CAAC,GAAG,MAAA,CAAV,MAAM,YAAa,CAAC;CAC5B","file":"config.js","sourcesContent":["let configuration = {\n basepath : {\n node : '',\n web : ''\n },\n fallback : {\n slaveScriptUrl : ''\n }\n};\n\nfunction configDeepMerge(destObj, srcObj, ancestorProps = []) {\n Object.keys(srcObj).forEach((propKey) => {\n let srcValue = srcObj[ propKey ];\n const ancestorPropsAndThis = ancestorProps.concat([ propKey ]);\n\n if (typeof srcValue === 'object') {\n if (typeof destObj[ propKey ] !== 'undefined' && typeof destObj[ propKey ] !== 'object') {\n throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n configDeepMerge(destObj[ propKey ], srcValue, ancestorPropsAndThis);\n } else {\n if (typeof destObj[ propKey ] === 'object') {\n throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.'));\n }\n destObj[ propKey ] = srcValue;\n }\n });\n}\n\nconst config = {\n get: () => configuration,\n\n set: (newConfig) => {\n if (typeof newConfig !== 'object') {\n throw new Error('Expected config object.');\n }\n\n configDeepMerge(configuration, newConfig);\n }\n};\n\nexport default config;\n\nexport function getConfig () {\n return config.get();\n}\n\nexport function setConfig (...args) {\n return config.set(...args);\n}\n"]} \ No newline at end of file diff --git a/lib/defaults.browser.js b/lib/defaults.browser.js deleted file mode 100644 index 6449ef8e..00000000 --- a/lib/defaults.browser.js +++ /dev/null @@ -1,12 +0,0 @@ -/*eslint-env browser*/ - -"use strict"; - -exports.__esModule = true; -exports["default"] = { - pool: { - size: navigator.hardwareConcurrency || 8 - } -}; -module.exports = exports["default"]; -//# sourceMappingURL=defaults.browser.js.map diff --git a/lib/defaults.browser.js.map b/lib/defaults.browser.js.map deleted file mode 100644 index eadc6688..00000000 --- a/lib/defaults.browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["defaults.browser.js"],"names":[],"mappings":";;;;;qBAEe;AACb,MAAI,EAAG;AACL,QAAI,EAAG,SAAS,CAAC,mBAAmB,IAAI,CAAC;GAC1C;CACF","file":"defaults.browser.js","sourcesContent":["/*eslint-env browser*/\n\nexport default {\n pool : {\n size : navigator.hardwareConcurrency || 8\n }\n};\n"]} \ No newline at end of file diff --git a/lib/defaults.js b/lib/defaults.js deleted file mode 100644 index b46d4890..00000000 --- a/lib/defaults.js +++ /dev/null @@ -1,15 +0,0 @@ -/*eslint-env node*/ -/* - * This file is only a stub to make './defaults' resolve the './defaults.node' module. - * Loading the browser defaults into the browser bundle is done in the gulpfile by - * configuring a browserify override. - */ - -'use strict'; - -if (typeof process !== 'undefined' && 'pid' in process) { - module.exports = require('./defaults.node'); -} else { - module.exports = require('./defaults.browser'); -} -//# sourceMappingURL=defaults.js.map diff --git a/lib/defaults.js.map b/lib/defaults.js.map deleted file mode 100644 index 59e8bd34..00000000 --- a/lib/defaults.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["defaults.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAChD","file":"defaults.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './defaults' resolve the './defaults.node' module.\n * Loading the browser defaults into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./defaults.node');\n} else {\n module.exports = require('./defaults.browser');\n}\n"]} \ No newline at end of file diff --git a/lib/defaults.node.js b/lib/defaults.node.js deleted file mode 100644 index 3cecd468..00000000 --- a/lib/defaults.node.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -var _os = require('os'); - -exports['default'] = { - pool: { - size: _os.cpus().length - } -}; -module.exports = exports['default']; -//# sourceMappingURL=defaults.node.js.map diff --git a/lib/defaults.node.js.map b/lib/defaults.node.js.map deleted file mode 100644 index c123d3fc..00000000 --- a/lib/defaults.node.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["defaults.node.js"],"names":[],"mappings":";;;;kBAAqB,IAAI;;qBAEV;AACb,MAAI,EAAG;AACL,QAAI,EAAG,UAAM,CAAC,MAAM;GACrB;CACF","file":"defaults.node.js","sourcesContent":["import { cpus } from 'os';\n\nexport default {\n pool : {\n size : cpus().length\n }\n};\n"]} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8c4558c2..00000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -exports.__esModule = true; -exports.spawn = spawn; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -require('native-promise-only'); - -var _config = require('./config'); - -var _config2 = _interopRequireDefault(_config); - -var _defaults = require('./defaults'); - -var _defaults2 = _interopRequireDefault(_defaults); - -var _pool = require('./pool'); - -var _pool2 = _interopRequireDefault(_pool); - -var _worker = require('./worker'); - -var _worker2 = _interopRequireDefault(_worker); - -exports.config = _config2['default']; -exports.defaults = _defaults2['default']; -exports.Pool = _pool2['default']; - -function spawn() { - var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - return new _worker2['default'](runnable, importScripts); -} - -exports['default'] = { - config: _config2['default'], - defaults: _defaults2['default'], - Pool: _pool2['default'], - spawn: spawn, - Worker: _worker2['default'] -}; -//# sourceMappingURL=index.js.map diff --git a/lib/index.js.map b/lib/index.js.map deleted file mode 100644 index a6e9931e..00000000 --- a/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;QAAO,qBAAqB;;sBAEP,UAAU;;;;wBACV,YAAY;;;;oBACZ,QAAQ;;;;sBACR,UAAU;;;;QAEtB,MAAM;QAAE,QAAQ;QAAE,IAAI;;AAExB,SAAS,KAAK,GAAsC;MAArC,QAAQ,yDAAG,IAAI;MAAE,aAAa,yDAAG,EAAE;;AACvD,SAAO,wBAAW,QAAQ,EAAE,aAAa,CAAC,CAAC;CAC5C;;qBAEc;AACb,QAAM,qBAAA;AACN,UAAQ,uBAAA;AACR,MAAI,mBAAA;AACJ,OAAK,EAAL,KAAK;AACL,QAAM,qBAAA;CACP","file":"index.js","sourcesContent":["import 'native-promise-only';\n\nimport config from './config';\nimport defaults from './defaults';\nimport Pool from './pool';\nimport Worker from './worker';\n\nexport { config, defaults, Pool };\n\nexport function spawn(runnable = null, importScripts = []) {\n return new Worker(runnable, importScripts);\n}\n\nexport default {\n config,\n defaults,\n Pool,\n spawn,\n Worker\n};\n"]} \ No newline at end of file diff --git a/lib/job.js b/lib/job.js deleted file mode 100644 index 29c8c01c..00000000 --- a/lib/job.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var Job = (function (_EventEmitter) { - _inherits(Job, _EventEmitter); - - function Job(pool) { - _classCallCheck(this, Job); - - _EventEmitter.call(this); - this.pool = pool; - this.thread = null; - - this.runArgs = []; - this.sendArgs = []; - - pool.emit('newJob', this); - } - - Job.prototype.run = function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (args.length === 0) { - throw new Error('Cannot call .run() without arguments.'); - } - - this.runArgs = args; - return this; - }; - - Job.prototype.send = function send() { - if (this.runArgs.length === 0) { - throw new Error('Cannot .send() before .run().'); - } - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - this.sendArgs = args; - - this.emit('readyToRun'); - return this; - }; - - Job.prototype.executeOn = function executeOn(thread) { - var _thread$once$once$run, _thread$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); - - this.thread = thread; - - this.emit('threadChanged'); - return this; - }; - - Job.prototype.promise = function promise() { - var _this = this; - - // Always return a promise - return new Promise(function (resolve) { - // If the thread isn't set, listen for the threadChanged event - if (!_this.thread) { - _this.once('threadChanged', function () { - resolve(_this.thread.promise()); - }); - } else { - resolve(_this.thread.promise()); - } - }); - }; - - return Job; -})(_eventemitter32['default']); - -exports['default'] = Job; -module.exports = exports['default']; -//# sourceMappingURL=job.js.map diff --git a/lib/job.js.map b/lib/job.js.map deleted file mode 100644 index 2c8afb7c..00000000 --- a/lib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C,IAAI,EAAE,OAAO,CAAC,CAAC,EAC5C,GAAG,MAAA,oBAAI,IAAI,CAAC,OAAO,CAAC,EACpB,IAAI,MAAA,wBAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;;AAE1B,QAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;AAErB,QAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,WAAO,IAAI,CAAC;GACb;;AA3CkB,KAAG,WA6CtB,OAAO,GAAA,mBAAG;;;;AAER,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAK;;AAE9B,UAAI,CAAC,MAAK,MAAM,EAAE;AAChB,cAAK,IAAI,CAAC,eAAe,EAAE,YAAM;AAC/B,iBAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;SAChC,CAAC,CAAC;OACJ,MAAM;AACL,eAAO,CAAC,MAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;OAChC;KACF,CAAC,CAAC;GACJ;;SAzDkB,GAAG;;;qBAAH,GAAG","file":"job.js","sourcesContent":["\nimport EventEmitter from 'eventemitter3';\n\nexport default class Job extends EventEmitter {\n constructor(pool) {\n super();\n this.pool = pool;\n this.thread = null;\n\n this.runArgs = [];\n this.sendArgs = [];\n\n pool.emit('newJob', this);\n }\n\n run(...args) {\n if (args.length === 0) {\n throw new Error('Cannot call .run() without arguments.');\n }\n\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (this.runArgs.length === 0) {\n throw new Error('Cannot .send() before .run().');\n }\n\n this.sendArgs = args;\n\n this.emit('readyToRun');\n return this;\n }\n\n executeOn(thread) {\n thread\n .once('message', this.emit.bind(this, 'done'))\n .once('error', this.emit.bind(this, 'error'))\n .run(...this.runArgs)\n .send(...this.sendArgs);\n\n this.thread = thread;\n\n this.emit('threadChanged');\n return this;\n }\n\n promise() {\n // Always return a promise\n return new Promise((resolve) => {\n // If the thread isn't set, listen for the threadChanged event\n if (!this.thread) {\n this.once('threadChanged', () => {\n resolve(this.thread.promise());\n });\n } else {\n resolve(this.thread.promise());\n }\n });\n }\n}\n"]} \ No newline at end of file diff --git a/lib/pool.js b/lib/pool.js deleted file mode 100644 index e06ef55f..00000000 --- a/lib/pool.js +++ /dev/null @@ -1,156 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var _job = require('./job'); - -var _job2 = _interopRequireDefault(_job); - -var _defaults = require('./defaults'); - -var _defaults2 = _interopRequireDefault(_defaults); - -var _ = require('./'); - -var Pool = (function (_EventEmitter) { - _inherits(Pool, _EventEmitter); - - function Pool(threads) { - var _this = this; - - _classCallCheck(this, Pool); - - _EventEmitter.call(this); - this.threads = Pool.spawn(threads || _defaults2['default'].pool.size); - this.idleThreads = this.threads.slice(); - this.jobQueue = []; - this.runArgs = []; - - this.on('newJob', function (job) { - return _this.handleNewJob(job); - }); - this.on('threadAvailable', function () { - return _this.dequeue(); - }); - } - - Pool.prototype.run = function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - this.runArgs = args; - return this; - }; - - Pool.prototype.send = function send() { - if (!this.runArgs) { - throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); - } - - var job = new _job2['default'](this); - job.run.apply(job, this.runArgs); - return job.send.apply(job, arguments); - }; - - Pool.prototype.killAll = function killAll() { - this.threads.forEach(function (thread) { - thread.kill(); - }); - }; - - Pool.prototype.queueJob = function queueJob(job) { - this.jobQueue.push(job); - this.dequeue(); - }; - - Pool.prototype.dequeue = function dequeue() { - var _this2 = this; - - if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; - } - - var job = this.jobQueue.shift(); - var thread = this.idleThreads.shift(); - - job.once('done', function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return _this2.handleJobSuccess.apply(_this2, [thread, job].concat(args)); - }).once('error', function () { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - return _this2.handleJobError.apply(_this2, [thread, job].concat(args)); - }); - - job.executeOn(thread); - }; - - Pool.prototype.handleNewJob = function handleNewJob(job) { - var _this3 = this; - - this.lastCreatedJob = job; - job.once('readyToRun', function () { - return _this3.queueJob(job); - }); // triggered by job.send() - }; - - Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { - for (var _len4 = arguments.length, responseArgs = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { - responseArgs[_key4 - 2] = arguments[_key4]; - } - - this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread); - }; - - Pool.prototype.handleJobError = function handleJobError(thread, job, error) { - this.emit('error', job, error); - this.handleJobDone(thread); - }; - - Pool.prototype.handleJobDone = function handleJobDone(thread) { - var _this4 = this; - - this.idleThreads.push(thread); - this.emit('threadAvailable'); - - if (this.idleThreads.length === this.threads.length) { - // run deferred to give other job.on('done') handlers time to run first - setTimeout(function () { - _this4.emit('finished'); - }, 0); - } - }; - - return Pool; -})(_eventemitter32['default']); - -exports['default'] = Pool; - -Pool.spawn = function (threadCount) { - var threads = []; - - for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push(_.spawn()); - } - - return threads; -}; -module.exports = exports['default']; -//# sourceMappingURL=pool.js.map diff --git a/lib/pool.js.map b/lib/pool.js.map deleted file mode 100644 index 1c949529..00000000 --- a/lib/pool.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["pool.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;mBACf,OAAO;;;;wBACP,YAAY;;;;gBACZ,IAAI;;IAER,IAAI;YAAJ,IAAI;;AACZ,WADQ,IAAI,CACX,OAAO,EAAE;;;0BADF,IAAI;;AAErB,4BAAO,CAAC;AACR,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,sBAAS,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,QAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACxC,QAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;AACnB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;;AAElB,QAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAC,GAAG;aAAK,MAAK,YAAY,CAAC,GAAG,CAAC;KAAA,CAAC,CAAC;AACnD,QAAI,CAAC,EAAE,CAAC,iBAAiB,EAAE;aAAM,MAAK,OAAO,EAAE;KAAA,CAAC,CAAC;GAClD;;AAVkB,MAAI,WAYvB,GAAG,GAAA,eAAU;sCAAN,IAAI;AAAJ,UAAI;;;AACT,QAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACpB,WAAO,IAAI,CAAC;GACb;;AAfkB,MAAI,WAiBvB,IAAI,GAAA,gBAAU;AACZ,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;KACvG;;AAED,QAAI,GAAG,GAAG,qBAAQ,IAAI,CAAC,CAAC;AACxB,OAAG,CAAC,GAAG,MAAA,CAAP,GAAG,EAAQ,IAAI,CAAC,OAAO,CAAC,CAAC;AACzB,WAAO,GAAG,CAAC,IAAI,MAAA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A0DvB,gBAAgB,GAAA,0BAAC,MAAM,EAAE,GAAG,EAAmB;uCAAd,YAAY;AAAZ,kBAAY;;;AAC3C,QAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,EAAE,GAAG,SAAK,YAAY,EAAC,CAAC;AACxC,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AA7DkB,MAAI,WA+DvB,cAAc,GAAA,wBAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE;AACjC,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,QAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;GAC5B;;AAlEkB,MAAI,WAoEvB,aAAa,GAAA,uBAAC,MAAM,EAAE;;;AACpB,QAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAE7B,QAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;;AAEnD,gBAAU,CAAC,YAAM;AAAE,eAAK,IAAI,CAAC,UAAU,CAAC,CAAC;OAAE,EAAE,CAAC,CAAC,CAAC;KACjD;GACF;;SA5EkB,IAAI;;;qBAAJ,IAAI;;AA+EzB,IAAI,CAAC,KAAK,GAAG,UAAC,WAAW,EAAK;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC;;AAEnB,OAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;AAClE,WAAO,CAAC,IAAI,CAAC,SAAO,CAAC,CAAC;GACvB;;AAED,SAAO,OAAO,CAAC;CAChB,CAAC","file":"pool.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport Job from './job';\nimport defaults from './defaults';\nimport { spawn } from './';\n\nexport default class Pool extends EventEmitter {\n constructor(threads) {\n super();\n this.threads = Pool.spawn(threads || defaults.pool.size);\n this.idleThreads = this.threads.slice();\n this.jobQueue = [];\n this.runArgs = [];\n\n this.on('newJob', (job) => this.handleNewJob(job));\n this.on('threadAvailable', () => this.dequeue());\n }\n\n run(...args) {\n this.runArgs = args;\n return this;\n }\n\n send(...args) {\n if (!this.runArgs) {\n throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.');\n }\n\n let job = new Job(this);\n job.run(...this.runArgs);\n return job.send(...args);\n }\n\n killAll() {\n this.threads.forEach(thread => {\n thread.kill();\n });\n }\n\n queueJob(job) {\n this.jobQueue.push(job);\n this.dequeue();\n }\n\n dequeue() {\n if (this.jobQueue.length === 0 || this.idleThreads.length === 0) {\n return;\n }\n\n const job = this.jobQueue.shift();\n const thread = this.idleThreads.shift();\n\n job\n .once('done', (...args) => this.handleJobSuccess(thread, job, ...args))\n .once('error', (...args) => this.handleJobError(thread, job, ...args));\n\n job.executeOn(thread);\n }\n\n handleNewJob(job) {\n this.lastCreatedJob = job;\n job.once('readyToRun', () => this.queueJob(job)); // triggered by job.send()\n }\n\n handleJobSuccess(thread, job, ...responseArgs) {\n this.emit('done', job, ...responseArgs);\n this.handleJobDone(thread);\n }\n\n handleJobError(thread, job, error) {\n this.emit('error', job, error);\n this.handleJobDone(thread);\n }\n\n handleJobDone(thread) {\n this.idleThreads.push(thread);\n this.emit('threadAvailable');\n\n if (this.idleThreads.length === this.threads.length) {\n // run deferred to give other job.on('done') handlers time to run first\n setTimeout(() => { this.emit('finished'); }, 0);\n }\n }\n}\n\nPool.spawn = (threadCount) => {\n const threads = [];\n\n for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) {\n threads.push(spawn());\n }\n\n return threads;\n};\n"]} \ No newline at end of file diff --git a/lib/worker.browser/slave-code-uri.js b/lib/worker.browser/slave-code-uri.js deleted file mode 100644 index 02f50e95..00000000 --- a/lib/worker.browser/slave-code-uri.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _slaveCode = require('./slave-code'); - -var _slaveCode2 = _interopRequireDefault(_slaveCode); - -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); -var createBlobURL = window.createBlobURL || window.createObjectURL; - -if (!createBlobURL) { - var _URL = window.URL || window.webkitURL; - - if (_URL) { - createBlobURL = _URL.createObjectURL; - } else { - throw new Error('No Blob creation implementation found.'); - } -} - -if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') { - var blobBuilder = new window.BlobBuilder(); - blobBuilder.append(_slaveCode2['default']); - slaveCodeDataUri = createBlobURL(blobBuilder.getBlob()); -} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') { - var blob = new window.Blob([_slaveCode2['default']], { type: 'text/javascript' }); - slaveCodeDataUri = createBlobURL(blob); -} - -exports['default'] = slaveCodeDataUri; -module.exports = exports['default']; -//# sourceMappingURL=slave-code-uri.js.map diff --git a/lib/worker.browser/slave-code-uri.js.map b/lib/worker.browser/slave-code-uri.js.map deleted file mode 100644 index 6d30b794..00000000 --- a/lib/worker.browser/slave-code-uri.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["worker.browser/slave-code-uri.js"],"names":[],"mappings":";;;;;;yBAAsB,cAAc;;;;AAEpC,IAAI,gBAAgB,GAAG,qCAAqC,GAAG,SAAS,wBAAW,CAAC;AACpF,IAAI,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,eAAe,CAAC;;AAEnE,IAAI,CAAC,aAAa,EAAE;AAClB,MAAM,IAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC;;AAE3C,MAAI,IAAG,EAAE;AACP,iBAAa,GAAG,IAAG,CAAC,eAAe,CAAC;GACrC,MAAM;AACL,UAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;GAC3D;CACF;;AAED,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7C,aAAW,CAAC,MAAM,wBAAW,CAAC;AAC9B,kBAAgB,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;CACzD,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACnF,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,wBAAa,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACzE,kBAAgB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;CACxC;;qBAEc,gBAAgB","file":"slave-code-uri.js","sourcesContent":["import slaveCode from './slave-code';\n\nlet slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(slaveCode);\nlet createBlobURL = window.createBlobURL || window.createObjectURL;\n\nif (!createBlobURL) {\n const URL = window.URL || window.webkitURL;\n\n if (URL) {\n createBlobURL = URL.createObjectURL;\n } else {\n throw new Error('No Blob creation implementation found.');\n }\n}\n\nif (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') {\n const blobBuilder = new window.BlobBuilder();\n blobBuilder.append(slaveCode);\n slaveCodeDataUri = createBlobURL(blobBuilder.getBlob());\n} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') {\n const blob = new window.Blob([ slaveCode ], { type: 'text/javascript' });\n slaveCodeDataUri = createBlobURL(blob);\n}\n\nexport default slaveCodeDataUri;\n"]} \ No newline at end of file diff --git a/lib/worker.browser/slave-code.js b/lib/worker.browser/slave-code.js deleted file mode 100644 index c5470c62..00000000 --- a/lib/worker.browser/slave-code.js +++ /dev/null @@ -1 +0,0 @@ -module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"; \ No newline at end of file diff --git a/lib/worker.browser/worker.js b/lib/worker.browser/worker.js deleted file mode 100644 index 1a794277..00000000 --- a/lib/worker.browser/worker.js +++ /dev/null @@ -1,210 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var _slaveCodeUri = require('./slave-code-uri'); - -var _slaveCodeUri2 = _interopRequireDefault(_slaveCodeUri); - -var _config = require('../config'); - -if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { - throw new Error('Browser does not support web workers!'); -} - -function joinPaths(path1, path2) { - if (!path1 || !path2) { - return path1 + path2; - } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') { - return path1 + path2; - } else { - return path1 + '/' + path2; - } -} - -function prependScriptUrl(scriptUrl) { - var prefix = _config.getConfig().basepath.web; - return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl; -} - -function convertToArray(input) { - var outputArray = []; - var index = 0; - - while (typeof input[index] !== 'undefined') { - outputArray.push(input[index]); - index++; - } - - return outputArray; -} - -function logError(error) { - if (error.stack) { - console.error(error.stack); // eslint-disable-line no-console - } else if (error.message && error.filename && error.lineno) { - var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } -} - -var Worker = (function (_EventEmitter) { - _inherits(Worker, _EventEmitter); - - function Worker() { - var initialScript = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - _classCallCheck(this, Worker); - - _EventEmitter.call(this); - - // used by `run()` to decide if the worker must be re-initialized - this.currentRunnable = null; - this.currentImportScripts = []; - - this.initWorker(); - this.worker.addEventListener('message', this.handleMessage.bind(this)); - this.worker.addEventListener('error', this.handleError.bind(this)); - - if (initialScript) { - this.run(initialScript, importScripts); - } - } - - Worker.prototype.initWorker = function initWorker() { - try { - this.worker = new window.Worker(_slaveCodeUri2['default']); - } catch (error) { - var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; - if (slaveScriptUrl) { - // try using the slave script file instead of the data URI - this.worker = new window.Worker(_slaveCodeUri2['default']); - } else { - // re-throw - throw error; - } - } - }; - - Worker.prototype.run = function run(toRun) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - if (this.alreadyInitializedToRun(toRun, importScripts)) { - // don't re-initialize with the new logic if it already has been - return this; - } - - if (typeof toRun === 'function') { - this.runMethod(toRun, importScripts); - } else { - this.runScripts(toRun, importScripts); - } - - this.currentRunnable = toRun; - this.currentImportScripts = importScripts; - - return this; - }; - - Worker.prototype.runMethod = function runMethod(method, importScripts) { - var methodStr = method.toString(); - var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); - var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); - - this.worker.postMessage({ - initByMethod: true, - method: { args: args, body: body }, - scripts: importScripts.map(prependScriptUrl) - }); - }; - - Worker.prototype.runScripts = function runScripts(script, importScripts) { - if (!script) { - throw new Error('Must pass a function or a script URL to run().'); - } - - // attention: array for browser, single script for node - this.worker.postMessage({ - initByScripts: true, - scripts: importScripts.concat([script]).map(prependScriptUrl) - }); - }; - - Worker.prototype.send = function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.worker.postMessage({ - doRun: true, - param: param - }, transferables); - return this; - }; - - Worker.prototype.kill = function kill() { - this.worker.terminate(); - this.emit('exit'); - return this; - }; - - Worker.prototype.promise = function promise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); - }; - - Worker.prototype.alreadyInitializedToRun = function alreadyInitializedToRun(toRun, importScripts) { - var runnablesMatch = this.currentRunnable === toRun; - var importScriptsMatch = this.currentImportScripts === importScripts || importScripts.length === 0 && this.currentImportScripts.length === 0; - - return runnablesMatch && importScriptsMatch; - }; - - Worker.prototype.handleMessage = function handleMessage(event) { - if (event.data.error) { - this.handleError(event.data.error); - } else if (event.data.progress) { - this.handleProgress(event.data.progress); - } else { - var responseArgs = convertToArray(event.data.response); - this.emit.apply(this, ['message'].concat(responseArgs)); - this.emit.apply(this, ['done'].concat(responseArgs)); // this one is just for convenience - } - }; - - Worker.prototype.handleProgress = function handleProgress(progress) { - this.emit('progress', progress); - }; - - Worker.prototype.handleError = function handleError(error) { - if (!this.listeners('error', true)) { - logError(error); - } - - if (error.preventDefault) { - error.preventDefault(); - } - - this.emit('error', error); - }; - - return Worker; -})(_eventemitter32['default']); - -exports['default'] = Worker; -module.exports = exports['default']; -//# sourceMappingURL=worker.js.map diff --git a/lib/worker.browser/worker.js.map b/lib/worker.browser/worker.js.map deleted file mode 100644 index 3da2af74..00000000 --- a/lib/worker.browser/worker.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["worker.browser/worker.js"],"names":[],"mappings":";;;;;;;;;;6BAAyB,eAAe;;;;4BACX,kBAAkB;;;;sBAErB,WAAW;;AAGrC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;AAC5E,QAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;CAC1D;;AAGD,SAAS,SAAS,CAAE,KAAK,EAAE,KAAK,EAAE;AAChC,MAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;AACpB,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E,WAAO,KAAK,GAAG,KAAK,CAAC;GACtB,MAAM;AACL,WAAO,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;GAC5B;CACF;;AAED,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACnC,MA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T,IAAI,GAAM,SAAS,SAAK,YAAY,EAAC,CAAC;AACtC,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,SAAK,YAAY,EAAC,CAAC;KACpC;GACF;;AAhHkB,QAAM,WAkHzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AApHkB,QAAM,WAsHzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,cAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;;AAED,QAAI,KAAK,CAAC,cAAc,EAAE;AACxB,WAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;AAED,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAhIkB,MAAM;;;qBAAN,MAAM","file":"worker.js","sourcesContent":["import EventEmitter from 'eventemitter3';\nimport slaveCodeDataUri from './slave-code-uri';\n\nimport { getConfig } from '../config';\n\n\nif (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') {\n throw new Error('Browser does not support web workers!');\n}\n\n\nfunction joinPaths (path1, path2) {\n if (!path1 || !path2) {\n return path1 + path2;\n } else if (path1.charAt(path1.length - 1) === '/' || path2.charAt(0) === '/') {\n return path1 + path2;\n } else {\n return path1 + '/' + path2;\n }\n}\n\nfunction prependScriptUrl(scriptUrl) {\n const prefix = getConfig().basepath.web;\n return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl;\n}\n\nfunction convertToArray(input) {\n let outputArray = [];\n let index = 0;\n\n while (typeof input[index] !== 'undefined') {\n outputArray.push(input[index]);\n index++;\n }\n\n return outputArray;\n}\n\nfunction logError(error) {\n if (error.stack) {\n console.error(error.stack); // eslint-disable-line no-console\n } else if (error.message && error.filename && error.lineno) {\n const fileName = error.filename.match(/^data:text\\/javascript/) && error.filename.length > 50\n ? error.filename.substr(0, 50) + '...'\n : error.filename;\n console.error(`${error.message} @${fileName}:${error.lineno}`); // eslint-disable-line no-console\n } else {\n console.error(error); // eslint-disable-line no-console\n }\n}\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialScript = null, importScripts = []) {\n super();\n\n // used by `run()` to decide if the worker must be re-initialized\n this.currentRunnable = null;\n this.currentImportScripts = [];\n\n this.initWorker();\n this.worker.addEventListener('message', this.handleMessage.bind(this));\n this.worker.addEventListener('error', this.handleError.bind(this));\n\n if (initialScript) {\n this.run(initialScript, importScripts);\n }\n }\n\n initWorker() {\n try {\n this.worker = new window.Worker(slaveCodeDataUri);\n } catch (error) {\n const slaveScriptUrl = getConfig().fallback.slaveScriptUrl;\n if (slaveScriptUrl) {\n // try using the slave script file instead of the data URI\n this.worker = new window.Worker(slaveCodeDataUri);\n } else {\n // re-throw\n throw error;\n }\n }\n }\n\n run(toRun, importScripts = []) {\n if (this.alreadyInitializedToRun(toRun, importScripts)) {\n // don't re-initialize with the new logic if it already has been\n return this;\n }\n\n if (typeof toRun === 'function') {\n this.runMethod(toRun, importScripts);\n } else {\n this.runScripts(toRun, importScripts);\n }\n\n this.currentRunnable = toRun;\n this.currentImportScripts = importScripts;\n\n return this;\n }\n\n runMethod(method, importScripts) {\n const methodStr = method.toString();\n const args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(',');\n const body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}'));\n\n this.worker.postMessage({\n initByMethod : true,\n method : { args, body },\n scripts : importScripts.map(prependScriptUrl)\n });\n }\n\n runScripts(script, importScripts) {\n if (!script) { throw new Error('Must pass a function or a script URL to run().'); }\n\n // attention: array for browser, single script for node\n this.worker.postMessage({\n initByScripts : true,\n scripts : importScripts.concat([ script ]).map(prependScriptUrl)\n });\n }\n\n send(param, transferables = []) {\n this.worker.postMessage({\n doRun : true,\n param\n }, transferables);\n return this;\n }\n\n kill() {\n this.worker.terminate();\n this.emit('exit');\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n alreadyInitializedToRun(toRun, importScripts) {\n const runnablesMatch = this.currentRunnable === toRun;\n const importScriptsMatch = this.currentImportScripts === importScripts\n || (importScripts.length === 0 && this.currentImportScripts.length === 0);\n\n return runnablesMatch && importScriptsMatch;\n }\n\n handleMessage(event) {\n if (event.data.error) {\n this.handleError(event.data.error);\n } else if (event.data.progress) {\n this.handleProgress(event.data.progress);\n } else {\n const responseArgs = convertToArray(event.data.response);\n this.emit('message', ...responseArgs);\n this.emit('done', ...responseArgs); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n logError(error);\n }\n\n if (error.preventDefault) {\n error.preventDefault();\n }\n\n this.emit('error', error);\n }\n}\n"]} \ No newline at end of file diff --git a/lib/worker.js b/lib/worker.js deleted file mode 100644 index 795c88c0..00000000 --- a/lib/worker.js +++ /dev/null @@ -1,15 +0,0 @@ -/*eslint-env node*/ -/* - * This file is only a stub to make './worker' resolve the './worker.node/worker' module. - * Loading the browser worker into the browser bundle is done in the gulpfile by - * configuring a browserify override. - */ - -'use strict'; - -if (typeof process !== 'undefined' && 'pid' in process) { - module.exports = require('./worker.node/worker'); -} else { - module.exports = require('./worker.browser/worker'); -} -//# sourceMappingURL=worker.js.map diff --git a/lib/worker.js.map b/lib/worker.js.map deleted file mode 100644 index 0f63909d..00000000 --- a/lib/worker.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["worker.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,OAAO,EAAE;AACtD,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAClD,MAAM;AACL,QAAM,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACrD","file":"worker.js","sourcesContent":["/*eslint-env node*/\n/*\n * This file is only a stub to make './worker' resolve the './worker.node/worker' module.\n * Loading the browser worker into the browser bundle is done in the gulpfile by\n * configuring a browserify override.\n */\n\nif (typeof process !== 'undefined' && 'pid' in process) {\n module.exports = require('./worker.node/worker');\n} else {\n module.exports = require('./worker.browser/worker');\n}\n"]} \ No newline at end of file diff --git a/lib/worker.node/slave.js b/lib/worker.node/slave.js deleted file mode 100644 index 4db936e1..00000000 --- a/lib/worker.node/slave.js +++ /dev/null @@ -1,80 +0,0 @@ -// not using ES6 import/export syntax, since we need to require() in a handler -// what the ES6 syntax does not permit -'use strict'; - -var vm = require('vm'); - -var errorCatcherInPlace = false; -var messageHandler = function messageHandler() { - console.error('No thread logic initialized.'); // eslint-disable-line no-console -}; - -function setupErrorCatcher() { - if (errorCatcherInPlace) { - return; - } - - process.on('uncaughtException', function (error) { - process.send({ - error: { message: error.message, stack: error.stack } - }); - }); - - errorCatcherInPlace = true; -} - -function runAsSandboxedModule(code) { - var sandbox = { - Buffer: Buffer, - console: console, - clearInterval: clearInterval, - clearTimeout: clearTimeout, - module: { exports: null }, - require: require, - setInterval: setInterval, - setTimeout: setTimeout - }; - - vm.runInNewContext(code, sandbox); - return sandbox.module.exports; -} - -function messageHandlerDone() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - process.send({ response: args }); -} - -messageHandlerDone.transfer = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - args.pop(); // ignore last parameter, since it's only useful for browser code - messageHandlerDone.apply(undefined, args); -}; - -function messageHandlerProgress(progress) { - process.send({ progress: progress }); -} - -process.on('message', function (data) { - if (data.initByScript) { - messageHandler = require(data.script); - } - - if (data.initByMethod) { - messageHandler = runAsSandboxedModule('module.exports = ' + data.method); - } - - if (data.doRun) { - // it's a good idea to wait until first thread logic run to set this up, - // so initialization errors will be printed to console - setupErrorCatcher(); - - messageHandler(data.param, messageHandlerDone, messageHandlerProgress); - } -}); -//# sourceMappingURL=slave.js.map diff --git a/lib/worker.node/slave.js.map b/lib/worker.node/slave.js.map deleted file mode 100644 index a7fd0f30..00000000 --- a/lib/worker.node/slave.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["worker.node/slave.js"],"names":[],"mappings":";;;;AAEA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,cAAc,GAAG,0BAAW;AAC9B,SAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;CAC/C,CAAC;;AAEF,SAAS,iBAAiB,GAAG;AAC3B,MAAI,mBAAmB,EAAE;AAAE,WAAO;GAAE;;AAEpC,SAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAS,KAAK,EAAE;AAC9C,WAAO,CAAC,IAAI,CAAC;AACX,WAAK,EAAG,EAAE,OAAO,EAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAG,KAAK,CAAC,KAAK,EAAE;KACzD,CAAC,CAAC;GACJ,CAAC,CAAC;;AAEH,qBAAmB,GAAG,IAAI,CAAC;CAC5B;;AAGD,SAAS,oBAAoB,CAAC,IAAI,EAAE;AAClC,MAAI,OAAO,GAAG;AACZ,UAAM,EAAN,MAAM;AACN,WAAO,EAAP,OAAO;AACP,iBAAa,EAAb,aAAa;AACb,gBAAY,EAAZ,YAAY;AACZ,UAAM,EAAU,EAAE,OAAO,EAAG,IAAI,EAAE;AAClC,WAAO,EAAP,OAAO;AACP,eAAW,EAAX,WAAW;AACX,cAAU,EAAV,UAAU;GACX,CAAC;;AAEF,IAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,SAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;CAC/B;;AAGD,SAAS,kBAAkB,GAAU;oCAAN,IAAI;AAAJ,QAAI;;;AACjC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;CAClC;;AAED,kBAAkB,CAAC,QAAQ,GAAG,YAAkB;qCAAN,IAAI;AAAJ,QAAI;;;AAC5C,MAAI,CAAC,GAAG,EAAE,CAAC;AACX,oBAAkB,kBAAI,IAAI,CAAC,CAAC;CAC7B,CAAC;;AAEF,SAAS,sBAAsB,CAAC,QAAQ,EAAE;AACxC,SAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAR,QAAQ,EAAE,CAAC,CAAC;CAC5B;;AAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAS,IAAI,EAAE;AACnC,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;GACvC;;AAED,MAAI,IAAI,CAAC,YAAY,EAAE;AACrB,kBAAc,GAAG,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;GAC1E;;AAED,MAAI,IAAI,CAAC,KAAK,EAAE;;;AAGd,qBAAiB,EAAE,CAAC;;AAEpB,kBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;GACxE;CACF,CAAC,CAAC","file":"slave.js","sourcesContent":["// not using ES6 import/export syntax, since we need to require() in a handler\n// what the ES6 syntax does not permit\nconst vm = require('vm');\n\nlet errorCatcherInPlace = false;\nlet messageHandler = function() {\n console.error('No thread logic initialized.'); // eslint-disable-line no-console\n};\n\nfunction setupErrorCatcher() {\n if (errorCatcherInPlace) { return; }\n\n process.on('uncaughtException', function(error) {\n process.send({\n error : { message : error.message, stack : error.stack }\n });\n });\n\n errorCatcherInPlace = true;\n}\n\n\nfunction runAsSandboxedModule(code) {\n var sandbox = {\n Buffer,\n console,\n clearInterval,\n clearTimeout,\n module : { exports : null },\n require,\n setInterval,\n setTimeout\n };\n\n vm.runInNewContext(code, sandbox);\n return sandbox.module.exports;\n}\n\n\nfunction messageHandlerDone(...args) {\n process.send({ response: args });\n}\n\nmessageHandlerDone.transfer = function(...args) {\n args.pop(); // ignore last parameter, since it's only useful for browser code\n messageHandlerDone(...args);\n};\n\nfunction messageHandlerProgress(progress) {\n process.send({ progress });\n}\n\n\nprocess.on('message', function(data) {\n if (data.initByScript) {\n messageHandler = require(data.script);\n }\n\n if (data.initByMethod) {\n messageHandler = runAsSandboxedModule('module.exports = ' + data.method);\n }\n\n if (data.doRun) {\n // it's a good idea to wait until first thread logic run to set this up,\n // so initialization errors will be printed to console\n setupErrorCatcher();\n\n messageHandler(data.param, messageHandlerDone, messageHandlerProgress);\n }\n});\n"]} \ No newline at end of file diff --git a/lib/worker.node/worker.js b/lib/worker.node/worker.js deleted file mode 100644 index e24ff56c..00000000 --- a/lib/worker.node/worker.js +++ /dev/null @@ -1,126 +0,0 @@ -'use strict'; - -exports.__esModule = true; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _child_process = require('child_process'); - -var _child_process2 = _interopRequireDefault(_child_process); - -var _path = require('path'); - -var _path2 = _interopRequireDefault(_path); - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var _config = require('../config'); - -var Worker = (function (_EventEmitter) { - _inherits(Worker, _EventEmitter); - - function Worker(initialRunnable) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - _classCallCheck(this, Worker); - - _EventEmitter.call(this); - - this.slave = _child_process2['default'].fork(_path2['default'].join(__dirname, 'slave.js'), [], options); - this.slave.on('message', this.handleMessage.bind(this)); - this.slave.on('error', this.handleError.bind(this)); - this.slave.on('exit', this.emit.bind(this, 'exit')); - - if (initialRunnable) { - this.run(initialRunnable); - } - } - - Worker.prototype.run = function run(toRun) { - if (typeof toRun === 'function') { - this.runMethod(toRun); - } else { - this.runScript(toRun); - } - return this; - }; - - Worker.prototype.runMethod = function runMethod(method) { - this.slave.send({ - initByMethod: true, - method: method.toString() - }); - }; - - Worker.prototype.runScript = function runScript(script) { - if (!script) { - throw new Error('Must pass a function or a script path to run().'); - } - - var prefixedScriptPath = _path2['default'].join(_config.getConfig().basepath.node, script); - - // attention: single script for node, array for browser - this.slave.send({ - initByScript: true, - script: _path2['default'].resolve(prefixedScriptPath) - }); - }; - - Worker.prototype.send = function send(param) { - this.slave.send({ - doRun: true, - param: param - }); - return this; - }; - - Worker.prototype.kill = function kill() { - this.slave.kill(); - return this; - }; - - Worker.prototype.promise = function promise() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); - }); - }; - - Worker.prototype.handleMessage = function handleMessage(message) { - if (message.error) { - var error = new Error(message.error.message); - error.stack = message.error.stack; - - this.handleError(error); - } else if (message.progress) { - this.handleProgress(message.progress); - } else { - this.emit.apply(this, ['message'].concat(message.response)); - this.emit.apply(this, ['done'].concat(message.response)); // this one is just for convenience - } - }; - - Worker.prototype.handleProgress = function handleProgress(progress) { - this.emit('progress', progress); - }; - - Worker.prototype.handleError = function handleError(error) { - if (!this.listeners('error', true)) { - console.error(error.stack || error); // eslint-disable-line no-console - } - this.emit('error', error); - }; - - return Worker; -})(_eventemitter32['default']); - -exports['default'] = Worker; -module.exports = exports['default']; -//# sourceMappingURL=worker.js.map diff --git a/lib/worker.node/worker.js.map b/lib/worker.node/worker.js.map deleted file mode 100644 index 8aed3cf3..00000000 --- a/lib/worker.node/worker.js.map +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AAC;KACzB,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;AAC3B,UAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;KACvC,MAAM;AACL,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,SAAS,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;AAC1C,UAAI,CAAC,IAAI,MAAA,CAAT,IAAI,GAAM,MAAM,SAAK,OAAO,CAAC,QAAQ,EAAC,CAAC;KACxC;GACF;;AA3EkB,QAAM,WA6EzB,cAAc,GAAA,wBAAC,QAAQ,EAAE;AACvB,QAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;GACjC;;AA/EkB,QAAM,WAiFzB,WAAW,GAAA,qBAAC,KAAK,EAAE;AACjB,QAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AAClC,aAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;KACrC;AACD,QAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;GAC3B;;SAtFkB,MAAM;;;qBAAN,MAAM","file":"worker.js","sourcesContent":["import child from 'child_process';\nimport path from 'path';\nimport EventEmitter from 'eventemitter3';\n\nimport { getConfig } from '../config';\n\n\nexport default class Worker extends EventEmitter {\n constructor(initialRunnable, options = {}) {\n super();\n\n this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options);\n this.slave.on('message', this.handleMessage.bind(this));\n this.slave.on('error', this.handleError.bind(this));\n this.slave.on('exit', this.emit.bind(this, 'exit'));\n\n if (initialRunnable) {\n this.run(initialRunnable);\n }\n }\n\n run(toRun) {\n if (typeof toRun === 'function') {\n this.runMethod(toRun);\n } else {\n this.runScript(toRun);\n }\n return this;\n }\n\n runMethod(method) {\n this.slave.send({\n initByMethod : true,\n method : method.toString()\n });\n }\n\n runScript(script) {\n if (!script) { throw new Error('Must pass a function or a script path to run().'); }\n\n const prefixedScriptPath = path.join(getConfig().basepath.node, script);\n\n // attention: single script for node, array for browser\n this.slave.send({\n initByScript : true,\n script : path.resolve(prefixedScriptPath)\n });\n }\n\n send(param) {\n this.slave.send({\n doRun : true,\n param\n });\n return this;\n }\n\n kill() {\n this.slave.kill();\n return this;\n }\n\n promise() {\n return new Promise((resolve, reject) => {\n this\n .once('message', resolve)\n .once('error', reject);\n });\n }\n\n handleMessage(message) {\n if (message.error) {\n const error = new Error(message.error.message);\n error.stack = message.error.stack;\n\n this.handleError(error);\n } else if (message.progress) {\n this.handleProgress(message.progress);\n } else {\n this.emit('message', ...message.response);\n this.emit('done', ...message.response); // this one is just for convenience\n }\n }\n\n handleProgress(progress) {\n this.emit('progress', progress);\n }\n\n handleError(error) {\n if (!this.listeners('error', true)) {\n console.error(error.stack || error); // eslint-disable-line no-console\n }\n this.emit('error', error);\n }\n}\n"]} \ No newline at end of file From 1b67ccc1a7d37807144872e14b940e5963bf37f7 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 12:12:50 +0100 Subject: [PATCH 137/224] Commit updated dist/ files --- dist/threads.browser.js | 13 ++++++++++++- dist/threads.browser.min.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 36249b62..67b48815 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -203,7 +203,18 @@ var Worker = (function (_EventEmitter) { var _this = this; return new Promise(function (resolve, reject) { - _this.once('message', resolve).once('error', reject); + var resolved = undefined, + rejected = undefined; + resolved = function (result) { + _this.removeListener('error', rejected); + resolve(result); + }; + rejected = function (err) { + _this.removeListener('message', resolved); + reject(err); + }; + + _this.once('message', resolved).once('error', rejected); }); }; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 3420d1b7..b55bd495 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){t.once("message",e).once("error",n)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o Date: Thu, 10 Nov 2016 12:21:21 +0100 Subject: [PATCH 138/224] Gitignore transpiled unit tests, rename test spec directory --- .gitignore | 1 + gulpfile.js | 8 +- karma.conf.js | 4 +- test/spec-src/config.spec.js | 53 ---- test/spec-src/job.spec.js | 167 ------------ test/spec-src/pool-functional.spec.js | 37 --- test/spec-src/pool.spec.js | 251 ----------------- test/spec-src/worker.spec.js | 268 ------------------ test/{spec-src => spec}/.eslintrc | 0 test/spec/config.spec.js | 64 ++--- test/spec/job.spec.js | 188 +++++++------ test/spec/pool-functional.spec.js | 45 ++-- test/spec/pool.spec.js | 374 ++++++++++++-------------- test/spec/worker.spec.js | 287 ++++++++++---------- 14 files changed, 473 insertions(+), 1274 deletions(-) delete mode 100644 test/spec-src/config.spec.js delete mode 100644 test/spec-src/job.spec.js delete mode 100644 test/spec-src/pool-functional.spec.js delete mode 100644 test/spec-src/pool.spec.js delete mode 100644 test/spec-src/worker.spec.js rename test/{spec-src => spec}/.eslintrc (100%) diff --git a/.gitignore b/.gitignore index 613e1f83..15de2a26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ lib/ node_modules/ +test/spec-build/ npm-debug.log diff --git a/gulpfile.js b/gulpfile.js index 0d23e1ec..b7ce9367 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -52,7 +52,7 @@ gulp.doneCallback = function (err) { gulp.task('lint', function() { - return gulp.src(['src/**/*.js', 'src/**/*.js.txt', 'test/spec-src/*.js']) + return gulp.src(['src/**/*.js', 'src/**/*.js.txt', 'test/spec/*.js']) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failOnError()); @@ -75,9 +75,9 @@ gulp.task('babel-lib', function() { }); gulp.task('babel-spec', function() { - return gulp.src('test/spec-src/**/*.js') + return gulp.src('test/spec/**/*.js') .pipe(babel()) - .pipe(gulp.dest('test/spec')); + .pipe(gulp.dest('test/spec-build')); }); @@ -127,7 +127,7 @@ gulp.task('test-browser-after-node', ['test-node'], function(done) { }); gulp.task('test-node', ['dist', 'babel-spec'], function() { - return gulp.src('test/spec/*.spec.js', { read: false }) + return gulp.src('test/spec-build/*.spec.js', { read: false }) .pipe(mocha()); }); diff --git a/karma.conf.js b/karma.conf.js index 834b4893..70517549 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,7 +11,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'test/spec/*.spec.js', + 'test/spec-build/*.spec.js', { pattern : 'test/thread-scripts/*.js', included : false } ], @@ -23,7 +23,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'test/spec/*.spec.js': ['browserify'] + 'test/spec-build/*.spec.js': ['browserify'] }, browserify: { diff --git a/test/spec-src/config.spec.js b/test/spec-src/config.spec.js deleted file mode 100644 index d2b2c569..00000000 --- a/test/spec-src/config.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import expect from 'expect.js'; -import { config } from '../../'; - -function cloneWithMods(obj, callback) { - const clone = JSON.parse(JSON.stringify(obj)); - callback(clone); - - return clone; -} - -describe('Config', () => { - - it('can be read', () => { - const initialConfig = config.get(); - expect(initialConfig).to.be.a('object'); - }); - - it('can override existing properties', () => { - const initialConfig = config.get(); - const newConfigFragment = { - basepath : { web : '/scripts' } - }; - - config.set(newConfigFragment); - const expectedNewConfig = cloneWithMods(initialConfig, (configObj) => { configObj.basepath.web = '/scripts'; }); - - expect(config.get()).to.eql(expectedNewConfig); - }); - - it('can set custom properties', () => { - config.set({ someUnknownProp : 'test' }); - expect(config.get().someUnknownProp).to.eql('test'); - }); - - it('prevents setting a string config to an object', () => { - expect(() => { - config.set({ - basepath : { - web : { illegal : 'object' } - } - }); - }).to.throwError(/Expected config property not to be an object: basepath.web/); - }); - - it('prevents setting an object config to a string', () => { - expect(() => { - config.set({ - basepath : 'no string allowed here' - }); - }).to.throwError(/Expected config property to be an object: basepath/); - }); - -}); diff --git a/test/spec-src/job.spec.js b/test/spec-src/job.spec.js deleted file mode 100644 index 71f32c88..00000000 --- a/test/spec-src/job.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -import expect from 'expect.js'; -import sinon from 'sinon'; -import EventEmitter from 'eventemitter3'; -import Job from '../../lib/job'; - - -const fakeThreadPromise = new Promise((resolve) => { - setTimeout(() => { - resolve(100); - }); -}); - -function noop() { - return this; -} - -function createFakeThread(response) { - const thread = new EventEmitter(); - - thread.run = noop; - thread.promise = () => fakeThreadPromise; - - if (response.error) { - thread.send = function() { - thread.emit('error', response.error); - }; - } else { - thread.send = function() { - thread.emit('message', ...response.response); - }; - } - - ['on', 'once', 'emit', 'run', 'send'] - .forEach((methodName) => { sinon.spy(thread, methodName); }); - - return thread; -} - - -describe('Job', () => { - let pool; - - beforeEach(() => { - // fake pool - pool = new EventEmitter(); - sinon.spy(pool, 'emit'); - }); - - it('can be created', () => { - const job = new Job(pool); - - expect(job.sendArgs).to.eql([]); - sinon.assert.calledOnce(pool.emit); - sinon.assert.calledWith(pool.emit, 'newJob', job); - }); - - it('throws on .run() without arguments', () => { - const job = new Job(pool); - - expect(() => { job.run(); }).to.throwError(/Cannot call \.run\(\) without arguments/); - }); - - it('throws on .send() before .run()', () => { - const job = new Job(pool); - - expect(() => { job.send(); }).to.throwError(/Cannot \.send\(\) before \.run\(\)/); - }); - - it('triggers readyToRun event on .send()', () => { - const job = new Job(pool); - sinon.spy(job, 'emit'); - - job.run(noop); - sinon.assert.neverCalledWith(job.emit, 'readyToRun'); - job.send(); - sinon.assert.calledWith(job.emit, 'readyToRun'); - }); - - it('can be executed', () => { - const thread = { - once : noop, - run : noop, - send : noop - }; - const mock = sinon.mock(thread); - - const job = new Job(pool); - const runnable = noop; - const importScripts = []; - const param = 'some data'; - const transferables = []; - - mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); - mock.expects('send').once().withArgs(param, transferables).returnsThis(); - - job - .run(runnable, importScripts) - .send(param, transferables) - .executeOn(thread); - - mock.verify(); - }); - - it('triggers done event', () => { - const thread = createFakeThread({ - response : [ { foo: 'bar' }, 'more data' ] - }); - - const job = new Job(pool); - sinon.spy(job, 'emit'); - - job - .run(noop) - .send() - .executeOn(thread); - - sinon.assert.calledWith(job.emit, 'done', { foo: 'bar' }, 'more data'); - }); - - it('triggers error event', () => { - const error = new Error('Epic fail'); - const thread = createFakeThread({ - error : error - }); - - const job = new Job(pool); - sinon.spy(job, 'emit'); - - job - .run(noop) - .send() - .executeOn(thread); - - sinon.assert.calledWith(job.emit, 'error', error); - }); - - it('proxies the promise', (done) => { - const job = new Job(pool); - const thread = createFakeThread({ - response : [ 'foo bar' ] - }); - - const promise = job - .run(noop) - .send() - .executeOn(thread) - .promise(); - - Promise - .all([promise, fakeThreadPromise]) - .then((results) => { - expect(results[0]).to.equal(results[1]); - done(); - }); - }); - - it('Creates a promise even if there is no thread', () => { - const job = new Job(pool); - - job - .run(noop) - .send(); - - expect(job.promise() instanceof Promise).to.equal(true); - }); - -}); diff --git a/test/spec-src/pool-functional.spec.js b/test/spec-src/pool-functional.spec.js deleted file mode 100644 index e849298a..00000000 --- a/test/spec-src/pool-functional.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import expect from 'expect.js'; -import { Pool } from '../../lib/'; - -describe('Pool (functional test)', () => { - const pool = new Pool(); - const jobs = [], promises = []; - - const handler = (input, done) => { - done(input); - }; - - pool.run(handler); - - it('can send data and run promisified', () => { - for (let i = 0; i < 10; i++) { - const job = pool.send(i); - if (jobs.indexOf(job) > -1) { - throw new Error('pool.send() returns the same job twice'); - } - - jobs.push(job); - promises.push(job.promise()); - } - }); - - it('responds as expected', done => { - Promise - .all(promises) - .then(responses => { - expect(responses.sort()).to.eql([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]); - done(); - }) - .catch(error => { - done(error); - }); - }); -}); diff --git a/test/spec-src/pool.spec.js b/test/spec-src/pool.spec.js deleted file mode 100644 index 78af6032..00000000 --- a/test/spec-src/pool.spec.js +++ /dev/null @@ -1,251 +0,0 @@ -import async from 'async'; -import expect from 'expect.js'; -import EventEmitter from 'eventemitter3'; -import { Pool, defaults } from '../../lib/'; - - -let spawnedFakeWorkers = 0; - -class FakeWorker extends EventEmitter { - constructor() { - super(); - spawnedFakeWorkers++; - } - - run(runnable, importScripts = []) { - this.runnable = runnable; - this.importScripts = importScripts; - return this; - } - - send(parameter, transferables = []) { - this.parameter = parameter; - this.transferables = transferables; - - setTimeout(() => { - if (parameter.error) { - this.emit('error', parameter.error); - } else { - this.emit('message', parameter); - } - }, 0); - return this; - } - - kill() { - this.emit('exit'); - return this; - } -} - -function noop() { return this; } - -function doTimes(callback, times) { - const returns = []; - - for (let index = 0; index < times; index++) { - returns.push(callback()); - } - - return returns; -} - - -describe('Pool', () => { - - const origSpawn = Pool.spawn; - const origDefaultSize = defaults.pool.size; - const fixedDefaultSize = 3; - - before(() => { - Pool.spawn = (threadCount) => { - return doTimes(() => new FakeWorker(), threadCount); - }; - defaults.pool.size = fixedDefaultSize; - }); - - beforeEach(() => { - spawnedFakeWorkers = 0; - }); - - after(() => { - Pool.spawn = origSpawn; - defaults.pool.size = origDefaultSize; - }); - - - it('can be created (w/o arguments)', () => { - const pool = new Pool(); - - expect(pool.threads.length).to.equal(fixedDefaultSize); - expect(pool.idleThreads).to.eql(pool.threads); - expect(spawnedFakeWorkers).to.equal(fixedDefaultSize); - }); - - it('can be created with arguments', () => { - const pool = new Pool(5); - - expect(pool.threads.length).to.equal(5); - expect(pool.idleThreads).to.eql(pool.threads); - expect(spawnedFakeWorkers).to.equal(5); - }); - - it('can kill', (done) => { - const pool = new Pool(5); - let killedThreads = 0; - - pool.threads.forEach(thread => { - thread.on('exit', () => { - killedThreads++; - }); - }); - - pool.killAll(); - - setTimeout(() => { - expect(killedThreads).to.equal(5); - done(); - }, 20); - }); - - it('can run jobs', (done) => { - const pool = new Pool(); - let calledJobA = 0, calledJobB = 0; - - const jobA = pool - .run(noop) - .send({ foo : 1 }); - const jobB = pool - .run(noop) - .send({ foo : 2 }); - - pool - .on('done', (job, message) => { - switch(job) { - case jobA: - calledJobA++; - expect(message).to.eql({ foo : 1 }); - break; - case jobB: - calledJobB++; - expect(message).to.eql({ foo : 2 }); - break; - default: - throw new Error('"message" event for unknown job.'); - } - }) - .on('finished', () => { - expect(calledJobA).to.equal(1); - expect(calledJobB).to.equal(1); - done(); - }); - }); - - it('can handle errors', (done) => { - let doneHandled = false, errorHandled = false; - - const pool = new Pool(); - - const jobA = pool - .run(noop) - .send({ foo : 'bar' }); - const jobB = pool - .run(noop) - .send({ error : new Error('Something went wrong.') }); - - pool - .on('done', (job, message) => { - doneHandled = true; - expect(job).to.equal(jobA); - expect(message).to.eql({ foo : 'bar' }); - }) - .on('error', (job, error) => { - errorHandled = true; - expect(job).to.equal(jobB); - expect(error.message).to.eql('Something went wrong.'); - }) - .on('finished', () => { - expect(doneHandled).to.equal(true); - expect(errorHandled).to.equal(true); - done(); - }); - }); - - it('can queue jobs', (done) => { - let calledJobA = 0, calledJobB = 0, calledJobC = 0; - let calledJobD = 0, calledJobE = 0; - const pool = new Pool(2); - - const part1 = (partDone) => { - pool - .run(noop) - .send({ foo : 1 }) - .on('done', () => { calledJobA++; }); - pool - .run(noop) - .send({ foo : 2 }) - .on('done', () => { calledJobB++; }); - pool - .run(noop) - .send({ foo : 3 }) - .on('done', () => { calledJobC++; }); - - pool.once('finished', () => { - expect(calledJobA).to.equal(1); - expect(calledJobB).to.equal(1); - expect(calledJobC).to.equal(1); - partDone(); - }); - }; - - const part2 = (partDone) => { - - pool - .run(noop) - .send({ error : new Error('Will the next job still be handled correctly?') }) - .on('error', () => { calledJobD++; }); - - pool - .run(noop) - .send({ foo : 4 }) - .on('done', () => { calledJobE++; }); - - pool.once('finished', () => { - // expectation: previous handlers have not been triggered again - expect(calledJobA).to.equal(1); - expect(calledJobB).to.equal(1); - expect(calledJobC).to.equal(1); - - expect(calledJobD).to.equal(1); - expect(calledJobE).to.equal(1); - partDone(); - }); - }; - - async.series([ - part1, part2 - ], done); - }); - - it('can run a lot of jobs', (done) => { - const pool = new Pool(3); - let calledJob = 0; - - function onDone () { - calledJob++; - } - - for (let jobIndex = 0; jobIndex < 50; jobIndex++) { - pool - .run(noop) - .send({ jobIndex }) - .on('done', onDone); - } - - pool.once('finished', () => { - expect(calledJob).to.equal(50); - done(); - }); - }); - -}); diff --git a/test/spec-src/worker.spec.js b/test/spec-src/worker.spec.js deleted file mode 100644 index bb6936c6..00000000 --- a/test/spec-src/worker.spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import async from 'async'; -import expect from 'expect.js'; -import sinon from 'sinon'; -import Worker from '../../lib/worker'; -import { config, spawn } from '../../'; - - -const env = typeof window === 'object' ? 'browser' : 'node'; - -function echoThread(param, done) { - done(param); -} - -function progressThread(param, done, progress) { - progress(0.3); - progress(0.6); - done(); -} - -function canSendAndReceive(worker, dataToSend, expectToRecv, done) { - worker - .once('message', (data) => { - expect(data).to.eql(expectToRecv); - done(); - }) - .send(dataToSend); -} - -function canSendAndReceiveEcho(worker, done) { - const testData = { foo: 'bar' }; - canSendAndReceive(worker, testData, testData, done); -} - -function expectEqualBuffers(buffer1, buffer2) { - expect(buffer2.byteLength).to.equal(buffer1.byteLength); - - for (let index = 0; index < buffer1.byteLength; index++) { - expect(buffer2[ index ]).to.equal(buffer1[ index ]); - } -} - - -describe('Worker', () => { - - before(() => { - sinon - .stub(config, 'get') - .returns({ - basepath : { - node : __dirname + '/../thread-scripts', - web : 'http://localhost:9876/base/test/thread-scripts' - } - }); - }); - - - it('can be spawned', () => { - const worker = spawn(); - - expect(worker).to.be.a('object'); - expect(worker).to.be.a(Worker); - }); - - it('can be killed', done => { - let spy; - const worker = spawn(); - - // the browser worker owns a worker, the node worker owns a slave - if (env === 'browser') { - spy = sinon.spy(worker.worker, 'terminate'); - } else { - spy = sinon.spy(worker.slave, 'kill'); - } - - worker.on('exit', () => { - expect(spy.calledOnce).to.be.ok(); - done(); - }); - worker.kill(); - }); - - it('can run method (set using spawn())', done => { - const worker = spawn(echoThread); - canSendAndReceiveEcho(worker, done); - }); - - it('can run method (set using .run())', done => { - const worker = spawn().run(echoThread); - canSendAndReceiveEcho(worker, done); - }); - - it('can run script (set using spawn())', done => { - const worker = spawn('abc-sender.js'); - canSendAndReceive(worker, null, 'abc', done); - }); - - it('can run script (set using .run())', done => { - const worker = spawn(echoThread); - canSendAndReceiveEcho(worker, done); - }); - - it('can pass more than one argument as response', done => { - const worker = spawn((input, threadDone) => { threadDone('a', 'b', 'c'); }); - worker - .send() - .on('message', (a, b, c) => { - expect(a).to.eql('a'); - expect(b).to.eql('b'); - expect(c).to.eql('c'); - worker.kill(); - done(); - }); - }); - - it('can reset thread code', done => { - const worker = spawn(); - - // .run(code), .send(data), .run(script), .send(data), .run(code), .send(data) - async.series([ - (stepDone) => { - canSendAndReceiveEcho(worker.run(echoThread), stepDone); - }, - (stepDone) => { - canSendAndReceive(worker.run('abc-sender.js'), null, 'abc', stepDone); - }, - (stepDone) => { - canSendAndReceiveEcho(worker.run(echoThread), stepDone); - } - ], done); - }); - - it('can emit error', done => { - const worker = spawn(() => { - throw new Error('Test message'); - }); - - worker.on('error', error => { - expect(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); - done(); - }); - worker.send(); - }); - - it('can promise and resolve', done => { - const promise = spawn(echoThread) - .send('foo bar') - .promise(); - - expect(promise).to.be.a(Promise); - - promise.then(response => { - expect(response).to.eql('foo bar'); - done(); - }); - }); - - it('can promise and reject', done => { - const worker = spawn(() => { - throw new Error('I fail'); - }); - const promise = worker - .send() - .promise(); - - promise.catch(error => { - expect(error.message).to.match(/^((Uncaught )?Error: )?I fail$/); - done(); - }); - }); - - it('can update progress', done => { - const progressUpdates = []; - const worker = spawn(progressThread); - - worker.on('progress', progress => { - progressUpdates.push(progress); - }); - worker.send(); - - worker.on('message', () => { - expect(progressUpdates).to.eql([ 0.3, 0.6 ]); - done(); - }); - }); - - it('does also emit "done" event', done => { - const progressUpdates = []; - const worker = spawn(progressThread); - - worker.on('progress', progress => { - progressUpdates.push(progress); - }); - worker.send(); - - worker.on('done', () => { - expect(progressUpdates).to.eql([ 0.3, 0.6 ]); - done(); - }); - }); - - - if (env === 'node') { - - it('thread code can use setTimeout, setInterval', done => { - let messageCount = 0; - - const worker = spawn() - .run((param, threadDone) => { - setTimeout(() => { - setInterval(() => { threadDone(true); }, 10); - }, 20); - }) - .send() - .on('message', () => { - messageCount++; - if (messageCount === 3) { - worker.kill(); - done(); - } - }); - }); - - } - - - if (env === 'browser') { - - it('can importScripts()', done => { - const worker = spawn() - .run(function(input, threadDone) { - this.importedEcho(input, threadDone); - }, [ 'import-me.js' ]) - .send('abc') - .on('message', (response) => { - expect(response).to.eql('abc'); - worker.kill(); - done(); - }); - }); - - it('can use transferables', function(done) { - // for some reason this test consumes extra-ordinarily much time when run on travis ci - this.timeout(6000); - - const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB - const arrayBufferClone = new Uint8Array(1024 * 2); - // need to clone, because referencing arrayBuffer will not work after .send() - - for (let index = 0; index < arrayBuffer.byteLength; index++) { - arrayBufferClone[ index ] = arrayBuffer[ index ]; - } - - const worker = spawn(). - run((input, threadDone) => { - threadDone.transfer(input, [ input.data.buffer ]); - }) - .send({ data: arrayBuffer }, [ arrayBuffer.buffer ]) - .on('message', (response) => { - expectEqualBuffers(arrayBufferClone, response.data); - - worker.kill(); - done(); - }); - }); - - } - -}); diff --git a/test/spec-src/.eslintrc b/test/spec/.eslintrc similarity index 100% rename from test/spec-src/.eslintrc rename to test/spec/.eslintrc diff --git a/test/spec/config.spec.js b/test/spec/config.spec.js index 84d3484a..d2b2c569 100644 --- a/test/spec/config.spec.js +++ b/test/spec/config.spec.js @@ -1,61 +1,53 @@ -'use strict'; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _expectJs = require('expect.js'); - -var _expectJs2 = _interopRequireDefault(_expectJs); - -var _ = require('../../'); +import expect from 'expect.js'; +import { config } from '../../'; function cloneWithMods(obj, callback) { - var clone = JSON.parse(JSON.stringify(obj)); + const clone = JSON.parse(JSON.stringify(obj)); callback(clone); return clone; } -describe('Config', function () { +describe('Config', () => { - it('can be read', function () { - var initialConfig = _.config.get(); - (0, _expectJs2['default'])(initialConfig).to.be.a('object'); + it('can be read', () => { + const initialConfig = config.get(); + expect(initialConfig).to.be.a('object'); }); - it('can override existing properties', function () { - var initialConfig = _.config.get(); - var newConfigFragment = { - basepath: { web: '/scripts' } + it('can override existing properties', () => { + const initialConfig = config.get(); + const newConfigFragment = { + basepath : { web : '/scripts' } }; - _.config.set(newConfigFragment); - var expectedNewConfig = cloneWithMods(initialConfig, function (configObj) { - configObj.basepath.web = '/scripts'; - }); + config.set(newConfigFragment); + const expectedNewConfig = cloneWithMods(initialConfig, (configObj) => { configObj.basepath.web = '/scripts'; }); - (0, _expectJs2['default'])(_.config.get()).to.eql(expectedNewConfig); + expect(config.get()).to.eql(expectedNewConfig); }); - it('can set custom properties', function () { - _.config.set({ someUnknownProp: 'test' }); - (0, _expectJs2['default'])(_.config.get().someUnknownProp).to.eql('test'); + it('can set custom properties', () => { + config.set({ someUnknownProp : 'test' }); + expect(config.get().someUnknownProp).to.eql('test'); }); - it('prevents setting a string config to an object', function () { - (0, _expectJs2['default'])(function () { - _.config.set({ - basepath: { - web: { illegal: 'object' } + it('prevents setting a string config to an object', () => { + expect(() => { + config.set({ + basepath : { + web : { illegal : 'object' } } }); }).to.throwError(/Expected config property not to be an object: basepath.web/); }); - it('prevents setting an object config to a string', function () { - (0, _expectJs2['default'])(function () { - _.config.set({ - basepath: 'no string allowed here' + it('prevents setting an object config to a string', () => { + expect(() => { + config.set({ + basepath : 'no string allowed here' }); }).to.throwError(/Expected config property to be an object: basepath/); }); -}); \ No newline at end of file + +}); diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 193697e6..71f32c88 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -1,27 +1,11 @@ -'use strict'; +import expect from 'expect.js'; +import sinon from 'sinon'; +import EventEmitter from 'eventemitter3'; +import Job from '../../lib/job'; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } - -var _expectJs = require('expect.js'); - -var _expectJs2 = _interopRequireDefault(_expectJs); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var _libJob = require('../../lib/job'); - -var _libJob2 = _interopRequireDefault(_libJob); - -var fakeThreadPromise = new Promise(function (resolve) { - setTimeout(function () { +const fakeThreadPromise = new Promise((resolve) => { + setTimeout(() => { resolve(100); }); }); @@ -31,141 +15,153 @@ function noop() { } function createFakeThread(response) { - var thread = new _eventemitter32['default'](); + const thread = new EventEmitter(); thread.run = noop; - thread.promise = function () { - return fakeThreadPromise; - }; + thread.promise = () => fakeThreadPromise; if (response.error) { - thread.send = function () { + thread.send = function() { thread.emit('error', response.error); }; } else { - thread.send = function () { - thread.emit.apply(thread, ['message'].concat(_toConsumableArray(response.response))); + thread.send = function() { + thread.emit('message', ...response.response); }; } - ['on', 'once', 'emit', 'run', 'send'].forEach(function (methodName) { - _sinon2['default'].spy(thread, methodName); - }); + ['on', 'once', 'emit', 'run', 'send'] + .forEach((methodName) => { sinon.spy(thread, methodName); }); return thread; } -describe('Job', function () { - var pool = undefined; - beforeEach(function () { +describe('Job', () => { + let pool; + + beforeEach(() => { // fake pool - pool = new _eventemitter32['default'](); - _sinon2['default'].spy(pool, 'emit'); + pool = new EventEmitter(); + sinon.spy(pool, 'emit'); }); - it('can be created', function () { - var job = new _libJob2['default'](pool); + it('can be created', () => { + const job = new Job(pool); - (0, _expectJs2['default'])(job.sendArgs).to.eql([]); - _sinon2['default'].assert.calledOnce(pool.emit); - _sinon2['default'].assert.calledWith(pool.emit, 'newJob', job); + expect(job.sendArgs).to.eql([]); + sinon.assert.calledOnce(pool.emit); + sinon.assert.calledWith(pool.emit, 'newJob', job); }); - it('throws on .run() without arguments', function () { - var job = new _libJob2['default'](pool); + it('throws on .run() without arguments', () => { + const job = new Job(pool); - (0, _expectJs2['default'])(function () { - job.run(); - }).to.throwError(/Cannot call \.run\(\) without arguments/); + expect(() => { job.run(); }).to.throwError(/Cannot call \.run\(\) without arguments/); }); - it('throws on .send() before .run()', function () { - var job = new _libJob2['default'](pool); + it('throws on .send() before .run()', () => { + const job = new Job(pool); - (0, _expectJs2['default'])(function () { - job.send(); - }).to.throwError(/Cannot \.send\(\) before \.run\(\)/); + expect(() => { job.send(); }).to.throwError(/Cannot \.send\(\) before \.run\(\)/); }); - it('triggers readyToRun event on .send()', function () { - var job = new _libJob2['default'](pool); - _sinon2['default'].spy(job, 'emit'); + it('triggers readyToRun event on .send()', () => { + const job = new Job(pool); + sinon.spy(job, 'emit'); job.run(noop); - _sinon2['default'].assert.neverCalledWith(job.emit, 'readyToRun'); + sinon.assert.neverCalledWith(job.emit, 'readyToRun'); job.send(); - _sinon2['default'].assert.calledWith(job.emit, 'readyToRun'); + sinon.assert.calledWith(job.emit, 'readyToRun'); }); - it('can be executed', function () { - var thread = { - once: noop, - run: noop, - send: noop + it('can be executed', () => { + const thread = { + once : noop, + run : noop, + send : noop }; - var mock = _sinon2['default'].mock(thread); + const mock = sinon.mock(thread); - var job = new _libJob2['default'](pool); - var runnable = noop; - var importScripts = []; - var param = 'some data'; - var transferables = []; + const job = new Job(pool); + const runnable = noop; + const importScripts = []; + const param = 'some data'; + const transferables = []; mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); mock.expects('send').once().withArgs(param, transferables).returnsThis(); - job.run(runnable, importScripts).send(param, transferables).executeOn(thread); + job + .run(runnable, importScripts) + .send(param, transferables) + .executeOn(thread); mock.verify(); }); - it('triggers done event', function () { - var thread = createFakeThread({ - response: [{ foo: 'bar' }, 'more data'] + it('triggers done event', () => { + const thread = createFakeThread({ + response : [ { foo: 'bar' }, 'more data' ] }); - var job = new _libJob2['default'](pool); - _sinon2['default'].spy(job, 'emit'); + const job = new Job(pool); + sinon.spy(job, 'emit'); - job.run(noop).send().executeOn(thread); + job + .run(noop) + .send() + .executeOn(thread); - _sinon2['default'].assert.calledWith(job.emit, 'done', { foo: 'bar' }, 'more data'); + sinon.assert.calledWith(job.emit, 'done', { foo: 'bar' }, 'more data'); }); - it('triggers error event', function () { - var error = new Error('Epic fail'); - var thread = createFakeThread({ - error: error + it('triggers error event', () => { + const error = new Error('Epic fail'); + const thread = createFakeThread({ + error : error }); - var job = new _libJob2['default'](pool); - _sinon2['default'].spy(job, 'emit'); + const job = new Job(pool); + sinon.spy(job, 'emit'); - job.run(noop).send().executeOn(thread); + job + .run(noop) + .send() + .executeOn(thread); - _sinon2['default'].assert.calledWith(job.emit, 'error', error); + sinon.assert.calledWith(job.emit, 'error', error); }); - it('proxies the promise', function (done) { - var job = new _libJob2['default'](pool); - var thread = createFakeThread({ - response: ['foo bar'] + it('proxies the promise', (done) => { + const job = new Job(pool); + const thread = createFakeThread({ + response : [ 'foo bar' ] }); - var promise = job.run(noop).send().executeOn(thread).promise(); + const promise = job + .run(noop) + .send() + .executeOn(thread) + .promise(); - Promise.all([promise, fakeThreadPromise]).then(function (results) { - (0, _expectJs2['default'])(results[0]).to.equal(results[1]); + Promise + .all([promise, fakeThreadPromise]) + .then((results) => { + expect(results[0]).to.equal(results[1]); done(); }); }); - it('Creates a promise even if there is no thread', function () { - var job = new _libJob2['default'](pool); + it('Creates a promise even if there is no thread', () => { + const job = new Job(pool); - job.run(noop).send(); + job + .run(noop) + .send(); - (0, _expectJs2['default'])(job.promise() instanceof Promise).to.equal(true); + expect(job.promise() instanceof Promise).to.equal(true); }); -}); \ No newline at end of file + +}); diff --git a/test/spec/pool-functional.spec.js b/test/spec/pool-functional.spec.js index 05352d01..e849298a 100644 --- a/test/spec/pool-functional.spec.js +++ b/test/spec/pool-functional.spec.js @@ -1,27 +1,19 @@ -'use strict'; +import expect from 'expect.js'; +import { Pool } from '../../lib/'; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +describe('Pool (functional test)', () => { + const pool = new Pool(); + const jobs = [], promises = []; -var _expectJs = require('expect.js'); - -var _expectJs2 = _interopRequireDefault(_expectJs); - -var _lib = require('../../lib/'); - -describe('Pool (functional test)', function () { - var pool = new _lib.Pool(); - var jobs = [], - promises = []; - - var handler = function handler(input, done) { + const handler = (input, done) => { done(input); }; pool.run(handler); - it('can send data and run promisified', function () { - for (var i = 0; i < 10; i++) { - var job = pool.send(i); + it('can send data and run promisified', () => { + for (let i = 0; i < 10; i++) { + const job = pool.send(i); if (jobs.indexOf(job) > -1) { throw new Error('pool.send() returns the same job twice'); } @@ -31,12 +23,15 @@ describe('Pool (functional test)', function () { } }); - it('responds as expected', function (done) { - Promise.all(promises).then(function (responses) { - (0, _expectJs2['default'])(responses.sort()).to.eql([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); - done(); - })['catch'](function (error) { - done(error); - }); + it('responds as expected', done => { + Promise + .all(promises) + .then(responses => { + expect(responses.sort()).to.eql([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]); + done(); + }) + .catch(error => { + done(error); + }); }); -}); \ No newline at end of file +}); diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 30fe3343..78af6032 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -1,271 +1,251 @@ -'use strict'; +import async from 'async'; +import expect from 'expect.js'; +import EventEmitter from 'eventemitter3'; +import { Pool, defaults } from '../../lib/'; -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; +let spawnedFakeWorkers = 0; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _async = require('async'); - -var _async2 = _interopRequireDefault(_async); - -var _expectJs = require('expect.js'); - -var _expectJs2 = _interopRequireDefault(_expectJs); - -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); - -var _lib = require('../../lib/'); - -var spawnedFakeWorkers = 0; - -var FakeWorker = (function (_EventEmitter) { - _inherits(FakeWorker, _EventEmitter); - - function FakeWorker() { - _classCallCheck(this, FakeWorker); - - _get(Object.getPrototypeOf(FakeWorker.prototype), 'constructor', this).call(this); +class FakeWorker extends EventEmitter { + constructor() { + super(); spawnedFakeWorkers++; } - _createClass(FakeWorker, [{ - key: 'run', - value: function run(runnable) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.runnable = runnable; - this.importScripts = importScripts; - return this; - } - }, { - key: 'send', - value: function send(parameter) { - var _this = this; - - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - this.parameter = parameter; - this.transferables = transferables; + run(runnable, importScripts = []) { + this.runnable = runnable; + this.importScripts = importScripts; + return this; + } - setTimeout(function () { - if (parameter.error) { - _this.emit('error', parameter.error); - } else { - _this.emit('message', parameter); - } - }, 0); - return this; - } - }, { - key: 'kill', - value: function kill() { - this.emit('exit'); - return this; - } - }]); + send(parameter, transferables = []) { + this.parameter = parameter; + this.transferables = transferables; - return FakeWorker; -})(_eventemitter32['default']); + setTimeout(() => { + if (parameter.error) { + this.emit('error', parameter.error); + } else { + this.emit('message', parameter); + } + }, 0); + return this; + } -function noop() { - return this; + kill() { + this.emit('exit'); + return this; + } } +function noop() { return this; } + function doTimes(callback, times) { - var returns = []; + const returns = []; - for (var index = 0; index < times; index++) { + for (let index = 0; index < times; index++) { returns.push(callback()); } return returns; } -describe('Pool', function () { - var origSpawn = _lib.Pool.spawn; - var origDefaultSize = _lib.defaults.pool.size; - var fixedDefaultSize = 3; +describe('Pool', () => { + + const origSpawn = Pool.spawn; + const origDefaultSize = defaults.pool.size; + const fixedDefaultSize = 3; - before(function () { - _lib.Pool.spawn = function (threadCount) { - return doTimes(function () { - return new FakeWorker(); - }, threadCount); + before(() => { + Pool.spawn = (threadCount) => { + return doTimes(() => new FakeWorker(), threadCount); }; - _lib.defaults.pool.size = fixedDefaultSize; + defaults.pool.size = fixedDefaultSize; }); - beforeEach(function () { + beforeEach(() => { spawnedFakeWorkers = 0; }); - after(function () { - _lib.Pool.spawn = origSpawn; - _lib.defaults.pool.size = origDefaultSize; + after(() => { + Pool.spawn = origSpawn; + defaults.pool.size = origDefaultSize; }); - it('can be created (w/o arguments)', function () { - var pool = new _lib.Pool(); - (0, _expectJs2['default'])(pool.threads.length).to.equal(fixedDefaultSize); - (0, _expectJs2['default'])(pool.idleThreads).to.eql(pool.threads); - (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(fixedDefaultSize); + it('can be created (w/o arguments)', () => { + const pool = new Pool(); + + expect(pool.threads.length).to.equal(fixedDefaultSize); + expect(pool.idleThreads).to.eql(pool.threads); + expect(spawnedFakeWorkers).to.equal(fixedDefaultSize); }); - it('can be created with arguments', function () { - var pool = new _lib.Pool(5); + it('can be created with arguments', () => { + const pool = new Pool(5); - (0, _expectJs2['default'])(pool.threads.length).to.equal(5); - (0, _expectJs2['default'])(pool.idleThreads).to.eql(pool.threads); - (0, _expectJs2['default'])(spawnedFakeWorkers).to.equal(5); + expect(pool.threads.length).to.equal(5); + expect(pool.idleThreads).to.eql(pool.threads); + expect(spawnedFakeWorkers).to.equal(5); }); - it('can kill', function (done) { - var pool = new _lib.Pool(5); - var killedThreads = 0; + it('can kill', (done) => { + const pool = new Pool(5); + let killedThreads = 0; - pool.threads.forEach(function (thread) { - thread.on('exit', function () { + pool.threads.forEach(thread => { + thread.on('exit', () => { killedThreads++; }); }); pool.killAll(); - setTimeout(function () { - (0, _expectJs2['default'])(killedThreads).to.equal(5); + setTimeout(() => { + expect(killedThreads).to.equal(5); done(); }, 20); }); - it('can run jobs', function (done) { - var pool = new _lib.Pool(); - var calledJobA = 0, - calledJobB = 0; - - var jobA = pool.run(noop).send({ foo: 1 }); - var jobB = pool.run(noop).send({ foo: 2 }); - - pool.on('done', function (job, message) { - switch (job) { - case jobA: - calledJobA++; - (0, _expectJs2['default'])(message).to.eql({ foo: 1 }); - break; - case jobB: - calledJobB++; - (0, _expectJs2['default'])(message).to.eql({ foo: 2 }); - break; - default: - throw new Error('"message" event for unknown job.'); - } - }).on('finished', function () { - (0, _expectJs2['default'])(calledJobA).to.equal(1); - (0, _expectJs2['default'])(calledJobB).to.equal(1); - done(); - }); - }); - - it('can handle errors', function (done) { - var doneHandled = false, - errorHandled = false; - - var pool = new _lib.Pool(); - - var jobA = pool.run(noop).send({ foo: 'bar' }); - var jobB = pool.run(noop).send({ error: new Error('Something went wrong.') }); - - pool.on('done', function (job, message) { - doneHandled = true; - (0, _expectJs2['default'])(job).to.equal(jobA); - (0, _expectJs2['default'])(message).to.eql({ foo: 'bar' }); - }).on('error', function (job, error) { - errorHandled = true; - (0, _expectJs2['default'])(job).to.equal(jobB); - (0, _expectJs2['default'])(error.message).to.eql('Something went wrong.'); - }).on('finished', function () { - (0, _expectJs2['default'])(doneHandled).to.equal(true); - (0, _expectJs2['default'])(errorHandled).to.equal(true); - done(); - }); + it('can run jobs', (done) => { + const pool = new Pool(); + let calledJobA = 0, calledJobB = 0; + + const jobA = pool + .run(noop) + .send({ foo : 1 }); + const jobB = pool + .run(noop) + .send({ foo : 2 }); + + pool + .on('done', (job, message) => { + switch(job) { + case jobA: + calledJobA++; + expect(message).to.eql({ foo : 1 }); + break; + case jobB: + calledJobB++; + expect(message).to.eql({ foo : 2 }); + break; + default: + throw new Error('"message" event for unknown job.'); + } + }) + .on('finished', () => { + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + done(); + }); }); - it('can queue jobs', function (done) { - var calledJobA = 0, - calledJobB = 0, - calledJobC = 0; - var calledJobD = 0, - calledJobE = 0; - var pool = new _lib.Pool(2); - - var part1 = function part1(partDone) { - pool.run(noop).send({ foo: 1 }).on('done', function () { - calledJobA++; - }); - pool.run(noop).send({ foo: 2 }).on('done', function () { - calledJobB++; - }); - pool.run(noop).send({ foo: 3 }).on('done', function () { - calledJobC++; + it('can handle errors', (done) => { + let doneHandled = false, errorHandled = false; + + const pool = new Pool(); + + const jobA = pool + .run(noop) + .send({ foo : 'bar' }); + const jobB = pool + .run(noop) + .send({ error : new Error('Something went wrong.') }); + + pool + .on('done', (job, message) => { + doneHandled = true; + expect(job).to.equal(jobA); + expect(message).to.eql({ foo : 'bar' }); + }) + .on('error', (job, error) => { + errorHandled = true; + expect(job).to.equal(jobB); + expect(error.message).to.eql('Something went wrong.'); + }) + .on('finished', () => { + expect(doneHandled).to.equal(true); + expect(errorHandled).to.equal(true); + done(); }); + }); - pool.once('finished', function () { - (0, _expectJs2['default'])(calledJobA).to.equal(1); - (0, _expectJs2['default'])(calledJobB).to.equal(1); - (0, _expectJs2['default'])(calledJobC).to.equal(1); + it('can queue jobs', (done) => { + let calledJobA = 0, calledJobB = 0, calledJobC = 0; + let calledJobD = 0, calledJobE = 0; + const pool = new Pool(2); + + const part1 = (partDone) => { + pool + .run(noop) + .send({ foo : 1 }) + .on('done', () => { calledJobA++; }); + pool + .run(noop) + .send({ foo : 2 }) + .on('done', () => { calledJobB++; }); + pool + .run(noop) + .send({ foo : 3 }) + .on('done', () => { calledJobC++; }); + + pool.once('finished', () => { + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + expect(calledJobC).to.equal(1); partDone(); }); }; - var part2 = function part2(partDone) { + const part2 = (partDone) => { - pool.run(noop).send({ error: new Error('Will the next job still be handled correctly?') }).on('error', function () { - calledJobD++; - }); + pool + .run(noop) + .send({ error : new Error('Will the next job still be handled correctly?') }) + .on('error', () => { calledJobD++; }); - pool.run(noop).send({ foo: 4 }).on('done', function () { - calledJobE++; - }); + pool + .run(noop) + .send({ foo : 4 }) + .on('done', () => { calledJobE++; }); - pool.once('finished', function () { + pool.once('finished', () => { // expectation: previous handlers have not been triggered again - (0, _expectJs2['default'])(calledJobA).to.equal(1); - (0, _expectJs2['default'])(calledJobB).to.equal(1); - (0, _expectJs2['default'])(calledJobC).to.equal(1); + expect(calledJobA).to.equal(1); + expect(calledJobB).to.equal(1); + expect(calledJobC).to.equal(1); - (0, _expectJs2['default'])(calledJobD).to.equal(1); - (0, _expectJs2['default'])(calledJobE).to.equal(1); + expect(calledJobD).to.equal(1); + expect(calledJobE).to.equal(1); partDone(); }); }; - _async2['default'].series([part1, part2], done); + async.series([ + part1, part2 + ], done); }); - it('can run a lot of jobs', function (done) { - var pool = new _lib.Pool(3); - var calledJob = 0; + it('can run a lot of jobs', (done) => { + const pool = new Pool(3); + let calledJob = 0; - function onDone() { + function onDone () { calledJob++; } - for (var jobIndex = 0; jobIndex < 50; jobIndex++) { - pool.run(noop).send({ jobIndex: jobIndex }).on('done', onDone); + for (let jobIndex = 0; jobIndex < 50; jobIndex++) { + pool + .run(noop) + .send({ jobIndex }) + .on('done', onDone); } - pool.once('finished', function () { - (0, _expectJs2['default'])(calledJob).to.equal(50); + pool.once('finished', () => { + expect(calledJob).to.equal(50); done(); }); }); -}); \ No newline at end of file + +}); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 196c8e03..bb6936c6 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -1,26 +1,11 @@ -'use strict'; +import async from 'async'; +import expect from 'expect.js'; +import sinon from 'sinon'; +import Worker from '../../lib/worker'; +import { config, spawn } from '../../'; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var _async = require('async'); - -var _async2 = _interopRequireDefault(_async); - -var _expectJs = require('expect.js'); - -var _expectJs2 = _interopRequireDefault(_expectJs); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _libWorker = require('../../lib/worker'); - -var _libWorker2 = _interopRequireDefault(_libWorker); - -var _ = require('../../'); - -var env = typeof window === 'object' ? 'browser' : 'node'; +const env = typeof window === 'object' ? 'browser' : 'node'; function echoThread(param, done) { done(param); @@ -33,225 +18,251 @@ function progressThread(param, done, progress) { } function canSendAndReceive(worker, dataToSend, expectToRecv, done) { - worker.once('message', function (data) { - (0, _expectJs2['default'])(data).to.eql(expectToRecv); + worker + .once('message', (data) => { + expect(data).to.eql(expectToRecv); done(); - }).send(dataToSend); + }) + .send(dataToSend); } function canSendAndReceiveEcho(worker, done) { - var testData = { foo: 'bar' }; + const testData = { foo: 'bar' }; canSendAndReceive(worker, testData, testData, done); } function expectEqualBuffers(buffer1, buffer2) { - (0, _expectJs2['default'])(buffer2.byteLength).to.equal(buffer1.byteLength); + expect(buffer2.byteLength).to.equal(buffer1.byteLength); - for (var index = 0; index < buffer1.byteLength; index++) { - (0, _expectJs2['default'])(buffer2[index]).to.equal(buffer1[index]); + for (let index = 0; index < buffer1.byteLength; index++) { + expect(buffer2[ index ]).to.equal(buffer1[ index ]); } } -describe('Worker', function () { - before(function () { - _sinon2['default'].stub(_.config, 'get').returns({ - basepath: { - node: __dirname + '/../thread-scripts', - web: 'http://localhost:9876/base/test/thread-scripts' - } - }); +describe('Worker', () => { + + before(() => { + sinon + .stub(config, 'get') + .returns({ + basepath : { + node : __dirname + '/../thread-scripts', + web : 'http://localhost:9876/base/test/thread-scripts' + } + }); }); - it('can be spawned', function () { - var worker = (0, _.spawn)(); - (0, _expectJs2['default'])(worker).to.be.a('object'); - (0, _expectJs2['default'])(worker).to.be.a(_libWorker2['default']); + it('can be spawned', () => { + const worker = spawn(); + + expect(worker).to.be.a('object'); + expect(worker).to.be.a(Worker); }); - it('can be killed', function (done) { - var spy = undefined; - var worker = (0, _.spawn)(); + it('can be killed', done => { + let spy; + const worker = spawn(); // the browser worker owns a worker, the node worker owns a slave if (env === 'browser') { - spy = _sinon2['default'].spy(worker.worker, 'terminate'); + spy = sinon.spy(worker.worker, 'terminate'); } else { - spy = _sinon2['default'].spy(worker.slave, 'kill'); + spy = sinon.spy(worker.slave, 'kill'); } - worker.on('exit', function () { - (0, _expectJs2['default'])(spy.calledOnce).to.be.ok(); + worker.on('exit', () => { + expect(spy.calledOnce).to.be.ok(); done(); }); worker.kill(); }); - it('can run method (set using spawn())', function (done) { - var worker = (0, _.spawn)(echoThread); + it('can run method (set using spawn())', done => { + const worker = spawn(echoThread); canSendAndReceiveEcho(worker, done); }); - it('can run method (set using .run())', function (done) { - var worker = (0, _.spawn)().run(echoThread); + it('can run method (set using .run())', done => { + const worker = spawn().run(echoThread); canSendAndReceiveEcho(worker, done); }); - it('can run script (set using spawn())', function (done) { - var worker = (0, _.spawn)('abc-sender.js'); + it('can run script (set using spawn())', done => { + const worker = spawn('abc-sender.js'); canSendAndReceive(worker, null, 'abc', done); }); - it('can run script (set using .run())', function (done) { - var worker = (0, _.spawn)(echoThread); + it('can run script (set using .run())', done => { + const worker = spawn(echoThread); canSendAndReceiveEcho(worker, done); }); - it('can pass more than one argument as response', function (done) { - var worker = (0, _.spawn)(function (input, threadDone) { - threadDone('a', 'b', 'c'); - }); - worker.send().on('message', function (a, b, c) { - (0, _expectJs2['default'])(a).to.eql('a'); - (0, _expectJs2['default'])(b).to.eql('b'); - (0, _expectJs2['default'])(c).to.eql('c'); - worker.kill(); - done(); - }); + it('can pass more than one argument as response', done => { + const worker = spawn((input, threadDone) => { threadDone('a', 'b', 'c'); }); + worker + .send() + .on('message', (a, b, c) => { + expect(a).to.eql('a'); + expect(b).to.eql('b'); + expect(c).to.eql('c'); + worker.kill(); + done(); + }); }); - it('can reset thread code', function (done) { - var worker = (0, _.spawn)(); + it('can reset thread code', done => { + const worker = spawn(); // .run(code), .send(data), .run(script), .send(data), .run(code), .send(data) - _async2['default'].series([function (stepDone) { - canSendAndReceiveEcho(worker.run(echoThread), stepDone); - }, function (stepDone) { - canSendAndReceive(worker.run('abc-sender.js'), null, 'abc', stepDone); - }, function (stepDone) { - canSendAndReceiveEcho(worker.run(echoThread), stepDone); - }], done); + async.series([ + (stepDone) => { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + }, + (stepDone) => { + canSendAndReceive(worker.run('abc-sender.js'), null, 'abc', stepDone); + }, + (stepDone) => { + canSendAndReceiveEcho(worker.run(echoThread), stepDone); + } + ], done); }); - it('can emit error', function (done) { - var worker = (0, _.spawn)(function () { + it('can emit error', done => { + const worker = spawn(() => { throw new Error('Test message'); }); - worker.on('error', function (error) { - (0, _expectJs2['default'])(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); + worker.on('error', error => { + expect(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); done(); }); worker.send(); }); - it('can promise and resolve', function (done) { - var promise = (0, _.spawn)(echoThread).send('foo bar').promise(); + it('can promise and resolve', done => { + const promise = spawn(echoThread) + .send('foo bar') + .promise(); - (0, _expectJs2['default'])(promise).to.be.a(Promise); + expect(promise).to.be.a(Promise); - promise.then(function (response) { - (0, _expectJs2['default'])(response).to.eql('foo bar'); + promise.then(response => { + expect(response).to.eql('foo bar'); done(); }); }); - it('can promise and reject', function (done) { - var worker = (0, _.spawn)(function () { + it('can promise and reject', done => { + const worker = spawn(() => { throw new Error('I fail'); }); - var promise = worker.send().promise(); + const promise = worker + .send() + .promise(); - promise['catch'](function (error) { - (0, _expectJs2['default'])(error.message).to.match(/^((Uncaught )?Error: )?I fail$/); + promise.catch(error => { + expect(error.message).to.match(/^((Uncaught )?Error: )?I fail$/); done(); }); }); - it('can update progress', function (done) { - var progressUpdates = []; - var worker = (0, _.spawn)(progressThread); + it('can update progress', done => { + const progressUpdates = []; + const worker = spawn(progressThread); - worker.on('progress', function (progress) { + worker.on('progress', progress => { progressUpdates.push(progress); }); worker.send(); - worker.on('message', function () { - (0, _expectJs2['default'])(progressUpdates).to.eql([0.3, 0.6]); + worker.on('message', () => { + expect(progressUpdates).to.eql([ 0.3, 0.6 ]); done(); }); }); - it('does also emit "done" event', function (done) { - var progressUpdates = []; - var worker = (0, _.spawn)(progressThread); + it('does also emit "done" event', done => { + const progressUpdates = []; + const worker = spawn(progressThread); - worker.on('progress', function (progress) { + worker.on('progress', progress => { progressUpdates.push(progress); }); worker.send(); - worker.on('done', function () { - (0, _expectJs2['default'])(progressUpdates).to.eql([0.3, 0.6]); + worker.on('done', () => { + expect(progressUpdates).to.eql([ 0.3, 0.6 ]); done(); }); }); + if (env === 'node') { - it('thread code can use setTimeout, setInterval', function (done) { - var messageCount = 0; - - var worker = (0, _.spawn)().run(function (param, threadDone) { - setTimeout(function () { - setInterval(function () { - threadDone(true); - }, 10); - }, 20); - }).send().on('message', function () { - messageCount++; - if (messageCount === 3) { - worker.kill(); - done(); - } - }); + it('thread code can use setTimeout, setInterval', done => { + let messageCount = 0; + + const worker = spawn() + .run((param, threadDone) => { + setTimeout(() => { + setInterval(() => { threadDone(true); }, 10); + }, 20); + }) + .send() + .on('message', () => { + messageCount++; + if (messageCount === 3) { + worker.kill(); + done(); + } + }); }); + } + if (env === 'browser') { - it('can importScripts()', function (done) { - var worker = (0, _.spawn)().run(function (input, threadDone) { - this.importedEcho(input, threadDone); - }, ['import-me.js']).send('abc').on('message', function (response) { - (0, _expectJs2['default'])(response).to.eql('abc'); - worker.kill(); - done(); - }); + it('can importScripts()', done => { + const worker = spawn() + .run(function(input, threadDone) { + this.importedEcho(input, threadDone); + }, [ 'import-me.js' ]) + .send('abc') + .on('message', (response) => { + expect(response).to.eql('abc'); + worker.kill(); + done(); + }); }); - it('can use transferables', function (done) { + it('can use transferables', function(done) { // for some reason this test consumes extra-ordinarily much time when run on travis ci this.timeout(6000); - var arrayBuffer = new Uint8Array(1024 * 2); // 2 KB - var arrayBufferClone = new Uint8Array(1024 * 2); + const arrayBuffer = new Uint8Array(1024 * 2); // 2 KB + const arrayBufferClone = new Uint8Array(1024 * 2); // need to clone, because referencing arrayBuffer will not work after .send() - for (var index = 0; index < arrayBuffer.byteLength; index++) { - arrayBufferClone[index] = arrayBuffer[index]; + for (let index = 0; index < arrayBuffer.byteLength; index++) { + arrayBufferClone[ index ] = arrayBuffer[ index ]; } - var worker = (0, _.spawn)().run(function (input, threadDone) { - threadDone.transfer(input, [input.data.buffer]); - }).send({ data: arrayBuffer }, [arrayBuffer.buffer]).on('message', function (response) { - expectEqualBuffers(arrayBufferClone, response.data); + const worker = spawn(). + run((input, threadDone) => { + threadDone.transfer(input, [ input.data.buffer ]); + }) + .send({ data: arrayBuffer }, [ arrayBuffer.buffer ]) + .on('message', (response) => { + expectEqualBuffers(arrayBufferClone, response.data); - worker.kill(); - done(); - }); + worker.kill(); + done(); + }); }); + } -}); \ No newline at end of file + +}); From 4add77654b7f6cee62d53a008e78aab44e3d1575 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 12:37:38 +0100 Subject: [PATCH 139/224] Increase worker unit test timeout --- test/spec/worker.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index bb6936c6..713cdd3c 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -40,7 +40,9 @@ function expectEqualBuffers(buffer1, buffer2) { } -describe('Worker', () => { +describe('Worker', function () { + + this.timeout(4000); before(() => { sinon From 8118ffb78737a514698a8c16f5304d72e2a3345c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 12:50:17 +0100 Subject: [PATCH 140/224] Update `event-emitter` from `1.1.1` to `2.0.2` --- dist/threads.browser.js | 214 ++++++++++++++++++++---------------- dist/threads.browser.min.js | 2 +- package.json | 2 +- 3 files changed, 120 insertions(+), 98 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 67b48815..fa2a45d6 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -661,24 +661,42 @@ module.exports = "/*eslint-env worker*/\n/*global importScripts*/\n/*eslint-disa },{}],8:[function(require,module,exports){ 'use strict'; -var has = Object.prototype.hasOwnProperty; +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @api private + */ +function Events() {} // -// We store our EE objects in a plain object whose properties are event names. +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. // If `Object.create(null)` is not supported we prefix the event names with a -// `~` to make sure that the built-in object properties are not overridden or -// used as an attack vector. -// We also assume that `Object.create(null)` is available when the event name -// is an ES6 Symbol. +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. // -var prefix = typeof Object.create !== 'function' ? '~' : false; +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} /** - * Representation of a single EventEmitter function. + * Representation of a single event listener. * - * @param {Function} fn Event handler to be called. - * @param {Mixed} context Context for function execution. - * @param {Boolean} [once=false] Only emit once + * @param {Function} fn The listener function. + * @param {Mixed} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor * @api private */ function EE(fn, context, once) { @@ -688,21 +706,16 @@ function EE(fn, context, once) { } /** - * Minimal EventEmitter interface that is molded against the Node.js - * EventEmitter interface. + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. * * @constructor * @api public */ -function EventEmitter() { /* Nothing to set */ } - -/** - * Hold the assigned EventEmitters by name. - * - * @type {Object} - * @private - */ -EventEmitter.prototype._events = undefined; +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} /** * Return an array listing the events for which the emitter has registered @@ -712,13 +725,13 @@ EventEmitter.prototype._events = undefined; * @api public */ EventEmitter.prototype.eventNames = function eventNames() { - var events = this._events - , names = [] + var names = [] + , events , name; - if (!events) return names; + if (this._eventsCount === 0) return names; - for (name in events) { + for (name in (events = this._events)) { if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); } @@ -730,16 +743,16 @@ EventEmitter.prototype.eventNames = function eventNames() { }; /** - * Return a list of assigned event listeners. + * Return the listeners registered for a given event. * - * @param {String} event The events that should be listed. - * @param {Boolean} exists We only need to know if there are listeners. + * @param {String|Symbol} event The event name. + * @param {Boolean} exists Only check if there are listeners. * @returns {Array|Boolean} * @api public */ EventEmitter.prototype.listeners = function listeners(event, exists) { var evt = prefix ? prefix + event : event - , available = this._events && this._events[evt]; + , available = this._events[evt]; if (exists) return !!available; if (!available) return []; @@ -753,23 +766,23 @@ EventEmitter.prototype.listeners = function listeners(event, exists) { }; /** - * Emit an event to all registered event listeners. + * Calls each of the listeners registered for a given event. * - * @param {String} event The name of the event. - * @returns {Boolean} Indication if we've emitted an event. + * @param {String|Symbol} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. * @api public */ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; - if (!this._events || !this._events[evt]) return false; + if (!this._events[evt]) return false; var listeners = this._events[evt] , len = arguments.length , args , i; - if ('function' === typeof listeners.fn) { + if (listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); switch (len) { @@ -797,6 +810,7 @@ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { case 1: listeners[i].fn.call(listeners[i].context); break; case 2: listeners[i].fn.call(listeners[i].context, a1); break; case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; default: if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { args[j - 1] = arguments[j]; @@ -811,115 +825,118 @@ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { }; /** - * Register a new EventListener for the given event. + * Add a listener for a given event. * - * @param {String} event Name of the event. - * @param {Function} fn Callback function. - * @param {Mixed} [context=this] The context of the function. + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. * @api public */ EventEmitter.prototype.on = function on(event, fn, context) { var listener = new EE(fn, context || this) , evt = prefix ? prefix + event : event; - if (!this._events) this._events = prefix ? {} : Object.create(null); - if (!this._events[evt]) this._events[evt] = listener; - else { - if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [ - this._events[evt], listener - ]; - } + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; return this; }; /** - * Add an EventListener that's only called once. + * Add a one-time listener for a given event. * - * @param {String} event Name of the event. - * @param {Function} fn Callback function. - * @param {Mixed} [context=this] The context of the function. + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. * @api public */ EventEmitter.prototype.once = function once(event, fn, context) { var listener = new EE(fn, context || this, true) , evt = prefix ? prefix + event : event; - if (!this._events) this._events = prefix ? {} : Object.create(null); - if (!this._events[evt]) this._events[evt] = listener; - else { - if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [ - this._events[evt], listener - ]; - } + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; return this; }; /** - * Remove event listeners. + * Remove the listeners of a given event. * - * @param {String} event The event we want to remove. - * @param {Function} fn The listener that we need to find. - * @param {Mixed} context Only remove listeners matching this context. - * @param {Boolean} once Only remove once listeners. + * @param {String|Symbol} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {Mixed} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. * @api public */ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; - if (!this._events || !this._events[evt]) return this; + if (!this._events[evt]) return this; + if (!fn) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + return this; + } - var listeners = this._events[evt] - , events = []; + var listeners = this._events[evt]; - if (fn) { - if (listeners.fn) { + if (listeners.fn) { + if ( + listeners.fn === fn + && (!once || listeners.once) + && (!context || listeners.context === context) + ) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { if ( - listeners.fn !== fn - || (once && !listeners.once) - || (context && listeners.context !== context) + listeners[i].fn !== fn + || (once && !listeners[i].once) + || (context && listeners[i].context !== context) ) { - events.push(listeners); - } - } else { - for (var i = 0, length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn - || (once && !listeners[i].once) - || (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } + events.push(listeners[i]); } } - } - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) { - this._events[evt] = events.length === 1 ? events[0] : events; - } else { - delete this._events[evt]; + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; } return this; }; /** - * Remove all listeners or only the listeners for the specified event. + * Remove all listeners, or those of the specified event. * - * @param {String} event The event want to remove all listeners for. + * @param {String|Symbol} [event] The event name. + * @returns {EventEmitter} `this`. * @api public */ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - if (!this._events) return this; + var evt; - if (event) delete this._events[prefix ? prefix + event : event]; - else this._events = prefix ? {} : Object.create(null); + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + this._events = new Events(); + this._eventsCount = 0; + } return this; }; @@ -942,6 +959,11 @@ EventEmitter.prototype.setMaxListeners = function setMaxListeners() { // EventEmitter.prefixed = prefix; +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + // // Expose the module. // diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index b55bd495..639a14e4 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var y=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=y,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var i=Object.prototype.hasOwnProperty,s="function"!=typeof Object.create&&"~";o.prototype._events=void 0,o.prototype.eventNames=function(){var t,e=this._events,n=[];if(!e)return n;for(t in e)i.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(t,e){var n=s?s+t:t,r=this._events&&this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var v=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=v,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(){}function o(t,e,n){this.fn=t,this.context=e,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 t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)s.call(t,e)&&n.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},i.prototype.listeners=function(t,e){var n=a?a+t:t,r=this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o Date: Thu, 10 Nov 2016 12:53:14 +0100 Subject: [PATCH 141/224] Update `codeclimate-test-reporter` dev dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f41dc141..ec2beadf 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "devDependencies": { "async": "^1.4.2", "browserify": "^9.0.8", - "codeclimate-test-reporter": "^0.1.1", + "codeclimate-test-reporter": "^0.4.0", "coveralls": "^2.11.4", "expect.js": "^0.3.1", "gulp": "^3.8.11", From 104032c4a8b72cf6dddbda5fbaae9c151ebb9b3b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 12:57:18 +0100 Subject: [PATCH 142/224] Update browserify version --- dist/threads.browser.js | 66 ++++++++++++++++++------------------- dist/threads.browser.min.js | 2 +- package.json | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index fa2a45d6..343c64c0 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -10,34 +10,9 @@ exports["default"] = { } }; module.exports = exports["default"]; -//# sourceMappingURL=defaults.browser.js.map -},{}],1:[function(require,module,exports){ -/*eslint-env browser, amd, commonjs*/ -/*global module*/ - -'use strict'; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _index = require('./index'); - -var _index2 = _interopRequireDefault(_index); - -if (typeof window === 'object') { - window.thread = _index2['default']; -} -if (typeof define === 'function') { - define([], function () { - return _index2['default']; - }); -} else if (typeof module === 'object') { - module.exports = _index2['default']; -} -//# sourceMappingURL=bundle.browser.js.map - -},{"./index":3}],"./worker":[function(require,module,exports){ +},{}],"./worker":[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -258,9 +233,34 @@ var Worker = (function (_EventEmitter) { exports['default'] = Worker; module.exports = exports['default']; -//# sourceMappingURL=worker.js.map -},{"../config":2,"./slave-code-uri":6,"eventemitter3":8}],2:[function(require,module,exports){ + +},{"../config":2,"./slave-code-uri":6,"eventemitter3":8}],1:[function(require,module,exports){ +/*eslint-env browser, amd, commonjs*/ +/*global module*/ + +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _index = require('./index'); + +var _index2 = _interopRequireDefault(_index); + +if (typeof window === 'object') { + window.thread = _index2['default']; +} + +if (typeof define === 'function') { + define([], function () { + return _index2['default']; + }); +} else if (typeof module === 'object') { + module.exports = _index2['default']; +} + + +},{"./index":3}],2:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -320,7 +320,7 @@ function getConfig() { function setConfig() { return config.set.apply(config, arguments); } -//# sourceMappingURL=config.js.map + },{}],3:[function(require,module,exports){ 'use strict'; @@ -366,7 +366,7 @@ exports['default'] = { spawn: spawn, Worker: _worker2['default'] }; -//# sourceMappingURL=index.js.map + },{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(require,module,exports){ 'use strict'; @@ -459,7 +459,7 @@ var Job = (function (_EventEmitter) { exports['default'] = Job; module.exports = exports['default']; -//# sourceMappingURL=job.js.map + },{"eventemitter3":8}],5:[function(require,module,exports){ 'use strict'; @@ -617,7 +617,7 @@ Pool.spawn = function (threadCount) { return threads; }; module.exports = exports['default']; -//# sourceMappingURL=pool.js.map + },{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":8}],6:[function(require,module,exports){ 'use strict'; @@ -654,7 +654,7 @@ if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'functi exports['default'] = slaveCodeDataUri; module.exports = exports['default']; -//# sourceMappingURL=slave-code-uri.js.map + },{"./slave-code":7}],7:[function(require,module,exports){ module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"; diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 639a14e4..ed23a218 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var v=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=v,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(){}function o(t,e,n){this.fn=t,this.context=e,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 t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)s.call(t,e)&&n.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},i.prototype.listeners=function(t,e){var n=a?a+t:t,r=this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var v=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=v,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],1:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=t("./index"),i=r(o);"object"==typeof window&&(window.thread=i["default"]),"function"==typeof define?define([],function(){return i["default"]}):"object"==typeof e&&(e.exports=i["default"])},{"./index":3}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(){}function o(t,e,n){this.fn=t,this.context=e,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 t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)s.call(t,e)&&n.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},i.prototype.listeners=function(t,e){var n=a?a+t:t,r=this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o Date: Thu, 10 Nov 2016 13:01:29 +0100 Subject: [PATCH 143/224] Update gulp-eslint version --- .eslintrc | 15 ++++----------- package.json | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index e6f5d8e8..5511c8e3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,18 +1,11 @@ { - "ecmaFeatures" : { - "arrowFunctions" : true, - "blockBindings" : true, - "classes" : true, - "defaultParams" : true, - "destructuring" : true, - "jsx" : true, - "modules" : true, - "restParams" : true, - "templateStrings": true - }, "globals" : { "setTimeout" : true }, + "parserOptions": { + "ecmaVersion": "2015", + "sourceType": "module" + }, "rules" : { "global-strict" : 0, "key-spacing" : [0, { "beforeColon": false, "afterColon": true }], diff --git a/package.json b/package.json index 6769a3f1..2a5f7285 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "gulp": "^3.8.11", "gulp-babel": "^5.2.0", "gulp-concat": "^2.5.2", - "gulp-eslint": "^0.9.0", + "gulp-eslint": "^3.0.1", "gulp-mocha": "^2.1.3", "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^1.5.2", From cf31fc978ac12bab37e22a2663361854bb6b2974 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:06:39 +0100 Subject: [PATCH 144/224] Update gulp-babel version --- dist/threads.browser.js | 263 +++++++++++++++++++----------------- dist/threads.browser.min.js | 2 +- gulpfile.js | 2 +- package.json | 10 +- 4 files changed, 147 insertions(+), 130 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index 343c64c0..4ac36494 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -1,15 +1,14 @@ 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 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } + var fileName = error.filename.match(/^data:text\/javascript/) && error.filename.length > 50 ? error.filename.substr(0, 50) + '...' : error.filename; + console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console + } else { + console.error(error); // eslint-disable-line no-console + } } -var Worker = (function (_EventEmitter) { +var Worker = function (_EventEmitter) { _inherits(Worker, _EventEmitter); function Worker() { - var initialScript = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + var initialScript = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; _classCallCheck(this, Worker); - _EventEmitter.call(this); - // used by `run()` to decide if the worker must be re-initialized - this.currentRunnable = null; - this.currentImportScripts = []; + var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - this.initWorker(); - this.worker.addEventListener('message', this.handleMessage.bind(this)); - this.worker.addEventListener('error', this.handleError.bind(this)); + _this.currentRunnable = null; + _this.currentImportScripts = []; + + _this.initWorker(); + _this.worker.addEventListener('message', _this.handleMessage.bind(_this)); + _this.worker.addEventListener('error', _this.handleError.bind(_this)); if (initialScript) { - this.run(initialScript, importScripts); + _this.run(initialScript, importScripts); } + return _this; } Worker.prototype.initWorker = function initWorker() { try { - this.worker = new window.Worker(_slaveCodeUri2['default']); + this.worker = new window.Worker(_slaveCodeUri2.default); } catch (error) { - var slaveScriptUrl = _config.getConfig().fallback.slaveScriptUrl; + var slaveScriptUrl = (0, _config.getConfig)().fallback.slaveScriptUrl; if (slaveScriptUrl) { // try using the slave script file instead of the data URI - this.worker = new window.Worker(_slaveCodeUri2['default']); + this.worker = new window.Worker(_slaveCodeUri2.default); } else { // re-throw throw error; @@ -115,7 +119,7 @@ var Worker = (function (_EventEmitter) { }; Worker.prototype.run = function run(toRun) { - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; if (this.alreadyInitializedToRun(toRun, importScripts)) { // don't re-initialize with the new logic if it already has been @@ -159,7 +163,7 @@ var Worker = (function (_EventEmitter) { }; Worker.prototype.send = function send(param) { - var transferables = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + var transferables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; this.worker.postMessage({ doRun: true, @@ -175,21 +179,21 @@ var Worker = (function (_EventEmitter) { }; Worker.prototype.promise = function promise() { - var _this = this; + var _this2 = this; return new Promise(function (resolve, reject) { - var resolved = undefined, - rejected = undefined; - resolved = function (result) { - _this.removeListener('error', rejected); + var resolved = void 0, + rejected = void 0; + resolved = function resolved(result) { + _this2.removeListener('error', rejected); resolve(result); }; - rejected = function (err) { - _this.removeListener('message', resolved); + rejected = function rejected(err) { + _this2.removeListener('message', resolved); reject(err); }; - _this.once('message', resolved).once('error', rejected); + _this2.once('message', resolved).once('error', rejected); }); }; @@ -229,34 +233,33 @@ var Worker = (function (_EventEmitter) { }; return Worker; -})(_eventemitter32['default']); +}(_eventemitter2.default); -exports['default'] = Worker; -module.exports = exports['default']; +exports.default = Worker; },{"../config":2,"./slave-code-uri":6,"eventemitter3":8}],1:[function(require,module,exports){ -/*eslint-env browser, amd, commonjs*/ -/*global module*/ - 'use strict'; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*eslint-env browser, amd, commonjs*/ +/*global module*/ var _index = require('./index'); var _index2 = _interopRequireDefault(_index); -if (typeof window === 'object') { - window.thread = _index2['default']; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object') { + window.thread = _index2.default; } if (typeof define === 'function') { define([], function () { - return _index2['default']; + return _index2.default; }); -} else if (typeof module === 'object') { - module.exports = _index2['default']; +} else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') { + module.exports = _index2.default; } @@ -264,6 +267,9 @@ if (typeof define === 'function') { 'use strict'; exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + exports.getConfig = getConfig; exports.setConfig = setConfig; var configuration = { @@ -277,19 +283,19 @@ var configuration = { }; function configDeepMerge(destObj, srcObj) { - var ancestorProps = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; + var ancestorProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; Object.keys(srcObj).forEach(function (propKey) { var srcValue = srcObj[propKey]; var ancestorPropsAndThis = ancestorProps.concat([propKey]); - if (typeof srcValue === 'object') { - if (typeof destObj[propKey] !== 'undefined' && typeof destObj[propKey] !== 'object') { + if ((typeof srcValue === 'undefined' ? 'undefined' : _typeof(srcValue)) === 'object') { + if (typeof destObj[propKey] !== 'undefined' && _typeof(destObj[propKey]) !== 'object') { throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.')); } configDeepMerge(destObj[propKey], srcValue, ancestorPropsAndThis); } else { - if (typeof destObj[propKey] === 'object') { + if (_typeof(destObj[propKey]) === 'object') { throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.')); } destObj[propKey] = srcValue; @@ -303,7 +309,7 @@ var config = { }, set: function set(newConfig) { - if (typeof newConfig !== 'object') { + if ((typeof newConfig === 'undefined' ? 'undefined' : _typeof(newConfig)) !== 'object') { throw new Error('Expected config object.'); } @@ -311,8 +317,7 @@ var config = { } }; -exports['default'] = config; - +exports.default = config; function getConfig() { return config.get(); } @@ -326,10 +331,9 @@ function setConfig() { 'use strict'; exports.__esModule = true; +exports.Pool = exports.defaults = exports.config = undefined; exports.spawn = spawn; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - require('native-promise-only'); var _config = require('./config'); @@ -348,23 +352,24 @@ var _worker = require('./worker'); var _worker2 = _interopRequireDefault(_worker); -exports.config = _config2['default']; -exports.defaults = _defaults2['default']; -exports.Pool = _pool2['default']; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +exports.config = _config2.default; +exports.defaults = _defaults2.default; +exports.Pool = _pool2.default; function spawn() { - var runnable = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - var importScripts = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + var runnable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - return new _worker2['default'](runnable, importScripts); + return new _worker2.default(runnable, importScripts); } -exports['default'] = { - config: _config2['default'], - defaults: _defaults2['default'], - Pool: _pool2['default'], +exports.default = { + config: _config2.default, + defaults: _defaults2.default, + Pool: _pool2.default, spawn: spawn, - Worker: _worker2['default'] + Worker: _worker2.default }; @@ -373,30 +378,34 @@ exports['default'] = { exports.__esModule = true; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _eventemitter = require('eventemitter3'); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } +var _eventemitter2 = _interopRequireDefault(_eventemitter); -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _eventemitter3 = require('eventemitter3'); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _eventemitter32 = _interopRequireDefault(_eventemitter3); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -var Job = (function (_EventEmitter) { +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Job = function (_EventEmitter) { _inherits(Job, _EventEmitter); function Job(pool) { _classCallCheck(this, Job); - _EventEmitter.call(this); - this.pool = pool; - this.thread = null; + var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); + + _this.pool = pool; + _this.thread = null; - this.runArgs = []; - this.sendArgs = []; + _this.runArgs = []; + _this.sendArgs = []; - pool.emit('newJob', this); + pool.emit('newJob', _this); + return _this; } Job.prototype.run = function run() { @@ -439,26 +448,25 @@ var Job = (function (_EventEmitter) { }; Job.prototype.promise = function promise() { - var _this = this; + var _this2 = this; // Always return a promise return new Promise(function (resolve) { // If the thread isn't set, listen for the threadChanged event - if (!_this.thread) { - _this.once('threadChanged', function () { - resolve(_this.thread.promise()); + if (!_this2.thread) { + _this2.once('threadChanged', function () { + resolve(_this2.thread.promise()); }); } else { - resolve(_this.thread.promise()); + resolve(_this2.thread.promise()); } }); }; return Job; -})(_eventemitter32['default']); +}(_eventemitter2.default); -exports['default'] = Job; -module.exports = exports['default']; +exports.default = Job; },{"eventemitter3":8}],5:[function(require,module,exports){ @@ -466,15 +474,9 @@ module.exports = exports['default']; exports.__esModule = true; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +var _eventemitter = require('eventemitter3'); -var _eventemitter3 = require('eventemitter3'); - -var _eventemitter32 = _interopRequireDefault(_eventemitter3); +var _eventemitter2 = _interopRequireDefault(_eventemitter); var _job = require('./job'); @@ -486,26 +488,34 @@ var _defaults2 = _interopRequireDefault(_defaults); var _ = require('./'); -var Pool = (function (_EventEmitter) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Pool = function (_EventEmitter) { _inherits(Pool, _EventEmitter); function Pool(threads) { - var _this = this; - _classCallCheck(this, Pool); - _EventEmitter.call(this); - this.threads = Pool.spawn(threads || _defaults2['default'].pool.size); - this.idleThreads = this.threads.slice(); - this.jobQueue = []; - this.runArgs = []; + var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); + + _this.threads = Pool.spawn(threads || _defaults2.default.pool.size); + _this.idleThreads = _this.threads.slice(); + _this.jobQueue = []; + _this.runArgs = []; - this.on('newJob', function (job) { + _this.on('newJob', function (job) { return _this.handleNewJob(job); }); - this.on('threadAvailable', function () { + _this.on('threadAvailable', function () { return _this.dequeue(); }); + return _this; } Pool.prototype.run = function run() { @@ -522,7 +532,7 @@ var Pool = (function (_EventEmitter) { throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); } - var job = new _job2['default'](this); + var job = new _job2.default(this); job.run.apply(job, this.runArgs); return job.send.apply(job, arguments); }; @@ -603,20 +613,20 @@ var Pool = (function (_EventEmitter) { }; return Pool; -})(_eventemitter32['default']); +}(_eventemitter2.default); + +exports.default = Pool; -exports['default'] = Pool; Pool.spawn = function (threadCount) { var threads = []; for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push(_.spawn()); + threads.push((0, _.spawn)()); } return threads; }; -module.exports = exports['default']; },{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":8}],6:[function(require,module,exports){ @@ -624,20 +634,20 @@ module.exports = exports['default']; exports.__esModule = true; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _slaveCode = require('./slave-code'); var _slaveCode2 = _interopRequireDefault(_slaveCode); -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2['default']); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2.default); var createBlobURL = window.createBlobURL || window.createObjectURL; if (!createBlobURL) { - var _URL = window.URL || window.webkitURL; + var URL = window.URL || window.webkitURL; - if (_URL) { - createBlobURL = _URL.createObjectURL; + if (URL) { + createBlobURL = URL.createObjectURL; } else { throw new Error('No Blob creation implementation found.'); } @@ -645,15 +655,14 @@ if (!createBlobURL) { if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') { var blobBuilder = new window.BlobBuilder(); - blobBuilder.append(_slaveCode2['default']); + blobBuilder.append(_slaveCode2.default); slaveCodeDataUri = createBlobURL(blobBuilder.getBlob()); } else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') { - var blob = new window.Blob([_slaveCode2['default']], { type: 'text/javascript' }); + var blob = new window.Blob([_slaveCode2.default], { type: 'text/javascript' }); slaveCodeDataUri = createBlobURL(blob); } -exports['default'] = slaveCodeDataUri; -module.exports = exports['default']; +exports.default = slaveCodeDataUri; },{"./slave-code":7}],7:[function(require,module,exports){ diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index ed23a218..bf7365ee 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +1 @@ -require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?t.filename.substr(0,50)+"...":t.filename;console.error(t.message+" @"+e+":"+t.lineno)}else console.error(t)}n.__esModule=!0;var f=t("eventemitter3"),l=r(f),h=t("./slave-code-uri"),p=r(h),d=t("../config");if("object"!=typeof window.Worker&&"function"!=typeof window.Worker)throw new Error("Browser does not support web workers!");var v=function(t){function e(){var n=arguments.length<=0||void 0===arguments[0]?null:arguments[0],r=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];o(this,e),t.call(this),this.currentRunnable=null,this.currentImportScripts=[],this.initWorker(),this.worker.addEventListener("message",this.handleMessage.bind(this)),this.worker.addEventListener("error",this.handleError.bind(this)),n&&this.run(n,r)}return i(e,t),e.prototype.initWorker=function(){try{this.worker=new window.Worker(p["default"])}catch(t){var e=d.getConfig().fallback.slaveScriptUrl;if(!e)throw t;this.worker=new window.Worker(p["default"])}},e.prototype.run=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.alreadyInitializedToRun(t,e)?this:("function"==typeof t?this.runMethod(t,e):this.runScripts(t,e),this.currentRunnable=t,this.currentImportScripts=e,this)},e.prototype.runMethod=function(t,e){var n=t.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:e.map(a)})},e.prototype.runScripts=function(t,e){if(!t)throw new Error("Must pass a function or a script URL to run().");this.worker.postMessage({initByScripts:!0,scripts:e.concat([t]).map(a)})},e.prototype.send=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return this.worker.postMessage({doRun:!0,param:t},e),this},e.prototype.kill=function(){return this.worker.terminate(),this.emit("exit"),this},e.prototype.promise=function(){var t=this;return new Promise(function(e,n){var r=void 0,o=void 0;r=function(n){t.removeListener("error",o),e(n)},o=function(e){t.removeListener("message",r),n(e)},t.once("message",r).once("error",o)})},e.prototype.alreadyInitializedToRun=function(t,e){var n=this.currentRunnable===t,r=this.currentImportScripts===e||0===e.length&&0===this.currentImportScripts.length;return n&&r},e.prototype.handleMessage=function(t){if(t.data.error)this.handleError(t.data.error);else if(t.data.progress)this.handleProgress(t.data.progress);else{var e=u(t.data.response);this.emit.apply(this,["message"].concat(e)),this.emit.apply(this,["done"].concat(e))}},e.prototype.handleProgress=function(t){this.emit("progress",t)},e.prototype.handleError=function(t){this.listeners("error",!0)||c(t),t.preventDefault&&t.preventDefault(),this.emit("error",t)},e}(l["default"]);n["default"]=v,e.exports=n["default"]},{"../config":2,"./slave-code-uri":6,eventemitter3:8}],1:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=t("./index"),i=r(o);"object"==typeof window&&(window.thread=i["default"]),"function"==typeof define?define([],function(){return i["default"]}):"object"==typeof e&&(e.exports=i["default"])},{"./index":3}],2:[function(t,e,n){"use strict";function r(t,e){var n=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];Object.keys(e).forEach(function(o){var i=e[o],s=n.concat([o]);if("object"==typeof i){if("undefined"!=typeof t[o]&&"object"!=typeof t[o])throw new Error("Expected config property not to be an object: "+s.join("."));r(t[o],i,s)}else{if("object"==typeof t[o])throw new Error("Expected config property to be an object: "+s.join("."));t[o]=i}})}function o(){return a.get()}function i(){return a.set.apply(a,arguments)}n.__esModule=!0,n.getConfig=o,n.setConfig=i;var s={basepath:{node:"",web:""},fallback:{slaveScriptUrl:""}},a={get:function(){return s},set:function(t){if("object"!=typeof t)throw new Error("Expected config object.");r(s,t)}};n["default"]=a},{}],3:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0],e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return new h["default"](t,e)}n.__esModule=!0,n.spawn=o,t("native-promise-only");var i=t("./config"),s=r(i),a=t("./defaults"),u=r(a),c=t("./pool"),f=r(c),l=t("./worker"),h=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:h["default"]}},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}n.__esModule=!0;var s=t("eventemitter3"),a=r(s),u=function(t){function e(n){o(this,e),t.call(this),this.pool=n,this.thread=null,this.runArgs=[],this.sendArgs=[],n.emit("newJob",this)}return i(e,t),e.prototype.run=function(){for(var t=arguments.length,e=Array(t),n=0;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"},{}],8:[function(t,e,n){"use strict";function r(){}function o(t,e,n){this.fn=t,this.context=e,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 t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)s.call(t,e)&&n.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},i.prototype.listeners=function(t,e){var n=a?a+t:t,r=this._events[n];if(e)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o0&&t(n,u))}catch(c){i.call(new a(u),c)}}}function i(e){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=e,r.state=2,r.chain.length>0&&t(n,r))}function s(t,e,n,r){for(var o=0;o50?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 w=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(e){var t=(0,v.getConfig)().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(y["default"])}},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=f(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)||c(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h["default"]);n["default"]=w},{"../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),f=e("./pool"),c=r(f),l=e("./worker"),p=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["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),f=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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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 Date: Thu, 10 Nov 2016 13:07:09 +0100 Subject: [PATCH 145/224] Don't run tests on node 0.12, since new gulp-eslint requires node >= 4.0 threads.js should still work on 0.12, though. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8b2215b..0ddff1aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - - 0.12 - 4 - 5 - 6 From 58723d2f067f11d8ea07a45fcd93b5d0d46683df Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:09:23 +0100 Subject: [PATCH 146/224] Update gulp-mocha --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 83a9aabe..22ffa83a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "gulp-babel": "^6.1.2", "gulp-concat": "^2.5.2", "gulp-eslint": "^3.0.1", - "gulp-mocha": "^2.1.3", + "gulp-mocha": "^3.0.1", "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^1.2.0", From 05cffaff5e2549096f215052b3d6938c31507c57 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:15:16 +0100 Subject: [PATCH 147/224] Update karma, its launchers & karma-mocha --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 22ffa83a..825a177d 100644 --- a/package.json +++ b/package.json @@ -49,13 +49,13 @@ "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^1.2.0", "istanbul": "^0.4.0", - "karma": "^0.13.9", + "karma": "^1.3.0", "karma-browserify": "^4.3.0", - "karma-chrome-launcher": "^0.2.0", + "karma-chrome-launcher": "^2.0.0", "karma-expect": "^1.1.0", - "karma-firefox-launcher": "^0.1.6", - "karma-mocha": "^0.2.0", - "karma-phantomjs-launcher": "^0.2.1", + "karma-firefox-launcher": "^1.0.0", + "karma-mocha": "^1.3.0", + "karma-phantomjs-launcher": "^1.0.2", "phantomjs": "^1.9.18", "sinon": "^1.16.1", "through2": "^2.0.0", From 4f4ad38b43feed1a53f7addb49b482b673ec3c34 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:18:54 +0100 Subject: [PATCH 148/224] Update gulp-uglify --- dist/threads.browser.min.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index bf7365ee..43bf8642 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?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 w=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(e){var t=(0,v.getConfig)().fallback.slaveScriptUrl;if(!t)throw e;this.worker=new window.Worker(y["default"])}},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=f(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)||c(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h["default"]);n["default"]=w},{"../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),f=e("./pool"),c=r(f),l=e("./worker"),p=r(l);n.config=s["default"],n.defaults=u["default"],n.Pool=c["default"],n["default"]={config:s["default"],defaults:u["default"],Pool:c["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),f=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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&e(n,u))}catch(f){i.call(new a(u),f)}}}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;o50?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 w=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(y.default)}},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=f(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)||c(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h.default);n.default=w},{"../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),f=e("./pool"),c=r(f),l=e("./worker"),p=r(l);n.config=s.default,n.defaults=u.default,n.Pool=c.default,n.default={config:s.default,defaults:u.default,Pool:c.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),f=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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&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 Date: Thu, 10 Nov 2016 13:30:14 +0100 Subject: [PATCH 149/224] Add explicit mocha dev dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c99b529c..3d91fc06 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "karma-firefox-launcher": "^1.0.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", + "mocha": "^3.1.2", "phantomjs": "^1.9.18", "sinon": "^1.16.1", "through2": "^2.0.0", From cad6df725d20a2d14611feccb4d9d6916b91c64b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:41:39 +0100 Subject: [PATCH 150/224] Move changelog to CHANGELOG.md --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ README.md | 22 ++-------------------- 2 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..13fa2710 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,27 @@ +# threads.js - Changelog + +## Upcoming release + +Fixes another memory leak. Credit goes to https://github.com/ChiperSoft +Depedencies have been updated. threads.js will cannot be built and tested anymore on node 0.12. Node >= 4.0 is from now on required. The lib will still work on Node 0.12, though. +The `lib/` directory and the transpiled unit test files are now gitignored. `lib/` will of course still be published to npm. + +## 0.7.1 + +`Pool.prototype.run()` now accepts more than one parameter. See [#31](https://github.com/andywer/threads.js/pull/31). +Credit goes to https://github.com/DatenMetzgerX + +## 0.7.0 + +Fixes a critical issue that prevented thread pools from running all jobs. +Also brings some major performance improvements for browser (web worker) - based setups. + +## 0.6.1 + +Added alias for threads: Event `done` as alias for `message`. Updated README example code. +Credit goes to https://github.com/andrakis + +## 0.6.0 + +Fixes promise and async issues. `Job.clone()` has been dropped. +Credit goes to https://github.com/maysale01 diff --git a/README.md b/README.md index f9b3be2b..8f5ac561 100644 --- a/README.md +++ b/README.md @@ -341,27 +341,9 @@ config.set({ **Solution**: Pass down `__dirname` to worker and use it in `require()` (see [Issue 28](https://github.com/andywer/threads.js/issues/28#issuecomment-248505917)) -## Changelog +## Change log -### 0.7.1 - -`Pool.prototype.run()` now accepts more than one parameter. See [#31](https://github.com/andywer/threads.js/pull/31). -Credit goes to https://github.com/DatenMetzgerX - -### 0.7.0 - -Fixes a critical issue that prevented thread pools from running all jobs. -Also brings some major performance improvements for browser (web worker) - based setups. - -### 0.6.1 - -Added alias for threads: Event `done` as alias for `message`. Updated README example code. -Credit goes to https://github.com/andrakis - -### 0.6.0 - -Fixes promise and async issues. `Job.clone()` has been dropped. -Credit goes to https://github.com/maysale01 +See [CHANGELOG.md](./CHANGELOG.md). ## License From 718f00d115222c79bb27bf82b53f71e134bae8b8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:43:52 +0100 Subject: [PATCH 151/224] Fix changelog markdown (=> bulletin point list) --- CHANGELOG.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13fa2710..41f2c123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,26 +2,26 @@ ## Upcoming release -Fixes another memory leak. Credit goes to https://github.com/ChiperSoft -Depedencies have been updated. threads.js will cannot be built and tested anymore on node 0.12. Node >= 4.0 is from now on required. The lib will still work on Node 0.12, though. -The `lib/` directory and the transpiled unit test files are now gitignored. `lib/` will of course still be published to npm. +- Fixes another memory leak. Credit goes to https://github.com/ChiperSoft +- Depedencies have been updated. threads.js will cannot be built and tested anymore on node 0.12. Node >= 4.0 is from now on required. The lib will still work on Node 0.12, though. +- The `lib/` directory and the transpiled unit test files are now gitignored. `lib/` will of course still be published to npm. ## 0.7.1 -`Pool.prototype.run()` now accepts more than one parameter. See [#31](https://github.com/andywer/threads.js/pull/31). -Credit goes to https://github.com/DatenMetzgerX +- `Pool.prototype.run()` now accepts more than one parameter. See [#31](https://github.com/andywer/threads.js/pull/31). +- Credit goes to https://github.com/DatenMetzgerX ## 0.7.0 -Fixes a critical issue that prevented thread pools from running all jobs. -Also brings some major performance improvements for browser (web worker) - based setups. +- Fixes a critical issue that prevented thread pools from running all jobs. +- Also brings some major performance improvements for browser (web worker) - based setups. ## 0.6.1 -Added alias for threads: Event `done` as alias for `message`. Updated README example code. -Credit goes to https://github.com/andrakis +- Added alias for threads: Event `done` as alias for `message`. Updated README example code. +- Credit goes to https://github.com/andrakis ## 0.6.0 -Fixes promise and async issues. `Job.clone()` has been dropped. -Credit goes to https://github.com/maysale01 +- Fixes promise and async issues. `Job.clone()` has been dropped. +- Credit goes to https://github.com/maysale01 From d0c0f3e281cb8df233710860be95b075730e516e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:45:24 +0100 Subject: [PATCH 152/224] 0.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d91fc06..654653d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.7.1", + "version": "0.7.2", "keywords": [ "threads", "web worker", From ced5a76702cd4cb6fafe0331243db2d1aac65f0c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 10 Nov 2016 13:48:59 +0100 Subject: [PATCH 153/224] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f2c123..ba0e7c80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # threads.js - Changelog -## Upcoming release +## 0.7.2 - Fixes another memory leak. Credit goes to https://github.com/ChiperSoft - Depedencies have been updated. threads.js will cannot be built and tested anymore on node 0.12. Node >= 4.0 is from now on required. The lib will still work on Node 0.12, though. From 881d6caacda50c46a92dd04230349f5a036c108c Mon Sep 17 00:00:00 2001 From: Peter Kerpedjiev Date: Tue, 29 Nov 2016 14:42:40 -0500 Subject: [PATCH 154/224] Added a v in front of the version number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f5ac561..fc976f96 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ bower install --save threads ``` -(where `__VERSION__` is the library's version to use, like `0.5.3`) +(where `__VERSION__` is the library's version to use, like `v0.5.3`) ## How To From e693e6d6e27c24901d5d157e0e2a6929f341d15d Mon Sep 17 00:00:00 2001 From: Peter Kerpedjiev Date: Tue, 29 Nov 2016 14:44:24 -0500 Subject: [PATCH 155/224] Upgraded version number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc976f96..cdd912ba 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ bower install --save threads ``` -(where `__VERSION__` is the library's version to use, like `v0.5.3`) +(where `__VERSION__` is the library's version to use, like `v0.7.2`) ## How To From 998364587d5d6fc1b148f54cbbf8448ff9db00c5 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 8 Feb 2017 15:17:04 +0100 Subject: [PATCH 156/224] Add .doclets.yml --- .doclets.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .doclets.yml diff --git a/.doclets.yml b/.doclets.yml new file mode 100644 index 00000000..59adf6d8 --- /dev/null +++ b/.doclets.yml @@ -0,0 +1,3 @@ +dir: src +articles: + - Overview: README.md From 9bfb312dbe22bfd77401ab9f4f56e87b35448ce1 Mon Sep 17 00:00:00 2001 From: Greg Michalec Date: Tue, 21 Feb 2017 10:49:07 -0800 Subject: [PATCH 157/224] Fix typo in bower "main" property Change "main" property in bower.json from "dist/thread.brower.js" to correct file name "dist/threads.brower.js" --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 11431550..37d80b9e 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "threads", "version": "0.6.1", - "main": "dist/thread.browser.js", + "main": "dist/threads.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ "Andy Wermke " From 745d34ac8be02e086ea8405505b4efbcb8212c71 Mon Sep 17 00:00:00 2001 From: Mitya Kononchuk Date: Mon, 8 May 2017 18:45:06 +0200 Subject: [PATCH 158/224] Add test for unhandled promise rejection in node --- test/spec/worker.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 713cdd3c..219faeec 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -203,6 +203,18 @@ describe('Worker', function () { if (env === 'node') { + it('can emit error on unhandled promise rejection', done => { + const worker = spawn(() => { + new Promise((resolve, reject) => reject(new Error('Test message'))); + }); + + worker.on('error', error => { + expect(error.message).to.match(/^((Uncaught )?Error: )?Test message$/); + done(); + }); + worker.send(); + }); + it('thread code can use setTimeout, setInterval', done => { let messageCount = 0; From 96e62dc1ed46aa0c873d7ee1f280fce9dd36f18a Mon Sep 17 00:00:00 2001 From: Mitya Kononchuk Date: Mon, 8 May 2017 18:45:34 +0200 Subject: [PATCH 159/224] Implement it --- src/worker.node/slave.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index b354c29c..d9b907aa 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -10,11 +10,8 @@ let messageHandler = function() { function setupErrorCatcher() { if (errorCatcherInPlace) { return; } - process.on('uncaughtException', function(error) { - process.send({ - error : { message : error.message, stack : error.stack } - }); - }); + process.on('uncaughtException', messageHandlerError); + process.on('unhandledRejection', messageHandlerError); errorCatcherInPlace = true; } @@ -50,6 +47,11 @@ function messageHandlerProgress(progress) { process.send({ progress }); } +function messageHandlerError(error) { + process.send({ + error : { message : error.message, stack : error.stack } + }); +} process.on('message', function(data) { if (data.initByScript) { From 3a297e1f17477d895115e7b00bed05dd30b12ac8 Mon Sep 17 00:00:00 2001 From: Mitya Kononchuk Date: Mon, 8 May 2017 19:02:48 +0200 Subject: [PATCH 160/224] Fix indenting --- src/worker.node/slave.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index d9b907aa..703f7728 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -48,9 +48,9 @@ function messageHandlerProgress(progress) { } function messageHandlerError(error) { - process.send({ - error : { message : error.message, stack : error.stack } - }); + process.send({ + error : { message : error.message, stack : error.stack } + }); } process.on('message', function(data) { From 5b1471a92cf7592a8b75d497a12140591166178a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 10:33:38 +0200 Subject: [PATCH 161/224] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba0e7c80..8220be48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # threads.js - Changelog +## Next release + +- Trigger worker error event on unhandled promise rejection in worker [#49](https://github.com/andywer/threads.js/issues/49) +- Merged lost commits stuck in the `develop` branch [#51](https://github.com/andywer/threads.js/pull/51) + ## 0.7.2 - Fixes another memory leak. Credit goes to https://github.com/ChiperSoft From 85d933f8e651b07d94a576256f37d2afe21cd7cd Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:18:53 +0200 Subject: [PATCH 162/224] v0.7.3 --- CHANGELOG.md | 2 +- bower.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8220be48..4b5eb2f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # threads.js - Changelog -## Next release +## 0.7.3 - Trigger worker error event on unhandled promise rejection in worker [#49](https://github.com/andywer/threads.js/issues/49) - Merged lost commits stuck in the `develop` branch [#51](https://github.com/andywer/threads.js/pull/51) diff --git a/bower.json b/bower.json index 37d80b9e..91d98193 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.6.1", + "version": "0.7.3", "main": "dist/threads.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index 654653d4..f63d0861 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.7.2", + "version": "0.7.3", "keywords": [ "threads", "web worker", From ceb0eccf3ec95e874335739b5c9b1652ebe2c21b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:42:37 +0200 Subject: [PATCH 163/224] Require node 4+ for development --- gulpfile.js | 56 +++++++++++++++++++++++++-------------------------- karma.conf.js | 9 ++++----- package.json | 3 +++ 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ce32564e..5a06b0eb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,23 +1,23 @@ /*eslint-env node*/ 'use strict'; -var gulp = require('gulp'); -var babel = require('gulp-babel'); -var browserify = require('browserify'); -var concat = require('gulp-concat'); -var eslint = require('gulp-eslint'); -var karma = require('karma'); -var mocha = require('gulp-mocha'); -var path = require('path'); -var rename = require('gulp-rename'); -var source = require('vinyl-source-stream'); -var sourcemaps = require('gulp-sourcemaps'); -var through = require('through2'); -var uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const babel = require('gulp-babel'); +const browserify = require('browserify'); +const concat = require('gulp-concat'); +const eslint = require('gulp-eslint'); +const karma = require('karma'); +const mocha = require('gulp-mocha'); +const path = require('path'); +const rename = require('gulp-rename'); +const source = require('vinyl-source-stream'); +const sourcemaps = require('gulp-sourcemaps'); +const through = require('through2'); +const uglify = require('gulp-uglify'); function toStringModule() { - return through.obj(function(file, enc, done) { + return through.obj((file, enc, done) => { if (file.isBuffer()) { var newContents = 'module.exports = ' + JSON.stringify(file.contents.toString(enc)) + ';'; file.contents = new Buffer(newContents, enc); @@ -35,7 +35,7 @@ function runKarma(options, done) { } options.configFile = path.join(__dirname, '/karma.conf.js'); - new karma.Server(options, function(exitCode) { + new karma.Server(options, exitCode => { if (exitCode === 0) { done(); } else { @@ -46,12 +46,12 @@ function runKarma(options, done) { // Fix for gulp not terminating after mocha finishes -gulp.doneCallback = function (err) { - process.exit(err ? 1 : 0); // eslint-disable-line no-process-exit +gulp.doneCallback = error => { + process.exit(error ? 1 : 0); // eslint-disable-line no-process-exit }; -gulp.task('lint', function() { +gulp.task('lint', () => { return gulp.src(['src/**/*.js', 'src/**/*.js.txt', 'test/spec/*.js']) .pipe(eslint()) .pipe(eslint.format()) @@ -59,14 +59,14 @@ gulp.task('lint', function() { }); -gulp.task('copy-slave', function() { +gulp.task('copy-slave', () => { return gulp.src('src/worker.browser/slave.js.txt') .pipe(rename('slave.js')) .pipe(gulp.dest('dist/')); }); -gulp.task('babel-lib', function() { +gulp.task('babel-lib', () => { return gulp.src('src/**/*.js') .pipe(sourcemaps.init()) .pipe(babel()) @@ -74,14 +74,14 @@ gulp.task('babel-lib', function() { .pipe(gulp.dest('lib/')); }); -gulp.task('babel-spec', function() { +gulp.task('babel-spec', () => { return gulp.src('test/spec/**/*.js') .pipe(babel()) .pipe(gulp.dest('test/spec-build')); }); -gulp.task('browser-slave-module', function() { +gulp.task('browser-slave-module', () => { return gulp.src('./src/worker.browser/slave.js.txt') .pipe(toStringModule()) .pipe(rename('slave-code.js')) @@ -89,7 +89,7 @@ gulp.task('browser-slave-module', function() { }); -gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], function() { +gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], () => { return browserify() .add('./lib/bundle.browser.js') @@ -101,14 +101,14 @@ gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], function() { .pipe(gulp.dest('dist/')); }); -gulp.task('uglify-lib', ['browserify-lib'], function() { +gulp.task('uglify-lib', ['browserify-lib'], () => { return gulp.src('dist/threads.browser.js') .pipe(uglify()) .pipe(concat('threads.browser.min.js')) .pipe(gulp.dest('dist/')); }); -gulp.task('uglify-slave', ['copy-slave'], function() { +gulp.task('uglify-slave', ['copy-slave'], () => { return gulp.src('dist/slave.js') .pipe(uglify()) .pipe(concat('slave.min.js')) @@ -118,15 +118,15 @@ gulp.task('uglify-slave', ['copy-slave'], function() { gulp.task('uglify', ['uglify-lib', 'uglify-slave']); -gulp.task('test-browser', ['dist', 'babel-spec'], function(done) { +gulp.task('test-browser', ['dist', 'babel-spec'], done => { runKarma(done); }); -gulp.task('test-browser-after-node', ['test-node'], function(done) { +gulp.task('test-browser-after-node', ['test-node'], done => { runKarma(done); }); -gulp.task('test-node', ['dist', 'babel-spec'], function() { +gulp.task('test-node', ['dist', 'babel-spec'], () => { return gulp.src('test/spec-build/*.spec.js', { read: false }) .pipe(mocha()); }); diff --git a/karma.conf.js b/karma.conf.js index 70517549..82c9df23 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,6 @@ // Karma configuration -module.exports = function(config) { +module.exports = function configureKarma(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -28,10 +28,9 @@ module.exports = function(config) { browserify: { debug : true, - configure : function(bundle) { - bundle.on('prebundle', function() { - bundle - .require('./lib/worker.browser/worker.js', { expose : './worker' }) // keep the node worker out of the bundle + configure(bundle) { + bundle.on('prebundle', () => { + bundle.require('./lib/worker.browser/worker.js', { expose : './worker' }) // keep the node worker out of the bundle }); } }, diff --git a/package.json b/package.json index f63d0861..79b50f68 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "author": "Andy Wermke ", "license": "MIT", "main": "lib/index.js", + "engines": { + "node": ">= 4.0" + }, "bugs": { "url": "https://github.com/andywer/thread.js/issues" }, From b98b622079aec5b51a57a40e55cc0981b70a701d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:42:57 +0200 Subject: [PATCH 164/224] Test against latest node as well on travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0ddff1aa..1fc13024 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: - 4 - 5 - - 6 + - node # Latest env: global: From 7aa3c8baa009dd8ef4f5b920e98066168548d59c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:46:31 +0200 Subject: [PATCH 165/224] Recommended name is .eslintrc.json, use clear sincerity levels --- .eslintrc | 16 ---------------- .eslintrc.json | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 5511c8e3..00000000 --- a/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "globals" : { - "setTimeout" : true - }, - "parserOptions": { - "ecmaVersion": "2015", - "sourceType": "module" - }, - "rules" : { - "global-strict" : 0, - "key-spacing" : [0, { "beforeColon": false, "afterColon": true }], - "no-console" : 1, - "no-multi-spaces" : 0, - "quotes" : [1, "single", "avoid-escape"] - } -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..01ed968d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "globals" : { + "setTimeout" : true + }, + "parserOptions": { + "ecmaVersion": "2015", + "sourceType": "module" + }, + "rules" : { + "global-strict" : "off", + "key-spacing" : ["off", { "beforeColon": false, "afterColon": true }], + "no-console" : "warn", + "no-multi-spaces" : "off", + "quotes" : ["warn", "single", "avoid-escape"] + } +} From 4a4d0a7b017da5a27092e7d1ebfcba77ffe27518 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 16:00:37 +0200 Subject: [PATCH 166/224] Minor non-behavior-changing code improvements --- dist/threads.browser.js | 14 +++----------- dist/threads.browser.min.js | 2 +- src/config.js | 4 ++-- src/worker.browser/worker.js | 16 +++------------- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/dist/threads.browser.js b/dist/threads.browser.js index cd3fda40..e089904a 100644 --- a/dist/threads.browser.js +++ b/dist/threads.browser.js @@ -55,16 +55,8 @@ function prependScriptUrl(scriptUrl) { return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl; } -function convertToArray(input) { - var outputArray = []; - var index = 0; - - while (typeof input[index] !== 'undefined') { - outputArray.push(input[index]); - index++; - } - - return outputArray; +function argsToArray(argumentsList) { + return Array.prototype.slice.call(argumentsList); } function logError(error) { @@ -210,7 +202,7 @@ var Worker = function (_EventEmitter) { } else if (event.data.progress) { this.handleProgress(event.data.progress); } else { - var responseArgs = convertToArray(event.data.response); + var responseArgs = argsToArray(event.data.response); this.emit.apply(this, ['message'].concat(responseArgs)); this.emit.apply(this, ['done'].concat(responseArgs)); // this one is just for convenience } diff --git a/dist/threads.browser.min.js b/dist/threads.browser.min.js index 4f29c484..b7389bc2 100644 --- a/dist/threads.browser.min.js +++ b/dist/threads.browser.min.js @@ -1 +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 f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s50?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 w=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=f(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)||c(e),e.preventDefault&&e.preventDefault(),this.emit("error",e)},t}(h.default);n.default=w},{"../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),f=e("./pool"),c=r(f),l=e("./worker"),p=r(l);n.config=s.default,n.defaults=u.default,n.Pool=c.default,n.default={config:s.default,defaults:u.default,Pool:c.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),f=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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&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;o50?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 w=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=w},{"../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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&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 { - let srcValue = srcObj[ propKey ]; + const srcValue = srcObj[ propKey ]; const ancestorPropsAndThis = ancestorProps.concat([ propKey ]); if (typeof srcValue === 'object') { diff --git a/src/worker.browser/worker.js b/src/worker.browser/worker.js index 997a2dea..17841ee2 100644 --- a/src/worker.browser/worker.js +++ b/src/worker.browser/worker.js @@ -3,12 +3,10 @@ import slaveCodeDataUri from './slave-code-uri'; import { getConfig } from '../config'; - if (typeof window.Worker !== 'object' && typeof window.Worker !== 'function') { throw new Error('Browser does not support web workers!'); } - function joinPaths (path1, path2) { if (!path1 || !path2) { return path1 + path2; @@ -24,16 +22,8 @@ function prependScriptUrl(scriptUrl) { return prefix ? joinPaths(prefix, scriptUrl) : scriptUrl; } -function convertToArray(input) { - let outputArray = []; - let index = 0; - - while (typeof input[index] !== 'undefined') { - outputArray.push(input[index]); - index++; - } - - return outputArray; +function argsToArray(argumentsList) { + return Array.prototype.slice.call(argumentsList); } function logError(error) { @@ -168,7 +158,7 @@ export default class Worker extends EventEmitter { } else if (event.data.progress) { this.handleProgress(event.data.progress); } else { - const responseArgs = convertToArray(event.data.response); + const responseArgs = argsToArray(event.data.response); this.emit('message', ...responseArgs); this.emit('done', ...responseArgs); // this one is just for convenience } From d93b2822a85eb9dfb30da94f0a0a144ee7b162eb Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 16:09:45 +0200 Subject: [PATCH 167/224] Forgot to rename additional .eslintrc files --- src/worker.browser/{.eslintrc => .eslintrc.json} | 0 src/worker.node/{.eslintrc => .eslintrc.json} | 0 test/spec/{.eslintrc => .eslintrc.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/worker.browser/{.eslintrc => .eslintrc.json} (100%) rename src/worker.node/{.eslintrc => .eslintrc.json} (100%) rename test/spec/{.eslintrc => .eslintrc.json} (100%) diff --git a/src/worker.browser/.eslintrc b/src/worker.browser/.eslintrc.json similarity index 100% rename from src/worker.browser/.eslintrc rename to src/worker.browser/.eslintrc.json diff --git a/src/worker.node/.eslintrc b/src/worker.node/.eslintrc.json similarity index 100% rename from src/worker.node/.eslintrc rename to src/worker.node/.eslintrc.json diff --git a/test/spec/.eslintrc b/test/spec/.eslintrc.json similarity index 100% rename from test/spec/.eslintrc rename to test/spec/.eslintrc.json From f1398c29a748661e173f13d214fc30274f282aeb Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:26:21 +0200 Subject: [PATCH 168/224] Add prepublish script --- package.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 79b50f68..76bcabcf 100644 --- a/package.json +++ b/package.json @@ -15,20 +15,18 @@ "author": "Andy Wermke ", "license": "MIT", "main": "lib/index.js", + "scripts": { + "build": "gulp dist", + "test": "gulp test", + "prepublish": "gulp dist test" + }, "engines": { "node": ">= 4.0" }, + "repository": "andywer/thread.js", "bugs": { "url": "https://github.com/andywer/thread.js/issues" }, - "repository": { - "type": "git", - "url": "https://github.com/andywer/thread.js.git" - }, - "scripts": { - "build": "./node_modules/.bin/gulp dist", - "test": "./node_modules/.bin/gulp test" - }, "babel": { "presets": [ "es2015", From 5df3f1829864bf8a8102beda4d5f72e61eb9cd5d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 15:31:37 +0200 Subject: [PATCH 169/224] Git-ignore dist/*, change + ``` -(where `__VERSION__` is the library's version to use, like `v0.7.2`) +(where `VERSION` is the library's version to use, like `v0.7.3`) ## How To diff --git a/dist/slave.js b/dist/slave.js deleted file mode 100644 index 4d4d5dac..00000000 --- a/dist/slave.js +++ /dev/null @@ -1,60 +0,0 @@ -/*eslint-env worker*/ -/*global importScripts*/ -/*eslint-disable no-console*/ -self.module = { - exports : function() { - if (console) { console.error('No thread logic initialized.'); } - } -}; - -function handlerDone() { - var args = Array.prototype.slice.call(arguments, 0); - this.postMessage({ response : args }); -} - -function handlerProgress(progress) { - this.postMessage({ progress : progress }); -} - -function handlerDoneTransfer() { - var args = Array.prototype.slice.call(arguments); - var lastArg = args.pop(); - - if (!(lastArg instanceof Array) && this.console) { - console.error('Expected 2nd parameter of .transfer() to be an array. Got:', lastArg); - } - - this.postMessage({ response : args }, lastArg); -} - -self.onmessage = function (event) { - var scripts = event.data.scripts; - if (scripts && scripts.length > 0 && typeof importScripts !== 'function') { - throw new Error('importScripts() not supported.'); - } - - if (event.data.initByScripts) { - importScripts.apply(null, scripts); - } - - if (event.data.initByMethod) { - var method = event.data.method; - this.module.exports = Function.apply(null, method.args.concat(method.body)); - - if (scripts && scripts.length > 0) { - importScripts.apply(null, scripts); - } - } - - if (event.data.doRun) { - var handler = this.module.exports; - if (typeof handler !== 'function') { - throw new Error('Cannot run thread logic. No handler has been exported.'); - } - - var preparedHandlerDone = handlerDone.bind(this); - preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); - - handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this)); - } -}.bind(self); diff --git a/dist/slave.min.js b/dist/slave.min.js deleted file mode 100644 index 048865a0..00000000 --- a/dist/slave.min.js +++ /dev/null @@ -1 +0,0 @@ -function handlerDone(){var r=Array.prototype.slice.call(arguments,0);this.postMessage({response:r})}function handlerProgress(r){this.postMessage({progress:r})}function handlerDoneTransfer(){var r=Array.prototype.slice.call(arguments),e=r.pop();e instanceof Array||!this.console||console.error("Expected 2nd parameter of .transfer() to be an array. Got:",e),this.postMessage({response:r},e)}self.module={exports:function(){console&&console.error("No thread logic initialized.")}},self.onmessage=function(r){var e=r.data.scripts;if(e&&e.length>0&&"function"!=typeof importScripts)throw new Error("importScripts() not supported.");if(r.data.initByScripts&&importScripts.apply(null,e),r.data.initByMethod){var o=r.data.method;this.module.exports=Function.apply(null,o.args.concat(o.body)),e&&e.length>0&&importScripts.apply(null,e)}if(r.data.doRun){var t=this.module.exports;if("function"!=typeof t)throw new Error("Cannot run thread logic. No handler has been exported.");var n=handlerDone.bind(this);n.transfer=handlerDoneTransfer.bind(this),t.call(this,r.data.param,n,handlerProgress.bind(this))}}.bind(self); \ No newline at end of file diff --git a/dist/threads.browser.js b/dist/threads.browser.js deleted file mode 100644 index e089904a..00000000 --- a/dist/threads.browser.js +++ /dev/null @@ -1,1358 +0,0 @@ -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 50 ? error.filename.substr(0, 50) + '...' : error.filename; - console.error(error.message + ' @' + fileName + ':' + error.lineno); // eslint-disable-line no-console - } else { - console.error(error); // eslint-disable-line no-console - } -} - -var Worker = function (_EventEmitter) { - _inherits(Worker, _EventEmitter); - - function Worker() { - var initialScript = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - _classCallCheck(this, Worker); - - // used by `run()` to decide if the worker must be re-initialized - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - _this.currentRunnable = null; - _this.currentImportScripts = []; - - _this.initWorker(); - _this.worker.addEventListener('message', _this.handleMessage.bind(_this)); - _this.worker.addEventListener('error', _this.handleError.bind(_this)); - - if (initialScript) { - _this.run(initialScript, importScripts); - } - return _this; - } - - Worker.prototype.initWorker = function initWorker() { - try { - this.worker = new window.Worker(_slaveCodeUri2.default); - } catch (error) { - var slaveScriptUrl = (0, _config.getConfig)().fallback.slaveScriptUrl; - if (slaveScriptUrl) { - // try using the slave script file instead of the data URI - this.worker = new window.Worker(slaveScriptUrl); - } else { - // re-throw - throw error; - } - } - }; - - Worker.prototype.run = function run(toRun) { - var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - if (this.alreadyInitializedToRun(toRun, importScripts)) { - // don't re-initialize with the new logic if it already has been - return this; - } - - if (typeof toRun === 'function') { - this.runMethod(toRun, importScripts); - } else { - this.runScripts(toRun, importScripts); - } - - this.currentRunnable = toRun; - this.currentImportScripts = importScripts; - - return this; - }; - - Worker.prototype.runMethod = function runMethod(method, importScripts) { - var methodStr = method.toString(); - var args = methodStr.substring(methodStr.indexOf('(') + 1, methodStr.indexOf(')')).split(','); - var body = methodStr.substring(methodStr.indexOf('{') + 1, methodStr.lastIndexOf('}')); - - this.worker.postMessage({ - initByMethod: true, - method: { args: args, body: body }, - scripts: importScripts.map(prependScriptUrl) - }); - }; - - Worker.prototype.runScripts = function runScripts(script, importScripts) { - if (!script) { - throw new Error('Must pass a function or a script URL to run().'); - } - - // attention: array for browser, single script for node - this.worker.postMessage({ - initByScripts: true, - scripts: importScripts.concat([script]).map(prependScriptUrl) - }); - }; - - Worker.prototype.send = function send(param) { - var transferables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - this.worker.postMessage({ - doRun: true, - param: param - }, transferables); - return this; - }; - - Worker.prototype.kill = function kill() { - this.worker.terminate(); - this.emit('exit'); - return this; - }; - - Worker.prototype.promise = function promise() { - var _this2 = this; - - return new Promise(function (resolve, reject) { - var resolved = void 0, - rejected = void 0; - resolved = function resolved(result) { - _this2.removeListener('error', rejected); - resolve(result); - }; - rejected = function rejected(err) { - _this2.removeListener('message', resolved); - reject(err); - }; - - _this2.once('message', resolved).once('error', rejected); - }); - }; - - Worker.prototype.alreadyInitializedToRun = function alreadyInitializedToRun(toRun, importScripts) { - var runnablesMatch = this.currentRunnable === toRun; - var importScriptsMatch = this.currentImportScripts === importScripts || importScripts.length === 0 && this.currentImportScripts.length === 0; - - return runnablesMatch && importScriptsMatch; - }; - - Worker.prototype.handleMessage = function handleMessage(event) { - if (event.data.error) { - this.handleError(event.data.error); - } else if (event.data.progress) { - this.handleProgress(event.data.progress); - } else { - var responseArgs = argsToArray(event.data.response); - this.emit.apply(this, ['message'].concat(responseArgs)); - this.emit.apply(this, ['done'].concat(responseArgs)); // this one is just for convenience - } - }; - - Worker.prototype.handleProgress = function handleProgress(progress) { - this.emit('progress', progress); - }; - - Worker.prototype.handleError = function handleError(error) { - if (!this.listeners('error', true)) { - logError(error); - } - - if (error.preventDefault) { - error.preventDefault(); - } - - this.emit('error', error); - }; - - return Worker; -}(_eventemitter2.default); - -exports.default = Worker; - - -},{"../config":2,"./slave-code-uri":6,"eventemitter3":8}],1:[function(require,module,exports){ -'use strict'; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*eslint-env browser, amd, commonjs*/ -/*global module*/ - -var _index = require('./index'); - -var _index2 = _interopRequireDefault(_index); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object') { - window.thread = _index2.default; -} - -if (typeof define === 'function') { - define([], function () { - return _index2.default; - }); -} else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') { - module.exports = _index2.default; -} - - -},{"./index":3}],2:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -exports.getConfig = getConfig; -exports.setConfig = setConfig; -var configuration = { - basepath: { - node: '', - web: '' - }, - fallback: { - slaveScriptUrl: '' - } -}; - -function configDeepMerge(destObj, srcObj) { - var ancestorProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; - - Object.keys(srcObj).forEach(function (propKey) { - var srcValue = srcObj[propKey]; - var ancestorPropsAndThis = ancestorProps.concat([propKey]); - - if ((typeof srcValue === 'undefined' ? 'undefined' : _typeof(srcValue)) === 'object') { - if (typeof destObj[propKey] !== 'undefined' && _typeof(destObj[propKey]) !== 'object') { - throw new Error('Expected config property not to be an object: ' + ancestorPropsAndThis.join('.')); - } - configDeepMerge(destObj[propKey], srcValue, ancestorPropsAndThis); - } else { - if (_typeof(destObj[propKey]) === 'object') { - throw new Error('Expected config property to be an object: ' + ancestorPropsAndThis.join('.')); - } - destObj[propKey] = srcValue; - } - }); -} - -var config = { - get: function get() { - return configuration; - }, - - set: function set(newConfig) { - if ((typeof newConfig === 'undefined' ? 'undefined' : _typeof(newConfig)) !== 'object') { - throw new Error('Expected config object.'); - } - - configDeepMerge(configuration, newConfig); - } -}; - -exports.default = config; -function getConfig() { - return config.get(); -} - -function setConfig() { - return config.set.apply(config, arguments); -} - - -},{}],3:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.Pool = exports.defaults = exports.config = undefined; -exports.spawn = spawn; - -require('native-promise-only'); - -var _config = require('./config'); - -var _config2 = _interopRequireDefault(_config); - -var _defaults = require('./defaults'); - -var _defaults2 = _interopRequireDefault(_defaults); - -var _pool = require('./pool'); - -var _pool2 = _interopRequireDefault(_pool); - -var _worker = require('./worker'); - -var _worker2 = _interopRequireDefault(_worker); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.config = _config2.default; -exports.defaults = _defaults2.default; -exports.Pool = _pool2.default; -function spawn() { - var runnable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - var importScripts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - return new _worker2.default(runnable, importScripts); -} - -exports.default = { - config: _config2.default, - defaults: _defaults2.default, - Pool: _pool2.default, - spawn: spawn, - Worker: _worker2.default -}; - - -},{"./config":2,"./defaults":"./defaults","./pool":5,"./worker":"./worker","native-promise-only":9}],4:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Job = function (_EventEmitter) { - _inherits(Job, _EventEmitter); - - function Job(pool) { - _classCallCheck(this, Job); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - _this.pool = pool; - _this.thread = null; - - _this.runArgs = []; - _this.sendArgs = []; - - pool.emit('newJob', _this); - return _this; - } - - Job.prototype.run = function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (args.length === 0) { - throw new Error('Cannot call .run() without arguments.'); - } - - this.runArgs = args; - return this; - }; - - Job.prototype.send = function send() { - if (this.runArgs.length === 0) { - throw new Error('Cannot .send() before .run().'); - } - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - this.sendArgs = args; - - this.emit('readyToRun'); - return this; - }; - - Job.prototype.executeOn = function executeOn(thread) { - var _thread$once$once$run, _thread$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); - - this.thread = thread; - this.emit('threadChanged'); - return this; - }; - - Job.prototype.promise = function promise() { - var _this2 = this; - - // Always return a promise - return new Promise(function (resolve) { - // If the thread isn't set, listen for the threadChanged event - if (!_this2.thread) { - _this2.once('threadChanged', function () { - resolve(_this2.thread.promise()); - }); - } else { - resolve(_this2.thread.promise()); - } - }); - }; - - Job.prototype.destroy = function destroy() { - this.removeAllListeners(); - delete this.runArgs; - delete this.sendArgs; - }; - - return Job; -}(_eventemitter2.default); - -exports.default = Job; - - -},{"eventemitter3":8}],5:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _job = require('./job'); - -var _job2 = _interopRequireDefault(_job); - -var _defaults = require('./defaults'); - -var _defaults2 = _interopRequireDefault(_defaults); - -var _ = require('./'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Pool = function (_EventEmitter) { - _inherits(Pool, _EventEmitter); - - function Pool(threads) { - _classCallCheck(this, Pool); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - _this.threads = Pool.spawn(threads || _defaults2.default.pool.size); - _this.idleThreads = _this.threads.slice(); - _this.jobQueue = []; - _this.runArgs = []; - - _this.on('newJob', function (job) { - return _this.handleNewJob(job); - }); - _this.on('threadAvailable', function () { - return _this.dequeue(); - }); - return _this; - } - - Pool.prototype.run = function run() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - this.runArgs = args; - return this; - }; - - Pool.prototype.send = function send() { - var _job$run; - - if (!this.runArgs) { - throw new Error('Pool.send() called without prior Pool.run(). You need to define what to run first.'); - } - - var job = new _job2.default(this); - return (_job$run = job.run.apply(job, this.runArgs)).send.apply(_job$run, arguments); - }; - - Pool.prototype.killAll = function killAll() { - this.threads.forEach(function (thread) { - thread.kill(); - }); - }; - - Pool.prototype.queueJob = function queueJob(job) { - this.jobQueue.push(job); - this.dequeue(); - }; - - Pool.prototype.dequeue = function dequeue() { - var _this2 = this; - - if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { - return; - } - - var job = this.jobQueue.shift(); - var thread = this.idleThreads.shift(); - - job.once('done', function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return _this2.handleJobSuccess.apply(_this2, [thread, job].concat(args)); - }).once('error', function () { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - return _this2.handleJobError.apply(_this2, [thread, job].concat(args)); - }); - - job.executeOn(thread); - }; - - Pool.prototype.handleNewJob = function handleNewJob(job) { - var _this3 = this; - - job.once('readyToRun', function () { - return _this3.queueJob(job); - }); // triggered by job.send() - }; - - Pool.prototype.handleJobSuccess = function handleJobSuccess(thread, job) { - for (var _len4 = arguments.length, responseArgs = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { - responseArgs[_key4 - 2] = arguments[_key4]; - } - - this.emit.apply(this, ['done', job].concat(responseArgs)); - this.handleJobDone(thread, job); - }; - - Pool.prototype.handleJobError = function handleJobError(thread, job, error) { - this.emit('error', job, error); - this.handleJobDone(thread, job); - }; - - Pool.prototype.handleJobDone = function handleJobDone(thread, job) { - var _this4 = this; - - job.destroy(); // to prevent memory leak - this.idleThreads.push(thread); - this.emit('threadAvailable'); - - if (this.idleThreads.length === this.threads.length) { - // run deferred to give other job.on('done') handlers time to run first - setTimeout(function () { - _this4.emit('finished'); - }, 0); - } - }; - - return Pool; -}(_eventemitter2.default); - -exports.default = Pool; - - -Pool.spawn = function (threadCount) { - var threads = []; - - for (var threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push((0, _.spawn)()); - } - - return threads; -}; - - -},{"./":3,"./defaults":"./defaults","./job":4,"eventemitter3":8}],6:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _slaveCode = require('./slave-code'); - -var _slaveCode2 = _interopRequireDefault(_slaveCode); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var slaveCodeDataUri = 'data:text/javascript;charset=utf-8,' + encodeURI(_slaveCode2.default); -var createBlobURL = window.createBlobURL || window.createObjectURL; - -if (!createBlobURL) { - var URL = window.URL || window.webkitURL; - - if (URL) { - createBlobURL = URL.createObjectURL; - } else { - throw new Error('No Blob creation implementation found.'); - } -} - -if (typeof window.BlobBuilder === 'function' && typeof createBlobURL === 'function') { - var blobBuilder = new window.BlobBuilder(); - blobBuilder.append(_slaveCode2.default); - slaveCodeDataUri = createBlobURL(blobBuilder.getBlob()); -} else if (typeof window.Blob === 'function' && typeof createBlobURL === 'function') { - var blob = new window.Blob([_slaveCode2.default], { type: 'text/javascript' }); - slaveCodeDataUri = createBlobURL(blob); -} - -exports.default = slaveCodeDataUri; - - -},{"./slave-code":7}],7:[function(require,module,exports){ -module.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 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 .transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\n }\n}.bind(self);\n"; -},{}],8:[function(require,module,exports){ -'use strict'; - -var has = Object.prototype.hasOwnProperty - , prefix = '~'; - -/** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @api private - */ -function Events() {} - -// -// We try to not inherit from `Object.prototype`. In some engines creating an -// instance in this way is faster than calling `Object.create(null)` directly. -// If `Object.create(null)` is not supported we prefix the event names with a -// character to make sure that the built-in object properties are not -// overridden or used as an attack vector. -// -if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; -} - -/** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {Mixed} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @api private - */ -function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; -} - -/** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @api public - */ -function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; -} - -/** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @api public - */ -EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; -}; - -/** - * Return the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Boolean} exists Only check if there are listeners. - * @returns {Array|Boolean} - * @api public - */ -EventEmitter.prototype.listeners = function listeners(event, exists) { - var evt = prefix ? prefix + event : event - , available = this._events[evt]; - - if (exists) return !!available; - if (!available) return []; - if (available.fn) return [available.fn]; - - for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { - ee[i] = available[i].fn; - } - - return ee; -}; - -/** - * Calls each of the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @api public - */ -EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; -}; - -/** - * Add a listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.on = function on(event, fn, context) { - var listener = new EE(fn, context || this) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; -}; - -/** - * Add a one-time listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.once = function once(event, fn, context) { - var listener = new EE(fn, context || this, true) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; -}; - -/** - * Remove the listeners of a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {Mixed} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn - && (!once || listeners.once) - && (!context || listeners.context === context) - ) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn - || (once && !listeners[i].once) - || (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - - return this; -}; - -/** - * Remove all listeners, or those of the specified event. - * - * @param {String|Symbol} [event] The event name. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; -}; - -// -// Alias methods names because people roll like that. -// -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -// -// This function doesn't apply anymore. -// -EventEmitter.prototype.setMaxListeners = function setMaxListeners() { - return this; -}; - -// -// Expose the prefix. -// -EventEmitter.prefixed = prefix; - -// -// Allow `EventEmitter` to be imported as module namespace. -// -EventEmitter.EventEmitter = EventEmitter; - -// -// Expose the module. -// -if ('undefined' !== typeof module) { - module.exports = EventEmitter; -} - -},{}],9:[function(require,module,exports){ -(function (global){ -/*! Native Promise Only - v0.8.1 (c) Kyle Simpson - MIT License: http://getify.mit-license.org -*/ - -(function UMD(name,context,definition){ - // special form of UMD for polyfilling across evironments - context[name] = context[name] || definition(); - if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } - else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } -})("Promise",typeof global != "undefined" ? global : this,function DEF(){ - /*jshint validthis:true */ - "use strict"; - - var builtInProp, cycle, scheduling_queue, - ToString = Object.prototype.toString, - timer = (typeof setImmediate != "undefined") ? - function timer(fn) { return setImmediate(fn); } : - setTimeout - ; - - // dammit, IE8. - try { - Object.defineProperty({},"x",{}); - builtInProp = function builtInProp(obj,name,val,config) { - return Object.defineProperty(obj,name,{ - value: val, - writable: true, - configurable: config !== false - }); - }; - } - catch (err) { - builtInProp = function builtInProp(obj,name,val) { - obj[name] = val; - return obj; - }; - } - - // Note: using a queue instead of array for efficiency - scheduling_queue = (function Queue() { - var first, last, item; - - function Item(fn,self) { - this.fn = fn; - this.self = self; - this.next = void 0; - } - - return { - add: function add(fn,self) { - item = new Item(fn,self); - if (last) { - last.next = item; - } - else { - first = item; - } - last = item; - item = void 0; - }, - drain: function drain() { - var f = first; - first = last = cycle = void 0; - - while (f) { - f.fn.call(f.self); - f = f.next; - } - } - }; - })(); - - function schedule(fn,self) { - scheduling_queue.add(fn,self); - if (!cycle) { - cycle = timer(scheduling_queue.drain); - } - } - - // promise duck typing - function isThenable(o) { - var _then, o_type = typeof o; - - if (o != null && - ( - o_type == "object" || o_type == "function" - ) - ) { - _then = o.then; - } - return typeof _then == "function" ? _then : false; - } - - function notify() { - for (var i=0; i 0) { - schedule(notify,self); - } - } - } - catch (err) { - reject.call(new MakeDefWrapper(self),err); - } - } - - function reject(msg) { - var self = this; - - // already triggered? - if (self.triggered) { return; } - - self.triggered = true; - - // unwrap - if (self.def) { - self = self.def; - } - - self.msg = msg; - self.state = 2; - if (self.chain.length > 0) { - schedule(notify,self); - } - } - - function iteratePromises(Constructor,arr,resolver,rejecter) { - for (var idx=0; idx50?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 w=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=w},{"../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;n2?n-2:0),o=2;o.transfer() to be an array. Got:', lastArg);\n }\n\n this.postMessage({ response : args }, lastArg);\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 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 handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this));\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);o0&&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 Date: Tue, 9 May 2017 16:27:32 +0200 Subject: [PATCH 170/224] Run `gulp dist test` on publish *only* (not on npm install) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76bcabcf..13557b3b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "gulp dist", "test": "gulp test", - "prepublish": "gulp dist test" + "prepublishOnly": "gulp dist test" }, "engines": { "node": ">= 4.0" From fbfbef017fa60240cd14fd633d1e814808b95bc0 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 9 May 2017 16:45:11 +0200 Subject: [PATCH 171/224] Testing on node 4 & latest is enough --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1fc13024..175b5d8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - 4 - - 5 - node # Latest env: From 2392954dc539f83767c35d48981a3ef811b74c62 Mon Sep 17 00:00:00 2001 From: mmcardle Date: Tue, 30 May 2017 17:55:46 +0100 Subject: [PATCH 172/224] Adding progress --- src/job.js | 2 ++ test/spec/job.spec.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/job.js b/src/job.js index c79c2986..ca9e8a7e 100644 --- a/src/job.js +++ b/src/job.js @@ -35,6 +35,8 @@ export default class Job extends EventEmitter { executeOn(thread) { thread + .off('progress') + .on('progress', (e) => {this.emit('progress', e)} ) .once('message', this.emit.bind(this, 'done')) .once('error', this.emit.bind(this, 'error')) .run(...this.runArgs) diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 71f32c88..45326e27 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -80,7 +80,9 @@ describe('Job', () => { const thread = { once : noop, run : noop, - send : noop + send : noop, + off : noop, + on : noop, }; const mock = sinon.mock(thread); @@ -92,6 +94,8 @@ describe('Job', () => { mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); mock.expects('send').once().withArgs(param, transferables).returnsThis(); + mock.expects('off').once().withArgs('progress').returnsThis(); + mock.expects('on').once().withArgs('progress').returnsThis(); job .run(runnable, importScripts) From cf4540684b1674319874a25181571fca90cc61fd Mon Sep 17 00:00:00 2001 From: mmcardle Date: Thu, 1 Jun 2017 09:47:09 +0100 Subject: [PATCH 173/224] Adding onProgress Handler --- src/job.js | 7 +++++-- test/spec/job.spec.js | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/job.js b/src/job.js index ca9e8a7e..1d5b0e9d 100644 --- a/src/job.js +++ b/src/job.js @@ -33,10 +33,13 @@ export default class Job extends EventEmitter { return this; } + onProgress(progress){ + this.emit('progress', progress); + } + executeOn(thread) { thread - .off('progress') - .on('progress', (e) => {this.emit('progress', e)} ) + .on('progress', this.onProgress.bind(this)) .once('message', this.emit.bind(this, 'done')) .once('error', this.emit.bind(this, 'error')) .run(...this.runArgs) diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 45326e27..72512d48 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -81,8 +81,7 @@ describe('Job', () => { once : noop, run : noop, send : noop, - off : noop, - on : noop, + on : noop }; const mock = sinon.mock(thread); @@ -94,7 +93,6 @@ describe('Job', () => { mock.expects('run').once().withArgs(runnable, importScripts).returnsThis(); mock.expects('send').once().withArgs(param, transferables).returnsThis(); - mock.expects('off').once().withArgs('progress').returnsThis(); mock.expects('on').once().withArgs('progress').returnsThis(); job From ba57d80d75fce9ed4ce3e95af4b2a339bef67133 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 1 Jun 2017 15:00:37 +0200 Subject: [PATCH 174/224] Remove `progress` event listener when job is done --- src/job.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/job.js b/src/job.js index 1d5b0e9d..0d42eacc 100644 --- a/src/job.js +++ b/src/job.js @@ -38,10 +38,20 @@ export default class Job extends EventEmitter { } executeOn(thread) { + const onProgress = (...args) => this.emit('progress', ...args); + const onMessage = (...args) => { + this.emit('message', ...args); + this.removeListener('progress', onProgress); + }; + const onError = (...args) => { + this.emit('error', ...args); + this.removeListener('progress', onProgress); + }; + thread - .on('progress', this.onProgress.bind(this)) - .once('message', this.emit.bind(this, 'done')) - .once('error', this.emit.bind(this, 'error')) + .on('progress', onProgress) + .once('message', onMessage) + .once('error', onError) .run(...this.runArgs) .send(...this.sendArgs); From 30b3c2cfafbeeb73967339a856b9545b5cd7da81 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 1 Jun 2017 15:06:36 +0200 Subject: [PATCH 175/224] Small fix --- src/job.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/job.js b/src/job.js index 0d42eacc..0a119578 100644 --- a/src/job.js +++ b/src/job.js @@ -33,19 +33,15 @@ export default class Job extends EventEmitter { return this; } - onProgress(progress){ - this.emit('progress', progress); - } - executeOn(thread) { const onProgress = (...args) => this.emit('progress', ...args); const onMessage = (...args) => { this.emit('message', ...args); - this.removeListener('progress', onProgress); + thread.removeListener('progress', onProgress); }; const onError = (...args) => { this.emit('error', ...args); - this.removeListener('progress', onProgress); + thread.removeListener('progress', onProgress); }; thread From 84213d113378c779116f1330ce30ed12b8a4c317 Mon Sep 17 00:00:00 2001 From: mmcardle Date: Thu, 1 Jun 2017 15:30:46 +0100 Subject: [PATCH 176/224] modify onMessage to emit 'done' --- src/job.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job.js b/src/job.js index 0a119578..54d44246 100644 --- a/src/job.js +++ b/src/job.js @@ -36,7 +36,7 @@ export default class Job extends EventEmitter { executeOn(thread) { const onProgress = (...args) => this.emit('progress', ...args); const onMessage = (...args) => { - this.emit('message', ...args); + this.emit('done', ...args); thread.removeListener('progress', onProgress); }; const onError = (...args) => { From 3c622fd6b61cf4e685c4b35287e71319bf4992fd Mon Sep 17 00:00:00 2001 From: mmcardle Date: Thu, 1 Jun 2017 16:13:59 +0100 Subject: [PATCH 177/224] Updating CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b5eb2f6..e9dd3c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # threads.js - Changelog +## Next release + +- Job class now emits 'progress' events +[#56](https://github.com/andywer/threads.js/pull/56) +- Credits to https://github.com/mmcardle + ## 0.7.3 - Trigger worker error event on unhandled promise rejection in worker [#49](https://github.com/andywer/threads.js/issues/49) From cfeaee55eee4b06008dd67ef62bc5e150769aa8f Mon Sep 17 00:00:00 2001 From: mmcardle Date: Fri, 2 Jun 2017 11:56:54 +0100 Subject: [PATCH 178/224] Test for multple progress events from Job --- test/spec/job.spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/spec/job.spec.js b/test/spec/job.spec.js index 72512d48..ad0d934f 100644 --- a/test/spec/job.spec.js +++ b/test/spec/job.spec.js @@ -24,6 +24,11 @@ function createFakeThread(response) { thread.send = function() { thread.emit('error', response.error); }; + } else if (response.progress) { + thread.send = function() { + // Emit multiple progress events + response.progress.forEach((p) => {thread.emit('progress', p)}); + }; } else { thread.send = function() { thread.emit('message', ...response.response); @@ -103,6 +108,25 @@ describe('Job', () => { mock.verify(); }); + it('triggers multiple progress events', () => { + const progress1 = { progress: 'progress1' }; + const progress2 = { progress: 'progress2' }; + const thread = createFakeThread({ + progress : [ progress1, progress2 ] + }); + + const job = new Job(pool); + sinon.spy(job, 'emit'); + + job + .run(noop) + .send() + .executeOn(thread); + + sinon.assert.calledWith(job.emit, 'progress', progress1); + sinon.assert.calledWith(job.emit, 'progress', progress2); + }); + it('triggers done event', () => { const thread = createFakeThread({ response : [ { foo: 'bar' }, 'more data' ] From 715f54c984b396576d03126aeaacb201dbf3463d Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 2 Jun 2017 12:22:02 +0200 Subject: [PATCH 179/224] Add support for async thread functions --- CHANGELOG.md | 5 ++-- README.md | 23 +++++++++++++++++ src/worker.browser/slave.js.txt | 21 ++++++++++++++- src/worker.node/slave.js | 13 +++++++++- test/spec/worker.spec.js | 45 ++++++++++++++++++++++----------- 5 files changed, 87 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9dd3c08..7b196d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,8 @@ ## Next release -- Job class now emits 'progress' events -[#56](https://github.com/andywer/threads.js/pull/56) -- Credits to https://github.com/mmcardle +- Support for async thread functions +- Job class now emits 'progress' events [#56](https://github.com/andywer/threads.js/pull/56), credits to https://github.com/mmcardle ## 0.7.3 diff --git a/README.md b/README.md index 7c2dcf81..f6adaa0b 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,29 @@ module.exports = function(input, done) { }; ``` +### Async functions + +You can also pass async functions, a.k.a. functions returning a Promise, to spawn threads. + +```javascript +const spawn = require('threads').spawn; + +const thread = spawn(function ([a, b]) { + // Remember that this function will be run in another execution context. + return new Promise(resolve => { + setTimeout(() => resolve(a + b), 1000) + }) +}); + +thread + .send([ 9, 12 ]) + // The handlers come here: (none of them is mandatory) + .on('message', function(response) { + console.log('9 + 12 = ', response); + thread.kill(); + }); +``` + ### Thread Pool diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index 4d4d5dac..4f98b109 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -16,6 +16,16 @@ function handlerProgress(progress) { this.postMessage({ progress : progress }); } +function handlerError(error) { + // Need to clone error manually to avoid DataCloneError, since errors cannot be send + var cloned = { + message: error.message, + name: error.name, + stack: error.stack + }; + this.postMessage({ error : cloned }); +} + function handlerDoneTransfer() { var args = Array.prototype.slice.call(arguments); var lastArg = args.pop(); @@ -27,6 +37,10 @@ function handlerDoneTransfer() { this.postMessage({ response : args }, lastArg); } +function isPromise (thing) { + return thing && typeof thing.then === 'function'; +} + self.onmessage = function (event) { var scripts = event.data.scripts; if (scripts && scripts.length > 0 && typeof importScripts !== 'function') { @@ -48,6 +62,7 @@ self.onmessage = function (event) { if (event.data.doRun) { var handler = this.module.exports; + if (typeof handler !== 'function') { throw new Error('Cannot run thread logic. No handler has been exported.'); } @@ -55,6 +70,10 @@ self.onmessage = function (event) { var preparedHandlerDone = handlerDone.bind(this); preparedHandlerDone.transfer = handlerDoneTransfer.bind(this); - handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this)); + var returned = handler.call(this, event.data.param, preparedHandlerDone, handlerProgress.bind(this)); + + if (isPromise(returned)) { + returned.then(preparedHandlerDone, handlerError.bind(this)); + } } }.bind(self); diff --git a/src/worker.node/slave.js b/src/worker.node/slave.js index 703f7728..3ebf4cfc 100644 --- a/src/worker.node/slave.js +++ b/src/worker.node/slave.js @@ -53,6 +53,10 @@ function messageHandlerError(error) { }); } +function isPromise (thing) { + return thing && typeof thing.then === 'function'; +} + process.on('message', function(data) { if (data.initByScript) { messageHandler = require(data.script); @@ -67,6 +71,13 @@ process.on('message', function(data) { // so initialization errors will be printed to console setupErrorCatcher(); - messageHandler(data.param, messageHandlerDone, messageHandlerProgress); + const returned = messageHandler(data.param, messageHandlerDone, messageHandlerProgress); + + if (isPromise(returned)) { + returned.then( + (result) => messageHandlerDone(result), + (error) => messageHandlerError(error) + ); + } } }); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 219faeec..69339b4e 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -4,7 +4,6 @@ import sinon from 'sinon'; import Worker from '../../lib/worker'; import { config, spawn } from '../../'; - const env = typeof window === 'object' ? 'browser' : 'node'; function echoThread(param, done) { @@ -39,7 +38,6 @@ function expectEqualBuffers(buffer1, buffer2) { } } - describe('Worker', function () { this.timeout(4000); @@ -55,7 +53,6 @@ describe('Worker', function () { }); }); - it('can be spawned', () => { const worker = spawn(); @@ -173,6 +170,8 @@ describe('Worker', function () { it('can update progress', done => { const progressUpdates = []; const worker = spawn(progressThread); + let messageHandlerInvoked = false; + let doneHandlerInvoked = false; worker.on('progress', progress => { progressUpdates.push(progress); @@ -181,23 +180,21 @@ describe('Worker', function () { worker.on('message', () => { expect(progressUpdates).to.eql([ 0.3, 0.6 ]); - done(); - }); - }); - - it('does also emit "done" event', done => { - const progressUpdates = []; - const worker = spawn(progressThread); - - worker.on('progress', progress => { - progressUpdates.push(progress); + messageHandlerInvoked = true; + maybeDone(); }); - worker.send(); worker.on('done', () => { expect(progressUpdates).to.eql([ 0.3, 0.6 ]); - done(); + doneHandlerInvoked = true; + maybeDone(); }); + + function maybeDone () { + if (messageHandlerInvoked && doneHandlerInvoked) { + done(); + } + } }); @@ -279,4 +276,22 @@ describe('Worker', function () { } + // For unknown reasons Firefox will choke on the last test cases + // if the following test cases are not at the end: + // (Only in Firefox, not in Chrome, not in node) + + it('can run async method (returning a Promise)', done => { + const worker = spawn((param) => Promise.resolve(param)); + canSendAndReceiveEcho(worker, done); + }); + + it('can handle errors in an async method', done => { + const worker = spawn(() => Promise.reject(new Error('Some error'))); + worker.on('error', error => { + expect(error.message).to.match(/^Some error$/); + done(); + }); + worker.send(); + }); + }); From f74fda12a1e87bc2257934de723fbdeb3abd0c51 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 2 Jun 2017 14:16:38 +0200 Subject: [PATCH 180/224] v0.8.0 --- CHANGELOG.md | 2 +- bower.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b196d8f..98985979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # threads.js - Changelog -## Next release +## 0.8.0 - Support for async thread functions - Job class now emits 'progress' events [#56](https://github.com/andywer/threads.js/pull/56), credits to https://github.com/mmcardle diff --git a/bower.json b/bower.json index 91d98193..60cb5fee 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.7.3", + "version": "0.8.0", "main": "dist/threads.browser.js", "homepage": "https://github.com/andywer/threads.js", "authors": [ diff --git a/package.json b/package.json index 13557b3b..96e206a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.7.3", + "version": "0.8.0", "keywords": [ "threads", "web worker", From 6e63f53f521f02896520704a578324c4e63e45f8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 2 Jun 2017 18:07:46 +0200 Subject: [PATCH 181/224] v0.8.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98985979..94c690e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.8.1 + +- Bug fix: Some outdated transpiled files were published as `v0.8.0` + ## 0.8.0 - Support for async thread functions diff --git a/package.json b/package.json index 96e206a3..019d470a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.8.0", + "version": "0.8.1", "keywords": [ "threads", "web worker", From 54746cf971018fba0795867a815e8c21d95c1b4b Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 4 Jun 2017 14:25:38 +0200 Subject: [PATCH 182/224] Update README.md Replace broken code climate coverage badge by coveralls badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6adaa0b..7e828410 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # threads.js [![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) -[![Test Coverage](https://codeclimate.com/github/andywer/threads.js/badges/coverage.svg)](https://codeclimate.com/github/andywer/threads.js/coverage) +[![Coverage Status](https://coveralls.io/repos/github/andywer/threads.js/badge.svg?branch=master)](https://coveralls.io/github/andywer/threads.js?branch=master) [![Code Climate](https://codeclimate.com/github/andywer/threads.js/badges/gpa.svg)](https://codeclimate.com/github/andywer/threads.js) [![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) From 95f050c7e18937b46f38ccc76b9af045ed52d176 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 24 Nov 2017 17:00:56 +0100 Subject: [PATCH 183/224] Merge dependent functional pool tests --- test/spec/pool-functional.spec.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/test/spec/pool-functional.spec.js b/test/spec/pool-functional.spec.js index e849298a..37f67f0e 100644 --- a/test/spec/pool-functional.spec.js +++ b/test/spec/pool-functional.spec.js @@ -21,17 +21,10 @@ describe('Pool (functional test)', () => { jobs.push(job); promises.push(job.promise()); } - }); - it('responds as expected', done => { - Promise - .all(promises) + return Promise.all(promises) .then(responses => { expect(responses.sort()).to.eql([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]); - done(); }) - .catch(error => { - done(error); - }); }); }); From 446cd91c6753803936e85e5d745b94ce5be2cf08 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 24 Nov 2017 17:01:24 +0100 Subject: [PATCH 184/224] Add package-lock.json --- package-lock.json | 9007 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 9007 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..9c89854a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,9007 @@ +{ + "name": "threads", + "version": "0.8.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@gulp-sourcemaps/map-sources": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", + "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", + "dev": true, + "requires": { + "normalize-path": "2.1.1", + "through2": "2.0.3" + } + }, + "Base64": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/Base64/-/Base64-0.2.1.tgz", + "integrity": "sha1-ujpCMHCOGGcFBl5mur3Uw1z2ACg=", + "dev": true + }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, + "abbrev": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "dev": true + }, + "accepts": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "dev": true, + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + }, + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "3.3.0" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", + "dev": true + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + }, + "dependencies": { + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + } + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "dev": true, + "requires": { + "micromatch": "2.3.11", + "normalize-path": "2.1.1" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "argparse": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + } + }, + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "dev": true, + "requires": { + "arr-flatten": "1.1.0" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "dev": true + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", + "dev": true + }, + "array-filter": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", + "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", + "dev": true + }, + "array-map": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", + "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", + "dev": true + }, + "array-reduce": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", + "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", + "dev": true + }, + "array-slice": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.0.0.tgz", + "integrity": "sha1-5zA08A3MH0CHYAj9IP6ud71LfC8=", + "dev": true + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "dev": true + }, + "arraybuffer.slice": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", + "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", + "dev": true + }, + "asn1.js": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", + "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "inherits": "2.0.3", + "minimalistic-assert": "1.0.0" + } + }, + "assert": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", + "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "dev": true, + "requires": { + "util": "0.10.3" + } + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "dev": true + }, + "astw": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", + "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", + "dev": true, + "requires": { + "acorn": "4.0.13" + } + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "atob": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", + "integrity": "sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M=", + "dev": true + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "dev": true + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", + "dev": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, + "babel-core": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", + "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "babel-generator": "6.26.0", + "babel-helpers": "6.24.1", + "babel-messages": "6.23.0", + "babel-register": "6.26.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "convert-source-map": "1.5.0", + "debug": "2.6.9", + "json5": "0.5.1", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "path-is-absolute": "1.0.1", + "private": "0.1.7", + "slash": "1.0.0", + "source-map": "0.5.7" + }, + "dependencies": { + "convert-source-map": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.0.tgz", + "integrity": "sha1-ms1whRxtXf3ZPZKC5e35SgP/RrU=", + "dev": true + } + } + }, + "babel-generator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz", + "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", + "dev": true, + "requires": { + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "detect-indent": "4.0.0", + "jsesc": "1.3.0", + "lodash": "4.17.4", + "source-map": "0.5.7", + "trim-right": "1.0.1" + }, + "dependencies": { + "jsesc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", + "dev": true + } + } + }, + "babel-helper-call-delegate": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", + "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "6.24.1", + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-define-map": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", + "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", + "dev": true, + "requires": { + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-helper-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", + "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", + "dev": true, + "requires": { + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-get-function-arity": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", + "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-hoist-variables": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", + "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-optimise-call-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", + "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-regex": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", + "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-helper-replace-supers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", + "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", + "dev": true, + "requires": { + "babel-helper-optimise-call-expression": "6.24.1", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helpers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", + "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-check-es2015-constants": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", + "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-arrow-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", + "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-block-scoped-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", + "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-block-scoping": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", + "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-plugin-transform-es2015-classes": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", + "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", + "dev": true, + "requires": { + "babel-helper-define-map": "6.26.0", + "babel-helper-function-name": "6.24.1", + "babel-helper-optimise-call-expression": "6.24.1", + "babel-helper-replace-supers": "6.24.1", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-computed-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", + "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-destructuring": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", + "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-duplicate-keys": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", + "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-for-of": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", + "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", + "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", + "dev": true, + "requires": { + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", + "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-amd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", + "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-commonjs": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz", + "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", + "dev": true, + "requires": { + "babel-plugin-transform-strict-mode": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-systemjs": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", + "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-umd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", + "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-amd": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-object-super": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", + "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", + "dev": true, + "requires": { + "babel-helper-replace-supers": "6.24.1", + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-parameters": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", + "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", + "dev": true, + "requires": { + "babel-helper-call-delegate": "6.24.1", + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-shorthand-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", + "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-spread": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", + "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-sticky-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", + "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", + "dev": true, + "requires": { + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-template-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", + "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-typeof-symbol": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", + "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-unicode-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", + "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", + "dev": true, + "requires": { + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "regexpu-core": "2.0.0" + } + }, + "babel-plugin-transform-regenerator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", + "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", + "dev": true, + "requires": { + "regenerator-transform": "0.10.1" + } + }, + "babel-plugin-transform-strict-mode": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", + "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-preset-es2015": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", + "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", + "dev": true, + "requires": { + "babel-plugin-check-es2015-constants": "6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0", + "babel-plugin-transform-es2015-block-scoping": "6.26.0", + "babel-plugin-transform-es2015-classes": "6.24.1", + "babel-plugin-transform-es2015-computed-properties": "6.24.1", + "babel-plugin-transform-es2015-destructuring": "6.23.0", + "babel-plugin-transform-es2015-duplicate-keys": "6.24.1", + "babel-plugin-transform-es2015-for-of": "6.23.0", + "babel-plugin-transform-es2015-function-name": "6.24.1", + "babel-plugin-transform-es2015-literals": "6.22.0", + "babel-plugin-transform-es2015-modules-amd": "6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", + "babel-plugin-transform-es2015-modules-systemjs": "6.24.1", + "babel-plugin-transform-es2015-modules-umd": "6.24.1", + "babel-plugin-transform-es2015-object-super": "6.24.1", + "babel-plugin-transform-es2015-parameters": "6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "6.24.1", + "babel-plugin-transform-es2015-spread": "6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "6.24.1", + "babel-plugin-transform-es2015-template-literals": "6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "6.23.0", + "babel-plugin-transform-es2015-unicode-regex": "6.24.1", + "babel-plugin-transform-regenerator": "6.26.0" + } + }, + "babel-preset-es2015-loose": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/babel-preset-es2015-loose/-/babel-preset-es2015-loose-8.0.0.tgz", + "integrity": "sha1-gu4pOrMTKcepRoa2RLYq37zcP1c=", + "dev": true, + "requires": { + "modify-babel-preset": "3.2.1" + } + }, + "babel-register": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", + "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "dev": true, + "requires": { + "babel-core": "6.26.0", + "babel-runtime": "6.26.0", + "core-js": "2.5.1", + "home-or-tmp": "2.0.0", + "lodash": "4.17.4", + "mkdirp": "0.5.1", + "source-map-support": "0.4.18" + } + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "2.5.1", + "regenerator-runtime": "0.11.0" + } + }, + "babel-template": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", + "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "lodash": "4.17.4" + } + }, + "babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "debug": "2.6.9", + "globals": "9.18.0", + "invariant": "2.2.2", + "lodash": "4.17.4" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "esutils": "2.0.2", + "lodash": "4.17.4", + "to-fast-properties": "1.0.3" + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=", + "dev": true + }, + "base64-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", + "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "dev": true + }, + "base64id": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", + "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "beeper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", + "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "dev": true + }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "dev": true, + "requires": { + "callsite": "1.0.0" + } + }, + "binary-extensions": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.10.0.tgz", + "integrity": "sha1-muuabF6IY4qtFx4Wf1kAq+JINdA=", + "dev": true + }, + "bl": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", + "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", + "dev": true, + "requires": { + "readable-stream": "2.0.6" + }, + "dependencies": { + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + } + } + } + }, + "blob": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", + "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=", + "dev": true + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "dev": true + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", + "dev": true + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "dev": true, + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + }, + "dependencies": { + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", + "dev": true + } + } + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "dev": true, + "requires": { + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "browser-pack": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", + "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.7.2", + "defined": "1.0.0", + "through2": "2.0.3", + "umd": "3.0.1" + } + }, + "browser-resolve": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", + "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "dev": true, + "requires": { + "resolve": "1.1.7" + }, + "dependencies": { + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + } + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "browserify": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-13.3.0.tgz", + "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "assert": "1.4.1", + "browser-pack": "6.0.2", + "browser-resolve": "1.11.2", + "browserify-zlib": "0.1.4", + "buffer": "4.9.1", + "cached-path-relative": "1.0.1", + "concat-stream": "1.5.2", + "console-browserify": "1.1.0", + "constants-browserify": "1.0.0", + "crypto-browserify": "3.11.1", + "defined": "1.0.0", + "deps-sort": "2.0.0", + "domain-browser": "1.1.7", + "duplexer2": "0.1.4", + "events": "1.1.1", + "glob": "7.1.2", + "has": "1.0.1", + "htmlescape": "1.1.1", + "https-browserify": "0.0.1", + "inherits": "2.0.3", + "insert-module-globals": "7.0.1", + "labeled-stream-splicer": "2.0.0", + "module-deps": "4.1.1", + "os-browserify": "0.1.2", + "parents": "1.0.1", + "path-browserify": "0.0.0", + "process": "0.11.10", + "punycode": "1.4.1", + "querystring-es3": "0.2.1", + "read-only-stream": "2.0.0", + "readable-stream": "2.3.3", + "resolve": "1.4.0", + "shasum": "1.0.2", + "shell-quote": "1.6.1", + "stream-browserify": "2.0.1", + "stream-http": "2.7.2", + "string_decoder": "0.10.31", + "subarg": "1.0.0", + "syntax-error": "1.3.0", + "through2": "2.0.3", + "timers-browserify": "1.4.2", + "tty-browserify": "0.0.0", + "url": "0.11.0", + "util": "0.10.3", + "vm-browserify": "0.0.4", + "xtend": "4.0.1" + } + }, + "browserify-aes": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.8.tgz", + "integrity": "sha512-WYCMOT/PtGTlpOKFht0YJFYcPy6pLCR98CtWfzK13zoynLlBMvAdEMSRGmgnJCw2M2j/5qxBkinZQFobieM8dQ==", + "dev": true, + "requires": { + "buffer-xor": "1.0.3", + "cipher-base": "1.0.4", + "create-hash": "1.1.3", + "evp_bytestokey": "1.0.3", + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "browserify-cipher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", + "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "dev": true, + "requires": { + "browserify-aes": "1.0.8", + "browserify-des": "1.0.0", + "evp_bytestokey": "1.0.3" + } + }, + "browserify-des": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", + "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "dev": true, + "requires": { + "cipher-base": "1.0.4", + "des.js": "1.0.0", + "inherits": "2.0.3" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "randombytes": "2.0.5" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "browserify-rsa": "4.0.1", + "create-hash": "1.1.3", + "create-hmac": "1.1.6", + "elliptic": "6.4.0", + "inherits": "2.0.3", + "parse-asn1": "5.1.0" + } + }, + "browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true, + "requires": { + "pako": "0.2.9" + } + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "1.2.1", + "ieee754": "1.1.8", + "isarray": "1.0.0" + } + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "bufferstreams": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.1.tgz", + "integrity": "sha1-AWE3MGCsWYjv+ZBYcxEU9uGV1R4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, + "builtins": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-0.0.7.tgz", + "integrity": "sha1-NVIZzWzxjb58Acx/0tznZc/cVJo=", + "dev": true + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "dev": true + }, + "cached-path-relative": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", + "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=", + "dev": true + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "0.2.0" + } + }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=", + "dev": true + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", + "dev": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "dev": true, + "requires": { + "anymatch": "1.3.2", + "async-each": "1.0.1", + "fsevents": "1.1.2", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" + } + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "requires": { + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + } + } + }, + "clone": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", + "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "dev": true + }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, + "clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "dev": true + }, + "cloneable-readable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.0.0.tgz", + "integrity": "sha1-pikNQT8hemEjL5XkWP84QYz7ARc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "process-nextick-args": "1.0.7", + "through2": "2.0.3" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "codeclimate-test-reporter": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/codeclimate-test-reporter/-/codeclimate-test-reporter-0.4.1.tgz", + "integrity": "sha1-nyD22C02qrmdIKvk9sc3L0xtGRU=", + "dev": true, + "requires": { + "async": "1.5.2", + "commander": "2.9.0", + "lcov-parse": "0.0.10", + "request": "2.74.0" + } + }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "dev": true + }, + "combine-lists": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.1.tgz", + "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + }, + "combine-source-map": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", + "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "dev": true, + "requires": { + "convert-source-map": "1.1.3", + "inline-source-map": "0.6.2", + "lodash.memoize": "3.0.4", + "source-map": "0.5.7" + } + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": "1.0.1" + } + }, + "commondir": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-0.0.1.tgz", + "integrity": "sha1-ifAP3NUbUZxXhzP+xWPmptp/W+I=", + "dev": true + }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", + "dev": true + }, + "component-emitter": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", + "integrity": "sha1-KWWU8nU9qmOZbSrwjRWpURbJrsM=", + "dev": true + }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", + "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.0.6", + "typedarray": "0.0.6" + }, + "dependencies": { + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + } + } + } + }, + "concat-with-sourcemaps": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.0.4.tgz", + "integrity": "sha1-9Vs74q60dgGxCi1SWcz7cP0vHdY=", + "dev": true, + "requires": { + "source-map": "0.5.7" + } + }, + "connect": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.5.tgz", + "integrity": "sha1-+43ee6B2OHfQ7J352sC0tA5yx9o=", + "dev": true, + "requires": { + "debug": "2.6.9", + "finalhandler": "1.0.6", + "parseurl": "1.3.2", + "utils-merge": "1.0.1" + } + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "0.1.4" + } + }, + "constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "dev": true + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dev": true + }, + "convert-source-map": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", + "dev": true + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "dev": true + }, + "core-js": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", + "integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "coveralls": { + "version": "2.13.3", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-2.13.3.tgz", + "integrity": "sha512-iiAmn+l1XqRwNLXhW8Rs5qHZRFMYp9ZIPjEOVRpC/c4so6Y/f4/lFi0FfR5B9cCqgyhkJ5cZmbvcVRfP8MHchw==", + "dev": true, + "requires": { + "js-yaml": "3.6.1", + "lcov-parse": "0.0.10", + "log-driver": "1.2.5", + "minimist": "1.2.0", + "request": "2.79.0" + }, + "dependencies": { + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "dev": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "qs": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", + "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", + "dev": true + }, + "request": { + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", + "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.11.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "2.0.6", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "qs": "6.3.2", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.4.3", + "uuid": "3.1.0" + } + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "dev": true + } + } + }, + "create-ecdh": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", + "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "elliptic": "6.4.0" + } + }, + "create-hash": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", + "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "dev": true, + "requires": { + "cipher-base": "1.0.4", + "inherits": "2.0.3", + "ripemd160": "2.0.1", + "sha.js": "2.4.9" + } + }, + "create-hmac": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", + "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "dev": true, + "requires": { + "cipher-base": "1.0.4", + "create-hash": "1.1.3", + "inherits": "2.0.3", + "ripemd160": "2.0.1", + "safe-buffer": "5.1.1", + "sha.js": "2.4.9" + } + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "crypto-browserify": { + "version": "3.11.1", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", + "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "dev": true, + "requires": { + "browserify-cipher": "1.0.0", + "browserify-sign": "4.0.4", + "create-ecdh": "4.0.0", + "create-hash": "1.1.3", + "create-hmac": "1.1.6", + "diffie-hellman": "5.0.2", + "inherits": "2.0.3", + "pbkdf2": "3.0.14", + "public-encrypt": "4.0.0", + "randombytes": "2.0.5" + } + }, + "css": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.1.tgz", + "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "source-map": "0.1.43", + "source-map-resolve": "0.3.1", + "urix": "0.1.0" + }, + "dependencies": { + "source-map": { + "version": "0.1.43", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + } + } + }, + "custom-event": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", + "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", + "dev": true + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "dev": true, + "requires": { + "es5-ext": "0.10.31" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "dateformat": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", + "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "debug-fabulous": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/debug-fabulous/-/debug-fabulous-0.0.4.tgz", + "integrity": "sha1-+gccXYdIRoVCSAdCHKSxawsaB2M=", + "dev": true, + "requires": { + "debug": "2.6.9", + "lazy-debug-legacy": "0.0.1", + "object-assign": "4.1.0" + }, + "dependencies": { + "object-assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", + "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=", + "dev": true + } + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true, + "requires": { + "clone": "1.0.2" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.2" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "dev": true + }, + "deprecated": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", + "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", + "dev": true + }, + "deps-sort": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", + "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "shasum": "1.0.2", + "subarg": "1.0.0", + "through2": "2.0.3" + } + }, + "des.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", + "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "minimalistic-assert": "1.0.0" + } + }, + "detect-file": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", + "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", + "dev": true, + "requires": { + "fs-exists-sync": "0.1.0" + } + }, + "detect-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", + "dev": true, + "requires": { + "repeating": "2.0.1" + } + }, + "detect-newline": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", + "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", + "dev": true + }, + "detective": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.5.0.tgz", + "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", + "dev": true, + "requires": { + "acorn": "4.0.13", + "defined": "1.0.0" + } + }, + "di": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", + "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", + "dev": true + }, + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "dev": true + }, + "diffie-hellman": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", + "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "miller-rabin": "4.0.1", + "randombytes": "2.0.5" + } + }, + "doctrine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "dev": true, + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + } + }, + "dom-serialize": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", + "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", + "dev": true, + "requires": { + "custom-event": "1.0.1", + "ent": "2.2.0", + "extend": "3.0.1", + "void-elements": "2.0.1" + } + }, + "domain-browser": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", + "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "dev": true + }, + "duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "elliptic": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "brorand": "1.1.0", + "hash.js": "1.1.3", + "hmac-drbg": "1.0.1", + "inherits": "2.0.3", + "minimalistic-assert": "1.0.0", + "minimalistic-crypto-utils": "1.0.1" + } + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "dev": true + }, + "end-of-stream": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", + "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "dev": true, + "requires": { + "once": "1.3.3" + }, + "dependencies": { + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + } + } + }, + "engine.io": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-1.8.3.tgz", + "integrity": "sha1-jef5eJXSDTm4X4ju7nd7K9QrE9Q=", + "dev": true, + "requires": { + "accepts": "1.3.3", + "base64id": "1.0.0", + "cookie": "0.3.1", + "debug": "2.3.3", + "engine.io-parser": "1.3.2", + "ws": "1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", + "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "dev": true, + "requires": { + "ms": "0.7.2" + } + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "engine.io-client": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-1.8.3.tgz", + "integrity": "sha1-F5jtk0USRkU9TG9jXXogH+lA1as=", + "dev": true, + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "2.3.3", + "engine.io-parser": "1.3.2", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parsejson": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "1.1.2", + "xmlhttprequest-ssl": "1.5.3", + "yeast": "0.1.2" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "debug": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", + "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "dev": true, + "requires": { + "ms": "0.7.2" + } + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "engine.io-parser": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.2.tgz", + "integrity": "sha1-k3sHnwAH0Ik+xW1GyyILjLQ1Igo=", + "dev": true, + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "0.0.6", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.4", + "has-binary": "0.1.7", + "wtf-8": "1.0.0" + } + }, + "ent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", + "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", + "dev": true + }, + "es5-ext": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.31.tgz", + "integrity": "sha1-e7k4yVp/G59ygJLcCcQe3MOY7v4=", + "dev": true, + "requires": { + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1" + } + }, + "es6-iterator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", + "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31", + "es6-symbol": "3.1.1" + } + }, + "es6-map": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", + "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31", + "es6-iterator": "2.0.1", + "es6-set": "0.1.5", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-promise": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.0.5.tgz", + "integrity": "sha1-eILzCt3lskDM+n99eMVIMwlRrkI=", + "dev": true + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31", + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31" + } + }, + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31", + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "dev": true, + "requires": { + "esprima": "2.7.3", + "estraverse": "1.9.3", + "esutils": "2.0.2", + "optionator": "0.8.2", + "source-map": "0.2.0" + }, + "dependencies": { + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": "1.0.1" + } + } + } + }, + "escope": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", + "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", + "dev": true, + "requires": { + "es6-map": "0.1.5", + "es6-weak-map": "2.0.2", + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + } + }, + "eslint": { + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", + "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "chalk": "1.1.3", + "concat-stream": "1.5.2", + "debug": "2.6.9", + "doctrine": "2.0.0", + "escope": "3.6.0", + "espree": "3.5.1", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "glob": "7.1.2", + "globals": "9.18.0", + "ignore": "3.3.5", + "imurmurhash": "0.1.4", + "inquirer": "0.12.0", + "is-my-json-valid": "2.16.1", + "is-resolvable": "1.0.0", + "js-yaml": "3.6.1", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "1.2.1", + "progress": "1.1.8", + "require-uncached": "1.0.3", + "shelljs": "0.7.8", + "strip-bom": "3.0.0", + "strip-json-comments": "2.0.1", + "table": "3.8.3", + "text-table": "0.2.0", + "user-home": "2.0.0" + }, + "dependencies": { + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } + } + } + }, + "espree": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.1.tgz", + "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=", + "dev": true, + "requires": { + "acorn": "5.1.2", + "acorn-jsx": "3.0.1" + }, + "dependencies": { + "acorn": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", + "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "dev": true + } + } + }, + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "esquery": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true, + "requires": { + "estraverse": "4.2.0" + } + }, + "esrecurse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", + "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", + "dev": true, + "requires": { + "estraverse": "4.2.0", + "object-assign": "4.1.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.31" + } + }, + "eventemitter3": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz", + "integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo=" + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "dev": true + }, + "evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dev": true, + "requires": { + "md5.js": "1.3.4", + "safe-buffer": "5.1.1" + } + }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, + "expand-braces": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", + "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", + "dev": true, + "requires": { + "array-slice": "0.2.3", + "array-unique": "0.2.1", + "braces": "0.1.5" + }, + "dependencies": { + "array-slice": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", + "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", + "dev": true + }, + "braces": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", + "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", + "dev": true, + "requires": { + "expand-range": "0.1.1" + } + }, + "expand-range": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", + "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", + "dev": true, + "requires": { + "is-number": "0.1.1", + "repeat-string": "0.2.2" + } + }, + "is-number": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", + "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=", + "dev": true + }, + "repeat-string": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz", + "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=", + "dev": true + } + } + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "dev": true, + "requires": { + "is-posix-bracket": "0.1.1" + } + }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "dev": true, + "requires": { + "fill-range": "2.2.3" + } + }, + "expand-tilde": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", + "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } + }, + "expect.js": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.3.1.tgz", + "integrity": "sha1-sKWaDS7/VDdUTr8M6qYBWEHQm1s=", + "dev": true + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } + }, + "extract-zip": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.5.tgz", + "integrity": "sha1-maBnNbbqIOqbcF13ms/8yHz/BEA=", + "dev": true, + "requires": { + "concat-stream": "1.6.0", + "debug": "2.2.0", + "mkdirp": "0.5.0", + "yauzl": "2.4.1" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", + "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fancy-log": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", + "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "time-stamp": "1.1.0" + } + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "dev": true, + "requires": { + "pend": "1.2.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "1.3.0", + "object-assign": "4.1.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "filename-regex": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", + "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", + "dev": true + }, + "fill-range": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "dev": true, + "requires": { + "is-number": "2.1.0", + "isobject": "2.1.0", + "randomatic": "1.1.7", + "repeat-element": "1.1.2", + "repeat-string": "1.6.1" + } + }, + "finalhandler": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.6.tgz", + "integrity": "sha1-AHrqM9Gk0+QgF/YkhIrVjSEvgU8=", + "dev": true, + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.3.1", + "unpipe": "1.0.0" + } + }, + "find-index": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", + "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", + "dev": true + }, + "findup-sync": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", + "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", + "dev": true, + "requires": { + "detect-file": "0.1.0", + "is-glob": "2.0.1", + "micromatch": "2.3.11", + "resolve-dir": "0.1.1" + } + }, + "fined": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.0.tgz", + "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", + "dev": true, + "requires": { + "expand-tilde": "2.0.2", + "is-plain-object": "2.0.4", + "object.defaults": "1.1.0", + "object.pick": "1.3.0", + "parse-filepath": "1.0.1" + }, + "dependencies": { + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dev": true, + "requires": { + "homedir-polyfill": "1.0.1" + } + } + } + }, + "first-chunk-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", + "dev": true + }, + "flagged-respawn": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", + "integrity": "sha1-/xke3c1wiKZ1smEP/8l2vpuAdLU=", + "dev": true + }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "dev": true, + "requires": { + "for-in": "1.0.2" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", + "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", + "dev": true, + "requires": { + "async": "2.5.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + }, + "dependencies": { + "async": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", + "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + } + } + }, + "formatio": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", + "integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=", + "dev": true, + "requires": { + "samsam": "1.1.2" + } + }, + "fs-access": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", + "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", + "dev": true, + "requires": { + "null-check": "1.0.0" + } + }, + "fs-exists-sync": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", + "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", + "dev": true + }, + "fs-extra": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "2.4.0", + "klaw": "1.3.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", + "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.7.0", + "node-pre-gyp": "0.6.36" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.36", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gaze": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", + "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "dev": true, + "requires": { + "globule": "0.1.0" + } + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "requires": { + "is-property": "1.0.2" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", + "dev": true, + "requires": { + "glob-parent": "2.0.0", + "is-glob": "2.0.1" + } + }, + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "dev": true, + "requires": { + "is-glob": "2.0.1" + } + }, + "glob-stream": { + "version": "3.1.18", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", + "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "dev": true, + "requires": { + "glob": "4.5.3", + "glob2base": "0.0.12", + "minimatch": "2.0.10", + "ordered-read-streams": "0.1.0", + "through2": "0.6.5", + "unique-stream": "1.0.0" + }, + "dependencies": { + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.4.0" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } + } + } + }, + "glob-watcher": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", + "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", + "dev": true, + "requires": { + "gaze": "0.5.2" + } + }, + "glob2base": { + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", + "dev": true, + "requires": { + "find-index": "0.1.1" + } + }, + "global-modules": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", + "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", + "dev": true, + "requires": { + "global-prefix": "0.1.5", + "is-windows": "0.2.0" + } + }, + "global-prefix": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", + "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", + "dev": true, + "requires": { + "homedir-polyfill": "1.0.1", + "ini": "1.3.4", + "is-windows": "0.2.0", + "which": "1.3.0" + } + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "globule": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", + "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", + "dev": true, + "requires": { + "glob": "3.1.21", + "lodash": "1.0.2", + "minimatch": "0.2.14" + }, + "dependencies": { + "glob": { + "version": "3.1.21", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", + "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "dev": true, + "requires": { + "graceful-fs": "1.2.3", + "inherits": "1.0.2", + "minimatch": "0.2.14" + } + }, + "graceful-fs": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", + "dev": true + }, + "inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", + "dev": true + }, + "lodash": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", + "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", + "dev": true + }, + "minimatch": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } + } + } + }, + "glogg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", + "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "dev": true, + "requires": { + "natives": "1.1.0" + } + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "gulp": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", + "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", + "dev": true, + "requires": { + "archy": "1.0.0", + "chalk": "1.1.3", + "deprecated": "0.0.1", + "gulp-util": "3.0.8", + "interpret": "1.0.4", + "liftoff": "2.3.0", + "minimist": "1.2.0", + "orchestrator": "0.3.8", + "pretty-hrtime": "1.0.3", + "semver": "4.3.6", + "tildify": "1.2.0", + "v8flags": "2.1.1", + "vinyl-fs": "0.3.14" + } + }, + "gulp-babel": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/gulp-babel/-/gulp-babel-6.1.2.tgz", + "integrity": "sha1-fAF25Lo/JExgWIoMSzIKRdGt784=", + "dev": true, + "requires": { + "babel-core": "6.26.0", + "gulp-util": "3.0.8", + "object-assign": "4.1.1", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl-sourcemaps-apply": "0.2.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "gulp-concat": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz", + "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", + "dev": true, + "requires": { + "concat-with-sourcemaps": "1.0.4", + "through2": "2.0.3", + "vinyl": "2.1.0" + }, + "dependencies": { + "clone": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", + "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true + }, + "vinyl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz", + "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", + "dev": true, + "requires": { + "clone": "2.1.1", + "clone-buffer": "1.0.0", + "clone-stats": "1.0.0", + "cloneable-readable": "1.0.0", + "remove-trailing-separator": "1.1.0", + "replace-ext": "1.0.0" + } + } + } + }, + "gulp-eslint": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", + "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", + "dev": true, + "requires": { + "bufferstreams": "1.1.1", + "eslint": "3.19.0", + "gulp-util": "3.0.8" + } + }, + "gulp-mocha": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gulp-mocha/-/gulp-mocha-3.0.1.tgz", + "integrity": "sha1-qwyiw5QDcYF03drXUOY6Yb4X4EE=", + "dev": true, + "requires": { + "gulp-util": "3.0.8", + "mocha": "3.5.3", + "plur": "2.1.2", + "req-cwd": "1.0.1", + "temp": "0.8.3", + "through": "2.3.8" + } + }, + "gulp-rename": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz", + "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", + "dev": true + }, + "gulp-sourcemaps": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-1.12.0.tgz", + "integrity": "sha1-eG+XyUoPloSSRl1wVY4EJCxnlZg=", + "dev": true, + "requires": { + "@gulp-sourcemaps/map-sources": "1.0.0", + "acorn": "4.0.13", + "convert-source-map": "1.1.3", + "css": "2.2.1", + "debug-fabulous": "0.0.4", + "detect-newline": "2.1.0", + "graceful-fs": "4.1.11", + "source-map": "0.5.7", + "strip-bom": "2.0.0", + "through2": "2.0.3", + "vinyl": "1.2.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "0.2.1" + } + }, + "vinyl": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-1.2.0.tgz", + "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + } + } + }, + "gulp-uglify": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-2.1.2.tgz", + "integrity": "sha1-bbhbHQ7mPRgFhZK2WGSdZcLsRUE=", + "dev": true, + "requires": { + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash": "4.17.4", + "make-error-cause": "1.2.2", + "through2": "2.0.3", + "uglify-js": "2.8.29", + "uglify-save-license": "0.4.1", + "vinyl-sourcemaps-apply": "0.2.1" + } + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true, + "requires": { + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.2.0", + "fancy-log": "1.3.0", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" + } + }, + "gulplog": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", + "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "dev": true, + "requires": { + "glogg": "1.0.0" + } + }, + "handlebars": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", + "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "dev": true, + "requires": { + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" + }, + "dependencies": { + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + } + } + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", + "dev": true + }, + "har-validator": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "commander": "2.9.0", + "is-my-json-valid": "2.16.1", + "pinkie-promise": "2.0.1" + } + }, + "has": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", + "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "dev": true, + "requires": { + "function-bind": "1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "has-binary": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", + "integrity": "sha1-aOYesWIQyVRaClzOBqhzkS/h5ow=", + "dev": true, + "requires": { + "isarray": "0.0.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", + "dev": true + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "hash-base": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", + "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dev": true, + "requires": { + "inherits": "2.0.3", + "minimalistic-assert": "1.0.0" + } + }, + "hasha": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", + "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", + "dev": true, + "requires": { + "is-stream": "1.1.0", + "pinkie-promise": "2.0.1" + } + }, + "hat": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", + "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=", + "dev": true + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "requires": { + "hash.js": "1.1.3", + "minimalistic-assert": "1.0.0", + "minimalistic-crypto-utils": "1.0.1" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", + "dev": true + }, + "home-or-tmp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", + "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", + "dev": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "dev": true, + "requires": { + "parse-passwd": "1.0.0" + } + }, + "htmlescape": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", + "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", + "dev": true + }, + "http-browserify": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/http-browserify/-/http-browserify-1.7.0.tgz", + "integrity": "sha1-M3la3nLfiKz7/TZ3PO/tp2RzWyA=", + "dev": true, + "requires": { + "Base64": "0.2.1", + "inherits": "2.0.3" + } + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "dev": true, + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + } + }, + "http-proxy": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.16.2.tgz", + "integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=", + "dev": true, + "requires": { + "eventemitter3": "1.2.0", + "requires-port": "1.0.0" + }, + "dependencies": { + "eventemitter3": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", + "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", + "dev": true + } + } + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "dev": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "https-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", + "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "dev": true + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "dev": true + }, + "ignore": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz", + "integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "dev": true + }, + "inline-source-map": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", + "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", + "dev": true, + "requires": { + "source-map": "0.5.7" + } + }, + "inquirer": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", + "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "dev": true, + "requires": { + "ansi-escapes": "1.4.0", + "ansi-regex": "2.1.1", + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-width": "2.2.0", + "figures": "1.7.0", + "lodash": "4.17.4", + "readline2": "1.0.1", + "run-async": "0.1.0", + "rx-lite": "3.1.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "through": "2.3.8" + } + }, + "insert-module-globals": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", + "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.7.2", + "concat-stream": "1.5.2", + "is-buffer": "1.1.5", + "lexical-scope": "1.2.0", + "process": "0.11.10", + "through2": "2.0.3", + "xtend": "4.0.1" + } + }, + "interpret": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.4.tgz", + "integrity": "sha1-ggzdWIuGj/sZGoCVBtbJyPISsbA=", + "dev": true + }, + "invariant": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz", + "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", + "dev": true, + "requires": { + "loose-envify": "1.3.1" + } + }, + "irregular-plurals": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.3.0.tgz", + "integrity": "sha512-njf5A+Mxb3kojuHd1DzISjjIl+XhyzovXEOyPPSzdQozq/Lf2tN27mOrAAsxEPZxpn6I4MGzs1oo9TxXxPFpaA==", + "dev": true + }, + "is-absolute": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", + "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", + "dev": true, + "requires": { + "is-relative": "0.2.1", + "is-windows": "0.2.0" + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "1.10.0" + } + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "is-dotfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", + "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", + "dev": true + }, + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", + "dev": true, + "requires": { + "is-primitive": "2.0.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } + }, + "is-my-json-valid": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz", + "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==", + "dev": true, + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" + } + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "dev": true, + "requires": { + "is-path-inside": "1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", + "dev": true + }, + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true + }, + "is-relative": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", + "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", + "dev": true, + "requires": { + "is-unc-path": "0.1.2" + } + }, + "is-resolvable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", + "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "dev": true, + "requires": { + "tryit": "1.0.3" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-unc-path": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", + "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", + "dev": true, + "requires": { + "unc-path-regex": "0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-windows": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", + "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isbinaryfile": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", + "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "istanbul": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "dev": true, + "requires": { + "abbrev": "1.0.9", + "async": "1.5.2", + "escodegen": "1.8.1", + "esprima": "2.7.3", + "glob": "5.0.15", + "handlebars": "4.0.10", + "js-yaml": "3.6.1", + "mkdirp": "0.5.1", + "nopt": "3.0.6", + "once": "1.4.0", + "resolve": "1.1.7", + "supports-color": "3.2.3", + "which": "1.3.0", + "wordwrap": "1.0.0" + }, + "dependencies": { + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "1.0.0" + } + } + } + }, + "js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=", + "dev": true + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.6.1.tgz", + "integrity": "sha1-bl/mfYsgXOTSL60Ft3geja3MSzA=", + "dev": true, + "requires": { + "argparse": "1.0.9", + "esprima": "2.7.3" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true, + "optional": true + }, + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-stable-stringify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", + "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "dev": true + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "karma": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz", + "integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==", + "dev": true, + "requires": { + "bluebird": "3.5.1", + "body-parser": "1.18.2", + "chokidar": "1.7.0", + "colors": "1.1.2", + "combine-lists": "1.0.1", + "connect": "3.6.5", + "core-js": "2.5.1", + "di": "0.0.1", + "dom-serialize": "2.2.1", + "expand-braces": "0.1.2", + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "http-proxy": "1.16.2", + "isbinaryfile": "3.0.2", + "lodash": "3.10.1", + "log4js": "0.6.38", + "mime": "1.4.1", + "minimatch": "3.0.4", + "optimist": "0.6.1", + "qjobs": "1.1.5", + "range-parser": "1.2.0", + "rimraf": "2.6.2", + "safe-buffer": "5.1.1", + "socket.io": "1.7.3", + "source-map": "0.5.7", + "tmp": "0.0.31", + "useragent": "2.2.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + } + } + }, + "karma-browserify": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-4.4.2.tgz", + "integrity": "sha1-QS7h/GMy7SSJ2Ax5l8qjzms61GE=", + "dev": true, + "requires": { + "browserify": "10.2.3", + "convert-source-map": "0.3.5", + "hat": "0.0.3", + "js-string-escape": "1.0.1", + "lodash": "3.10.1", + "minimatch": "1.0.0", + "os-shim": "0.1.3", + "watchify": "3.2.1" + }, + "dependencies": { + "assert": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.3.0.tgz", + "integrity": "sha1-A5OaYiWCqBLMICMgoLmlbJuBWEk=", + "dev": true, + "requires": { + "util": "0.10.3" + } + }, + "base64-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", + "integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=", + "dev": true + }, + "browser-pack": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz", + "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.6.1", + "defined": "1.0.0", + "through2": "1.1.1", + "umd": "3.0.1" + } + }, + "browserify": { + "version": "10.2.3", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-10.2.3.tgz", + "integrity": "sha1-9qGNTWqzERP5/fg/ED+gFyioIGo=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "assert": "1.3.0", + "browser-pack": "5.0.1", + "browser-resolve": "1.11.2", + "browserify-zlib": "0.1.4", + "buffer": "3.6.0", + "builtins": "0.0.7", + "commondir": "0.0.1", + "concat-stream": "1.4.10", + "console-browserify": "1.1.0", + "constants-browserify": "0.0.1", + "crypto-browserify": "3.11.1", + "deep-equal": "1.0.1", + "defined": "1.0.0", + "deps-sort": "1.3.9", + "domain-browser": "1.1.7", + "duplexer2": "0.0.2", + "events": "1.0.2", + "glob": "4.5.3", + "has": "1.0.1", + "htmlescape": "1.1.1", + "http-browserify": "1.7.0", + "https-browserify": "0.0.1", + "inherits": "2.0.3", + "insert-module-globals": "6.6.3", + "isarray": "0.0.1", + "labeled-stream-splicer": "1.0.2", + "module-deps": "3.9.1", + "os-browserify": "0.1.2", + "parents": "1.0.1", + "path-browserify": "0.0.0", + "process": "0.11.10", + "punycode": "1.4.1", + "querystring-es3": "0.2.1", + "read-only-stream": "1.1.1", + "readable-stream": "1.1.14", + "resolve": "1.4.0", + "shasum": "1.0.2", + "shell-quote": "0.0.1", + "stream-browserify": "1.0.0", + "string_decoder": "0.10.31", + "subarg": "1.0.0", + "syntax-error": "1.3.0", + "through2": "1.1.1", + "timers-browserify": "1.4.2", + "tty-browserify": "0.0.0", + "url": "0.10.3", + "util": "0.10.3", + "vm-browserify": "0.0.4", + "xtend": "4.0.1" + } + }, + "buffer": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", + "integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=", + "dev": true, + "requires": { + "base64-js": "0.0.8", + "ieee754": "1.1.8", + "isarray": "1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "combine-source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz", + "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", + "dev": true, + "requires": { + "convert-source-map": "1.1.3", + "inline-source-map": "0.5.0", + "lodash.memoize": "3.0.4", + "source-map": "0.4.4" + }, + "dependencies": { + "convert-source-map": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", + "dev": true + } + } + }, + "concat-stream": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.10.tgz", + "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "1.1.14", + "typedarray": "0.0.6" + } + }, + "constants-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-0.0.1.tgz", + "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", + "dev": true + }, + "convert-source-map": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-0.3.5.tgz", + "integrity": "sha1-8dgClQr33SYxof6+BZZVDIarMZA=", + "dev": true + }, + "deps-sort": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-1.3.9.tgz", + "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "shasum": "1.0.2", + "subarg": "1.0.0", + "through2": "1.1.1" + } + }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "events": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/events/-/events-1.0.2.tgz", + "integrity": "sha1-dYSdz+k9EPsFfDAFWv29UdBqjiQ=", + "dev": true + }, + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.4.0" + }, + "dependencies": { + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, + "inline-source-map": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz", + "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", + "dev": true, + "requires": { + "source-map": "0.4.4" + } + }, + "insert-module-globals": { + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-6.6.3.tgz", + "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.6.1", + "concat-stream": "1.4.10", + "is-buffer": "1.1.5", + "lexical-scope": "1.2.0", + "process": "0.11.10", + "through2": "1.1.1", + "xtend": "4.0.1" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "labeled-stream-splicer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz", + "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "isarray": "0.0.1", + "stream-splicer": "1.3.2" + } + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + }, + "minimatch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", + "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=", + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } + }, + "module-deps": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-3.9.1.tgz", + "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "browser-resolve": "1.11.2", + "concat-stream": "1.4.10", + "defined": "1.0.0", + "detective": "4.5.0", + "duplexer2": "0.0.2", + "inherits": "2.0.3", + "parents": "1.0.1", + "readable-stream": "1.1.14", + "resolve": "1.4.0", + "stream-combiner2": "1.0.2", + "subarg": "1.0.0", + "through2": "1.1.1", + "xtend": "4.0.1" + } + }, + "read-only-stream": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-1.1.1.tgz", + "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "readable-wrap": "1.0.0" + } + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "shell-quote": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-0.0.1.tgz", + "integrity": "sha1-GkEZbzwDM8SCMjWT1ohuzxU92YY=", + "dev": true + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + }, + "stream-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-1.0.0.tgz", + "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "1.1.14" + } + }, + "stream-combiner2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.0.2.tgz", + "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", + "dev": true, + "requires": { + "duplexer2": "0.0.2", + "through2": "0.5.1" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", + "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "3.0.0" + } + }, + "xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", + "dev": true + } + } + }, + "stream-splicer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz", + "integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=", + "dev": true, + "requires": { + "indexof": "0.0.1", + "inherits": "2.0.3", + "isarray": "0.0.1", + "readable-stream": "1.1.14", + "readable-wrap": "1.0.0", + "through2": "1.1.1" + } + }, + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + } + } + }, + "karma-chrome-launcher": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", + "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", + "dev": true, + "requires": { + "fs-access": "1.0.1", + "which": "1.3.0" + } + }, + "karma-expect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/karma-expect/-/karma-expect-1.1.3.tgz", + "integrity": "sha1-xrClb/GJA9sRr08JjMbnzxmM4nU=", + "dev": true, + "requires": { + "expect.js": "0.3.1" + } + }, + "karma-firefox-launcher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.0.1.tgz", + "integrity": "sha1-zlj0fCATqIFW1VpdYTN8CZz1u1E=", + "dev": true + }, + "karma-mocha": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-1.3.0.tgz", + "integrity": "sha1-7qrH/8DiAetjxGdEDStpx883eL8=", + "dev": true, + "requires": { + "minimist": "1.2.0" + } + }, + "karma-phantomjs-launcher": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", + "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", + "dev": true, + "requires": { + "lodash": "4.17.4", + "phantomjs-prebuilt": "2.1.15" + }, + "dependencies": { + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "dev": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "dev": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "phantomjs-prebuilt": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.15.tgz", + "integrity": "sha1-IPhugtM0nFBZF1J3RbekEeCLOQM=", + "dev": true, + "requires": { + "es6-promise": "4.0.5", + "extract-zip": "1.6.5", + "fs-extra": "1.0.0", + "hasha": "2.2.0", + "kew": "0.7.0", + "progress": "1.1.8", + "request": "2.81.0", + "request-progress": "2.0.1", + "which": "1.2.14" + } + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "dev": true + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "dev": true + }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + } + } + }, + "kew": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", + "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + }, + "klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, + "labeled-stream-splicer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", + "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "isarray": "0.0.1", + "stream-splicer": "2.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "lazy-debug-legacy": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/lazy-debug-legacy/-/lazy-debug-legacy-0.0.1.tgz", + "integrity": "sha1-U3cWwHduTPeePtG2IfdljCkRsbE=", + "dev": true + }, + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "lexical-scope": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", + "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", + "dev": true, + "requires": { + "astw": "2.2.0" + } + }, + "liftoff": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", + "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", + "dev": true, + "requires": { + "extend": "3.0.1", + "findup-sync": "0.4.3", + "fined": "1.1.0", + "flagged-respawn": "0.3.2", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.mapvalues": "4.6.0", + "rechoir": "0.6.2", + "resolve": "1.4.0" + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash.keys": "3.1.2" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", + "dev": true + }, + "lodash._basetostring": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "dev": true + }, + "lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._reescape": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", + "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "dev": true + }, + "lodash._reevaluate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", + "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash._root": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", + "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "dev": true + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "dev": true, + "requires": { + "lodash._baseassign": "3.2.0", + "lodash._basecreate": "3.0.3", + "lodash._isiterateecall": "3.0.9" + } + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "3.0.1" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "dev": true + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.mapvalues": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", + "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", + "dev": true + }, + "lodash.memoize": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", + "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", + "dev": true + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" + } + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } + }, + "log-driver": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.5.tgz", + "integrity": "sha1-euTsJXMC/XkNVXyxDJcQDYV7AFY=", + "dev": true + }, + "log4js": { + "version": "0.6.38", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", + "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "semver": "4.3.6" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + } + } + }, + "lolex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", + "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loose-envify": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", + "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "dev": true, + "requires": { + "js-tokens": "3.0.2" + } + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "make-error": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", + "integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=", + "dev": true + }, + "make-error-cause": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz", + "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=", + "dev": true, + "requires": { + "make-error": "1.3.0" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "dev": true, + "requires": { + "hash-base": "3.0.4", + "inherits": "2.0.3" + }, + "dependencies": { + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + } + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "dev": true, + "requires": { + "arr-diff": "2.0.0", + "array-unique": "0.2.1", + "braces": "1.8.5", + "expand-brackets": "0.1.5", + "extglob": "0.3.2", + "filename-regex": "2.0.1", + "is-extglob": "1.0.0", + "is-glob": "2.0.1", + "kind-of": "3.2.2", + "normalize-path": "2.1.1", + "object.omit": "2.0.1", + "parse-glob": "3.0.4", + "regex-cache": "0.4.4" + } + }, + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "brorand": "1.1.0" + } + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "dev": true + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", + "dev": true + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "dev": true, + "requires": { + "mime-db": "1.30.0" + } + }, + "minimalistic-assert": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", + "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "dev": true + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "mocha": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", + "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.9.0", + "debug": "2.6.8", + "diff": "3.2.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.1", + "growl": "1.9.2", + "he": "1.1.1", + "json3": "3.3.2", + "lodash.create": "3.1.1", + "mkdirp": "0.5.1", + "supports-color": "3.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "1.0.0" + } + } + } + }, + "modify-babel-preset": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/modify-babel-preset/-/modify-babel-preset-3.2.1.tgz", + "integrity": "sha1-1xcqo8CCLtP8COMI/QlxKVE2q1A=", + "dev": true, + "requires": { + "require-relative": "0.8.7" + } + }, + "module-deps": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", + "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "browser-resolve": "1.11.2", + "cached-path-relative": "1.0.1", + "concat-stream": "1.5.2", + "defined": "1.0.0", + "detective": "4.5.0", + "duplexer2": "0.1.4", + "inherits": "2.0.3", + "parents": "1.0.1", + "readable-stream": "2.3.3", + "resolve": "1.4.0", + "stream-combiner2": "1.1.1", + "subarg": "1.0.0", + "through2": "2.0.3", + "xtend": "4.0.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "dev": true, + "requires": { + "duplexer2": "0.0.2" + }, + "dependencies": { + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + } + } + }, + "mute-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", + "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "dev": true + }, + "nan": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", + "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=", + "dev": true, + "optional": true + }, + "native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=" + }, + "natives": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", + "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "dev": true + }, + "node-uuid": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", + "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", + "dev": true + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1.0.9" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "1.1.0" + } + }, + "null-check": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", + "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", + "dev": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", + "dev": true + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "dev": true, + "requires": { + "array-each": "1.0.1", + "array-slice": "1.0.0", + "for-own": "1.0.0", + "isobject": "3.0.1" + }, + "dependencies": { + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dev": true, + "requires": { + "for-in": "1.0.2" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", + "dev": true, + "requires": { + "for-own": "0.1.5", + "is-extendable": "0.1.1" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "0.0.10", + "wordwrap": "0.0.3" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + } + }, + "options": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", + "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", + "dev": true + }, + "orchestrator": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", + "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "dev": true, + "requires": { + "end-of-stream": "0.1.5", + "sequencify": "0.0.7", + "stream-consume": "0.1.0" + } + }, + "ordered-read-streams": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", + "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", + "dev": true + }, + "os-browserify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", + "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-shim": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", + "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "outpipe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", + "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", + "dev": true, + "requires": { + "shell-quote": "1.6.1" + } + }, + "pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "parents": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", + "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", + "dev": true, + "requires": { + "path-platform": "0.11.15" + } + }, + "parse-asn1": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", + "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "dev": true, + "requires": { + "asn1.js": "4.9.1", + "browserify-aes": "1.0.8", + "create-hash": "1.1.3", + "evp_bytestokey": "1.0.3", + "pbkdf2": "3.0.14" + } + }, + "parse-filepath": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", + "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", + "dev": true, + "requires": { + "is-absolute": "0.2.6", + "map-cache": "0.2.2", + "path-root": "0.1.1" + } + }, + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", + "dev": true, + "requires": { + "glob-base": "0.3.0", + "is-dotfile": "1.0.3", + "is-extglob": "1.0.0", + "is-glob": "2.0.1" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "parsejson": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz", + "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=", + "dev": true, + "requires": { + "better-assert": "1.0.2" + } + }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "dev": true, + "requires": { + "better-assert": "1.0.2" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "dev": true, + "requires": { + "better-assert": "1.0.2" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "dev": true + }, + "path-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "dev": true + }, + "path-platform": { + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", + "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", + "dev": true + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "dev": true, + "requires": { + "path-root-regex": "0.1.2" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "dev": true + }, + "pbkdf2": { + "version": "3.0.14", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", + "integrity": "sha512-gjsZW9O34fm0R7PaLHRJmLLVfSoesxztjPjE9o6R+qtVJij90ltg1joIovN9GKrRW3t1PzhDDG3UMEMFfZ+1wA==", + "dev": true, + "requires": { + "create-hash": "1.1.3", + "create-hmac": "1.1.6", + "ripemd160": "2.0.1", + "safe-buffer": "5.1.1", + "sha.js": "2.4.9" + } + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", + "dev": true + }, + "phantomjs": { + "version": "1.9.20", + "resolved": "https://registry.npmjs.org/phantomjs/-/phantomjs-1.9.20.tgz", + "integrity": "sha1-RCSsog4U0lXAsIia9va4lz2hDg0=", + "dev": true, + "requires": { + "extract-zip": "1.5.0", + "fs-extra": "0.26.7", + "hasha": "2.2.0", + "kew": "0.7.0", + "progress": "1.1.8", + "request": "2.67.0", + "request-progress": "2.0.1", + "which": "1.2.14" + }, + "dependencies": { + "bl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", + "integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=", + "dev": true, + "requires": { + "readable-stream": "2.0.6" + } + }, + "concat-stream": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.0.tgz", + "integrity": "sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.0.6", + "typedarray": "0.0.6" + } + }, + "debug": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", + "integrity": "sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk=", + "dev": true + }, + "extract-zip": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.5.0.tgz", + "integrity": "sha1-ksz22B73Cp+kwXRxFMzvbYaIpsQ=", + "dev": true, + "requires": { + "concat-stream": "1.5.0", + "debug": "0.7.4", + "mkdirp": "0.5.0", + "yauzl": "2.4.1" + } + }, + "fs-extra": { + "version": "0.26.7", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", + "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "2.4.0", + "klaw": "1.3.1", + "path-is-absolute": "1.0.1", + "rimraf": "2.6.2" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", + "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "qs": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.1.tgz", + "integrity": "sha1-gB/uAw4LlFDWOFrcSKTMVbRK7fw=", + "dev": true + }, + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.67.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.67.0.tgz", + "integrity": "sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I=", + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "bl": "1.0.3", + "caseless": "0.11.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "1.0.1", + "har-validator": "2.0.6", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "node-uuid": "1.4.8", + "oauth-sign": "0.8.2", + "qs": "5.2.1", + "stringstream": "0.0.5", + "tough-cookie": "2.2.2", + "tunnel-agent": "0.4.3" + } + }, + "tough-cookie": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", + "integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=", + "dev": true + }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + } + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + }, + "plur": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", + "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", + "dev": true, + "requires": { + "irregular-plurals": "1.3.0" + } + }, + "pluralize": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", + "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", + "dev": true + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", + "dev": true + }, + "private": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", + "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=", + "dev": true + }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, + "public-encrypt": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", + "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "browserify-rsa": "4.0.1", + "create-hash": "1.1.3", + "parse-asn1": "5.1.0", + "randombytes": "2.0.5" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "qjobs": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.1.5.tgz", + "integrity": "sha1-ZZ3p8s+NzCehSBJ28gU3cnI4LnM=", + "dev": true + }, + "qs": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.3.tgz", + "integrity": "sha1-HPyyXBCpsrSDBT/zn138kjOQjP4=", + "dev": true + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, + "querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "dev": true + }, + "randomatic": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "dev": true, + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "randombytes": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", + "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "dev": true + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "dev": true, + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + } + }, + "read-only-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", + "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + }, + "dependencies": { + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, + "readable-wrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/readable-wrap/-/readable-wrap-1.0.0.tgz", + "integrity": "sha1-O1ohHGMeEjA6VJkcgGwX564ga/8=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + } + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.3", + "set-immediate-shim": "1.0.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "readline2": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", + "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "mute-stream": "0.0.5" + } + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "dev": true, + "requires": { + "resolve": "1.4.0" + } + }, + "regenerate": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz", + "integrity": "sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz", + "integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A==", + "dev": true + }, + "regenerator-transform": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", + "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "private": "0.1.7" + } + }, + "regex-cache": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", + "dev": true, + "requires": { + "is-equal-shallow": "0.1.3" + } + }, + "regexpu-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", + "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", + "dev": true, + "requires": { + "regenerate": "1.3.3", + "regjsgen": "0.2.0", + "regjsparser": "0.1.5" + } + }, + "regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", + "dev": true + }, + "regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "dev": true, + "requires": { + "jsesc": "0.5.0" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + }, + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + }, + "req-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/req-cwd/-/req-cwd-1.0.1.tgz", + "integrity": "sha1-DXOurpJm5penj3l2AZZ352rPD/8=", + "dev": true, + "requires": { + "req-from": "1.0.1" + } + }, + "req-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/req-from/-/req-from-1.0.1.tgz", + "integrity": "sha1-v4HaUUeUfTLRO5R9wSpYrUWHNQ4=", + "dev": true, + "requires": { + "resolve-from": "2.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=", + "dev": true + } + } + }, + "request": { + "version": "2.74.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", + "integrity": "sha1-dpPKdou7DqXIzgjAhKRe+gW4kqs=", + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "bl": "1.1.2", + "caseless": "0.11.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "1.0.1", + "har-validator": "2.0.6", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "node-uuid": "1.4.8", + "oauth-sign": "0.8.2", + "qs": "6.2.3", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.4.3" + } + }, + "request-progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", + "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", + "dev": true, + "requires": { + "throttleit": "1.0.0" + } + }, + "require-relative": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", + "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", + "dev": true + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + } + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", + "dev": true + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } + }, + "resolve-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", + "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", + "dev": true, + "requires": { + "expand-tilde": "1.2.2", + "global-modules": "0.2.3" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "0.1.4" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "ripemd160": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", + "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "dev": true, + "requires": { + "hash-base": "2.0.2", + "inherits": "2.0.3" + } + }, + "run-async": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", + "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "samsam": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", + "integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc=", + "dev": true + }, + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "dev": true + }, + "sequencify": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", + "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", + "dev": true + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", + "dev": true + }, + "sha.js": { + "version": "2.4.9", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", + "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "dev": true, + "requires": { + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "shasum": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", + "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", + "dev": true, + "requires": { + "json-stable-stringify": "0.0.1", + "sha.js": "2.4.9" + } + }, + "shell-quote": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", + "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", + "dev": true, + "requires": { + "array-filter": "0.0.1", + "array-map": "0.0.0", + "array-reduce": "0.0.0", + "jsonify": "0.0.0" + } + }, + "shelljs": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", + "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", + "dev": true, + "requires": { + "glob": "7.1.2", + "interpret": "1.0.4", + "rechoir": "0.6.2" + } + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "sinon": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", + "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", + "dev": true, + "requires": { + "formatio": "1.1.1", + "lolex": "1.3.2", + "samsam": "1.1.2", + "util": "0.10.3" + } + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "socket.io": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-1.7.3.tgz", + "integrity": "sha1-uK+cq6AJSeVo42nxMn6pvp6iRhs=", + "dev": true, + "requires": { + "debug": "2.3.3", + "engine.io": "1.8.3", + "has-binary": "0.1.7", + "object-assign": "4.1.0", + "socket.io-adapter": "0.5.0", + "socket.io-client": "1.7.3", + "socket.io-parser": "2.3.1" + }, + "dependencies": { + "debug": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", + "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "dev": true, + "requires": { + "ms": "0.7.2" + } + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + }, + "object-assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", + "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=", + "dev": true + } + } + }, + "socket.io-adapter": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz", + "integrity": "sha1-y21LuL7IHhB4uZZ3+c7QBGBmu4s=", + "dev": true, + "requires": { + "debug": "2.3.3", + "socket.io-parser": "2.3.1" + }, + "dependencies": { + "debug": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", + "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "dev": true, + "requires": { + "ms": "0.7.2" + } + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "socket.io-client": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-1.7.3.tgz", + "integrity": "sha1-sw6GqhDV7zVGYBwJzeR2Xjgdo3c=", + "dev": true, + "requires": { + "backo2": "1.0.2", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "2.3.3", + "engine.io-client": "1.8.3", + "has-binary": "0.1.7", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseuri": "0.0.5", + "socket.io-parser": "2.3.1", + "to-array": "0.1.4" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "debug": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", + "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "dev": true, + "requires": { + "ms": "0.7.2" + } + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "socket.io-parser": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz", + "integrity": "sha1-3VMgJRA85Clpcya+/WQAX8/ltKA=", + "dev": true, + "requires": { + "component-emitter": "1.1.2", + "debug": "2.2.0", + "isarray": "0.0.1", + "json3": "3.3.2" + }, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-resolve": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", + "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", + "dev": true, + "requires": { + "atob": "1.1.3", + "resolve-url": "0.2.1", + "source-map-url": "0.3.0", + "urix": "0.1.0" + } + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "dev": true, + "requires": { + "source-map": "0.5.7" + } + }, + "source-map-url": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", + "integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=", + "dev": true + }, + "sparkles": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", + "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "dev": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + }, + "stream-browserify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3" + } + }, + "stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", + "dev": true, + "requires": { + "duplexer2": "0.1.4", + "readable-stream": "2.3.3" + } + }, + "stream-consume": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", + "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", + "dev": true + }, + "stream-http": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", + "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "dev": true, + "requires": { + "builtin-status-codes": "3.0.0", + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "to-arraybuffer": "1.0.1", + "xtend": "4.0.1" + } + }, + "stream-splicer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", + "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-bom": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", + "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "dev": true, + "requires": { + "first-chunk-stream": "1.0.0", + "is-utf8": "0.2.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "subarg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", + "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", + "dev": true, + "requires": { + "minimist": "1.2.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "syntax-error": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", + "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "dev": true, + "requires": { + "acorn": "4.0.13" + } + }, + "table": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "dev": true, + "requires": { + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.4", + "slice-ansi": "0.0.4", + "string-width": "2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "temp": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", + "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2", + "rimraf": "2.2.8" + }, + "dependencies": { + "rimraf": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", + "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", + "dev": true + } + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "throttleit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", + "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "tildify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", + "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } + }, + "time-stamp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "dev": true + }, + "timers-browserify": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", + "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", + "dev": true, + "requires": { + "process": "0.11.10" + } + }, + "tmp": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", + "dev": true + }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + }, + "tough-cookie": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", + "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "dev": true, + "requires": { + "punycode": "1.4.1" + } + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, + "tryit": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", + "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", + "dev": true + }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "dev": true + }, + "tunnel-agent": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "dev": true + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true, + "optional": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2" + } + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "dev": true, + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.17" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + } + }, + "uglify-save-license": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", + "integrity": "sha1-lXJsF8xv0XHDYX479NjYKqjEzOE=", + "dev": true + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "ultron": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", + "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po=", + "dev": true + }, + "umd": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", + "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "dev": true + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "dev": true + }, + "unique-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", + "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "dev": true + }, + "useragent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.2.1.tgz", + "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=", + "dev": true, + "requires": { + "lru-cache": "2.2.4", + "tmp": "0.0.31" + }, + "dependencies": { + "lru-cache": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", + "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=", + "dev": true + } + } + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "dev": true + }, + "v8flags": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", + "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "dev": true, + "requires": { + "user-home": "1.1.1" + } + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + }, + "vinyl-fs": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", + "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", + "dev": true, + "requires": { + "defaults": "1.0.3", + "glob-stream": "3.1.18", + "glob-watcher": "0.0.6", + "graceful-fs": "3.0.11", + "mkdirp": "0.5.1", + "strip-bom": "1.0.0", + "through2": "0.6.5", + "vinyl": "0.4.6" + }, + "dependencies": { + "clone": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } + }, + "vinyl": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true, + "requires": { + "clone": "0.2.0", + "clone-stats": "0.0.1" + } + } + } + }, + "vinyl-source-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-1.1.0.tgz", + "integrity": "sha1-RMvlEIIFJ53rDFZTwJSiiHk4sas=", + "dev": true, + "requires": { + "through2": "0.6.5", + "vinyl": "0.4.6" + }, + "dependencies": { + "clone": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } + }, + "vinyl": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true, + "requires": { + "clone": "0.2.0", + "clone-stats": "0.0.1" + } + } + } + }, + "vinyl-sourcemaps-apply": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", + "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "dev": true, + "requires": { + "source-map": "0.5.7" + } + }, + "vm-browserify": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "dev": true, + "requires": { + "indexof": "0.0.1" + } + }, + "void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "dev": true + }, + "watchify": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.2.1.tgz", + "integrity": "sha1-Gbz9e/y/Qdf0/jwpdAvORfdk4gM=", + "dev": true, + "requires": { + "browserify": "10.2.6", + "chokidar": "1.7.0", + "defined": "1.0.0", + "outpipe": "1.1.1", + "through2": "0.6.5", + "xtend": "4.0.1" + }, + "dependencies": { + "assert": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.3.0.tgz", + "integrity": "sha1-A5OaYiWCqBLMICMgoLmlbJuBWEk=", + "dev": true, + "requires": { + "util": "0.10.3" + } + }, + "base64-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", + "integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=", + "dev": true + }, + "browser-pack": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz", + "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.6.1", + "defined": "1.0.0", + "through2": "1.1.1", + "umd": "3.0.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "browserify": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-10.2.6.tgz", + "integrity": "sha1-3L/veU9Uj1+EmCFIFPaXpcUMCJY=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "assert": "1.3.0", + "browser-pack": "5.0.1", + "browser-resolve": "1.11.2", + "browserify-zlib": "0.1.4", + "buffer": "3.6.0", + "builtins": "0.0.7", + "commondir": "0.0.1", + "concat-stream": "1.4.10", + "console-browserify": "1.1.0", + "constants-browserify": "0.0.1", + "crypto-browserify": "3.11.1", + "defined": "1.0.0", + "deps-sort": "1.3.9", + "domain-browser": "1.1.7", + "duplexer2": "0.0.2", + "events": "1.0.2", + "glob": "4.5.3", + "has": "1.0.1", + "htmlescape": "1.1.1", + "http-browserify": "1.7.0", + "https-browserify": "0.0.1", + "inherits": "2.0.3", + "insert-module-globals": "6.6.3", + "isarray": "0.0.1", + "labeled-stream-splicer": "1.0.2", + "module-deps": "3.9.1", + "os-browserify": "0.1.2", + "parents": "1.0.1", + "path-browserify": "0.0.0", + "process": "0.11.10", + "punycode": "1.4.1", + "querystring-es3": "0.2.1", + "read-only-stream": "1.1.1", + "readable-stream": "1.1.14", + "resolve": "1.4.0", + "shasum": "1.0.2", + "shell-quote": "0.0.1", + "stream-browserify": "1.0.0", + "string_decoder": "0.10.31", + "subarg": "1.0.0", + "syntax-error": "1.3.0", + "through2": "1.1.1", + "timers-browserify": "1.4.2", + "tty-browserify": "0.0.0", + "url": "0.10.3", + "util": "0.10.3", + "vm-browserify": "0.0.4", + "xtend": "4.0.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "buffer": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", + "integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=", + "dev": true, + "requires": { + "base64-js": "0.0.8", + "ieee754": "1.1.8", + "isarray": "1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "combine-source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz", + "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", + "dev": true, + "requires": { + "convert-source-map": "1.1.3", + "inline-source-map": "0.5.0", + "lodash.memoize": "3.0.4", + "source-map": "0.4.4" + } + }, + "concat-stream": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.10.tgz", + "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "1.1.14", + "typedarray": "0.0.6" + } + }, + "constants-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-0.0.1.tgz", + "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", + "dev": true + }, + "deps-sort": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-1.3.9.tgz", + "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "shasum": "1.0.2", + "subarg": "1.0.0", + "through2": "1.1.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "events": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/events/-/events-1.0.2.tgz", + "integrity": "sha1-dYSdz+k9EPsFfDAFWv29UdBqjiQ=", + "dev": true + }, + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.4.0" + } + }, + "inline-source-map": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz", + "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", + "dev": true, + "requires": { + "source-map": "0.4.4" + } + }, + "insert-module-globals": { + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-6.6.3.tgz", + "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "combine-source-map": "0.6.1", + "concat-stream": "1.4.10", + "is-buffer": "1.1.5", + "lexical-scope": "1.2.0", + "process": "0.11.10", + "through2": "1.1.1", + "xtend": "4.0.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "labeled-stream-splicer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz", + "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "isarray": "0.0.1", + "stream-splicer": "1.3.2" + } + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "module-deps": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-3.9.1.tgz", + "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", + "dev": true, + "requires": { + "JSONStream": "1.3.1", + "browser-resolve": "1.11.2", + "concat-stream": "1.4.10", + "defined": "1.0.0", + "detective": "4.5.0", + "duplexer2": "0.0.2", + "inherits": "2.0.3", + "parents": "1.0.1", + "readable-stream": "1.1.14", + "resolve": "1.4.0", + "stream-combiner2": "1.0.2", + "subarg": "1.0.0", + "through2": "1.1.1", + "xtend": "4.0.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "read-only-stream": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-1.1.1.tgz", + "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "readable-wrap": "1.0.0" + } + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "shell-quote": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-0.0.1.tgz", + "integrity": "sha1-GkEZbzwDM8SCMjWT1ohuzxU92YY=", + "dev": true + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + }, + "stream-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-1.0.0.tgz", + "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "1.1.14" + } + }, + "stream-combiner2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.0.2.tgz", + "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", + "dev": true, + "requires": { + "duplexer2": "0.0.2", + "through2": "0.5.1" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", + "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "3.0.0" + } + }, + "xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", + "dev": true + } + } + }, + "stream-splicer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz", + "integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=", + "dev": true, + "requires": { + "indexof": "0.0.1", + "inherits": "2.0.3", + "isarray": "0.0.1", + "readable-stream": "1.1.14", + "readable-wrap": "1.0.0", + "through2": "1.1.1" + }, + "dependencies": { + "through2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", + "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "4.0.1" + } + } + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + } + } + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + } + } + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "0.5.1" + } + }, + "ws": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-1.1.2.tgz", + "integrity": "sha1-iiRPoFJAHgjJiGz0SoUYnh/UBn8=", + "dev": true, + "requires": { + "options": "0.0.6", + "ultron": "1.0.2" + } + }, + "wtf-8": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wtf-8/-/wtf-8-1.0.0.tgz", + "integrity": "sha1-OS2LotDxw00e4tYw8V0O+2jhBIo=", + "dev": true + }, + "xmlhttprequest-ssl": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", + "integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "dev": true, + "requires": { + "fd-slicer": "1.0.1" + } + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", + "dev": true + } + } +} From f261692230a4e9ca156d3cca28dac1a92a486f0a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 24 Nov 2017 17:05:31 +0100 Subject: [PATCH 185/224] Improve functional pool test code --- test/spec/pool-functional.spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/spec/pool-functional.spec.js b/test/spec/pool-functional.spec.js index 37f67f0e..33d6932a 100644 --- a/test/spec/pool-functional.spec.js +++ b/test/spec/pool-functional.spec.js @@ -1,7 +1,9 @@ import expect from 'expect.js'; import { Pool } from '../../lib/'; -describe('Pool (functional test)', () => { +describe('Pool (functional test)', function () { + this.timeout(10000) + const pool = new Pool(); const jobs = [], promises = []; @@ -9,9 +11,9 @@ describe('Pool (functional test)', () => { done(input); }; - pool.run(handler); - it('can send data and run promisified', () => { + pool.run(handler); + for (let i = 0; i < 10; i++) { const job = pool.send(i); if (jobs.indexOf(job) > -1) { From 0edfb3aa10f1c610eebe083ad546698e418e442a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 24 Nov 2017 17:06:46 +0100 Subject: [PATCH 186/224] Change karma log-level from debug to info --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 82c9df23..588b2e60 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -48,7 +48,7 @@ module.exports = function configureKarma(config) { // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_DEBUG, + logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, From f0ad797b9a7f5d877154ca5f411969b64684c874 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 24 Nov 2017 17:33:41 +0100 Subject: [PATCH 187/224] Fix docs: basepath.browser => basepath.web (#64) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e828410..911bc544 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,8 @@ const spawn = threads.spawn; // Set base paths to thread scripts config.set({ basepath : { - browser : 'http://myserver.local/thread-scripts', - node : __dirname + '/../thread-scripts' + node : __dirname + '/../thread-scripts', + web : 'http://myserver.local/thread-scripts' } }); From fca47a7fe4ad33fcba4c521649d4c1c696942000 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Sun, 26 Nov 2017 21:46:53 +1100 Subject: [PATCH 188/224] Fix builds --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 019d470a..c7b51ea2 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,12 @@ }, "babel": { "presets": [ - "es2015", - "es2015-loose" + [ + "es2015", + { + "loose": true + } + ] ] }, "devDependencies": { From 501df40834328030e5451cc503d7f8043c9479f9 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Sun, 26 Nov 2017 21:47:54 +1100 Subject: [PATCH 189/224] Passes execArgv to the thread. When `--inspect` or `--inspect-brk` are using, it changes the flag so each thread gets a different debug port. Fixes #16 --- README.md | 19 +++++++++ src/worker.node/worker.js | 27 +++++++++++- test/spec/worker.spec.js | 86 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 911bc544..13172fb5 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,25 @@ Done. You can provide a fallback if the user's browser does not support web workers. See [webworker-fallback](https://github.com/andywer/webworker-fallback). This will not have any effect if used by node.js code. +### Debugging threads + +When the main process uses `--inspect` to debug Node.js, each thread will be started with the `--inspect` flag too, but +in a different port so they don't interfere with the main process. Each created thread will have an incremental port, so +you can create and debug as many as you want. + +This also works with `--inspect-brk`. As expected, each thread will pause on the first line when created. + +All other flags are passed to the thread unchanged. To override this behaviour, you can pass your own `execArgv` array +when creating a thread: + +```javascript +// Always open an inspect port on 1234, no matter what the main process is doing. +spawn(myThreadFile, { execArgv: ['--inspect=1234'] }) + +// Pass this flag to the thread. Ignore any other flag provided by the main process. +spawn(myThreadFile, { execArgv: ['--throw-deprecation'] }) +``` + ### Use external dependencies Not yet completely implemented. diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 2e290da7..428967dc 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -4,12 +4,37 @@ import EventEmitter from 'eventemitter3'; import { getConfig } from '../config'; +// Mutable variable with the last port used for inspect/inspect-brk. +// This value is shared among all workers. +let lastPort = 0; + +// Port used by Node.JS when there is no port specified. See +// https://nodejs.org/en/docs/inspector/#command-line-options +const DEFAULT_PORT = 9229; +const buildExecArgv = () => process.execArgv.map(arg => { + const matches = arg.match(/^(--inspect(?:-brk)?)(?:=(\d+))?/); + if (!matches) return arg; + + const command = matches[1]; + if (lastPort === 0) lastPort = Number(matches[2]) || 9229; + lastPort++; + return `${command}=${lastPort}` +}); + +// This function will reset the counter of ports used for inspect/inspect-brk. +// Used for testing. +export const resetPortCounter = () => { + lastPort = 0; +} export default class Worker extends EventEmitter { constructor(initialRunnable, options = {}) { super(); - this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options); + this.slave = child.fork(path.join(__dirname, 'slave.js'), [], Object.assign( + { execArgv: buildExecArgv() }, + options + )); this.slave.on('message', this.handleMessage.bind(this)); this.slave.on('error', this.handleError.bind(this)); this.slave.on('exit', this.emit.bind(this, 'exit')); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 69339b4e..a2eb4752 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -1,7 +1,9 @@ import async from 'async'; import expect from 'expect.js'; import sinon from 'sinon'; -import Worker from '../../lib/worker'; +import Worker, { resetPortCounter } from '../../lib/worker'; +import child_process from 'child_process'; +import EventEmitter from 'eventemitter3'; import { config, spawn } from '../../'; const env = typeof window === 'object' ? 'browser' : 'node'; @@ -231,6 +233,88 @@ describe('Worker', function () { }); }); + // Note: these tests set a value in `process.execArgv` to test it is correctly used to generate + // the values for the worker. If you run these tests in an IDE (for example, VS Code), it might + // add extra values to `process.execArgv` and it will cause unexpected results in these tests. + describe('can handle process argv', () => { + let forkStub; + class ForkMock extends EventEmitter { + send(){} + } + + beforeEach(() => { + forkStub = sinon.stub(child_process, 'fork').returns(new ForkMock()); + resetPortCounter(); + }) + + afterEach(() => { + forkStub.restore(); + }) + + it('can receive main process flags', () => { + process.execArgv=['--arg1', '--arg2']; + const worker = spawn(); + + expect(forkStub.calledOnce).to.be.ok(); + expect(forkStub.lastCall.args[2]).to.eql({ + execArgv: ['--arg1', '--arg2'] + }) + }); + + it('increments manual port for --inspect', () => { + process.execArgv=['--inspect=1234']; + const worker = spawn(); + + expect(forkStub.lastCall.args[2]).to.eql({ + execArgv: ['--inspect=1235'] + }) + }); + + it('increments manual port for --inspect-brk', () => { + process.execArgv=['--inspect-brk=1234']; + const worker = spawn(); + + expect(forkStub.lastCall.args[2]).to.eql({ + execArgv: ['--inspect-brk=1235'] + }) + }); + + it('increments default port for --inspect', () => { + process.execArgv=['--inspect']; + const worker = spawn(); + + expect(forkStub.lastCall.args[2]).to.eql({ + execArgv: ['--inspect=9230'] + }) + }); + + it('increments default port for --inspect-brk', () => { + process.execArgv=['--inspect-brk']; + const worker = spawn(); + + expect(forkStub.lastCall.args[2]).to.eql({ + execArgv: ['--inspect-brk=9230'] + }) + }); + + it('increments the port in multiple workers', () => { + process.execArgv=['--inspect']; + const worker1 = spawn(); + const worker2 = spawn(); + const worker3 = spawn(); + + expect(forkStub.firstCall.args[2]).to.eql({ execArgv: ['--inspect=9230'] }) + expect(forkStub.secondCall.args[2]).to.eql({ execArgv: ['--inspect=9231'] }) + expect(forkStub.thirdCall.args[2]).to.eql({ execArgv: ['--inspect=9232'] }) + }); + + it('can override execArgv', () => { + process.execArgv=['--inspect']; + const worker = spawn( echoThread, { execArgv: ['--my-args'] } ); + + expect(forkStub.lastCall.args[2]).to.eql({ execArgv: ['--my-args'] }) + }); + }) } From 49ef8943ac03c11b3f1caf20848d3fde38223514 Mon Sep 17 00:00:00 2001 From: Ryan Wong Date: Tue, 28 Nov 2017 11:35:06 -0800 Subject: [PATCH 190/224] Add option parameter to Pool for passing arguments to worker processes (#66) * Add optional config to workers * Add options parameter to Pool constructor for passing arguments to processes * Add unit test --- src/index.js | 4 ++-- src/pool.js | 8 ++++---- src/worker.node/worker.js | 5 +++-- test/spec/worker.spec.js | 25 ++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 8f667e2a..6b106bd7 100644 --- a/src/index.js +++ b/src/index.js @@ -7,8 +7,8 @@ import Worker from './worker'; export { config, defaults, Pool }; -export function spawn(runnable = null, importScripts = []) { - return new Worker(runnable, importScripts); +export function spawn(runnable = null, importScripts = [], options = {}) { + return new Worker(runnable, importScripts, options); } export default { diff --git a/src/pool.js b/src/pool.js index cc813aec..dc4a5b5a 100644 --- a/src/pool.js +++ b/src/pool.js @@ -4,9 +4,9 @@ import defaults from './defaults'; import { spawn } from './'; export default class Pool extends EventEmitter { - constructor(threads) { + constructor(threads, options = {}) { super(); - this.threads = Pool.spawn(threads || defaults.pool.size); + this.threads = Pool.spawn(threads || defaults.pool.size, options); this.idleThreads = this.threads.slice(); this.jobQueue = []; this.runArgs = []; @@ -81,11 +81,11 @@ export default class Pool extends EventEmitter { } } -Pool.spawn = (threadCount) => { +Pool.spawn = (threadCount, options) => { const threads = []; for (let threadIndex = 0; threadIndex < threadCount; threadIndex++) { - threads.push(spawn()); + threads.push(spawn(null, [], options)); } return threads; diff --git a/src/worker.node/worker.js b/src/worker.node/worker.js index 2e290da7..834b450b 100644 --- a/src/worker.node/worker.js +++ b/src/worker.node/worker.js @@ -6,9 +6,10 @@ import { getConfig } from '../config'; export default class Worker extends EventEmitter { - constructor(initialRunnable, options = {}) { + constructor(initialRunnable, importScripts = [], options = {}) { + // `importScripts` cannot be consumed, it's just there to keep the API compatible to the browser worker super(); - + this.slave = child.fork(path.join(__dirname, 'slave.js'), [], options); this.slave.on('message', this.handleMessage.bind(this)); this.slave.on('error', this.handleError.bind(this)); diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 69339b4e..1e1a8b8f 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -197,7 +197,6 @@ describe('Worker', function () { } }); - if (env === 'node') { it('can emit error on unhandled promise rejection', done => { @@ -231,6 +230,30 @@ describe('Worker', function () { }); }); + describe('handle option parameters', () => { + let worker; + let initialArgs; + + before(() => { + initialArgs = process.execArgv; + }); + + after(() => { + process.execArgv = initialArgs; + }); + + afterEach(() => { + worker.kill(); + }); + + it('can override options', done => { + process.execArgv=['--arg1']; + worker = spawn(null, [], { execArgv: ['--arg2'] }); + expect(worker.slave.spawnargs[1]).to.eql('--arg2'); + worker.kill(); + done(); + }); + }); } From afdee535ff34a63ce99878f7137173289850db06 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 28 Nov 2017 20:41:20 +0100 Subject: [PATCH 191/224] v0.9.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94c690e9..701a904c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.9.0 + +- Add option parameter to Pool for passing arguments to worker processes [#66](https://github.com/andywer/threads.js/pull/66), credits to https://github.com/ryanchristopherwong8 + ## 0.8.1 - Bug fix: Some outdated transpiled files were published as `v0.8.0` diff --git a/package.json b/package.json index 019d470a..6b5a66e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.8.1", + "version": "0.9.0", "keywords": [ "threads", "web worker", From 64eb6cc0c4684f0cc5a337c7d16b664c0bff27a7 Mon Sep 17 00:00:00 2001 From: Sergio Cinos Date: Sun, 3 Dec 2017 21:18:01 +1100 Subject: [PATCH 192/224] Pass options as third argument --- test/spec/worker.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/worker.spec.js b/test/spec/worker.spec.js index 2c906f2a..c7e6a609 100644 --- a/test/spec/worker.spec.js +++ b/test/spec/worker.spec.js @@ -309,7 +309,7 @@ describe('Worker', function () { it('can override execArgv', () => { process.execArgv=['--inspect']; - const worker = spawn( echoThread, { execArgv: ['--my-args'] } ); + const worker = spawn( echoThread, [], { execArgv: ['--my-args'] } ); expect(forkStub.lastCall.args[2]).to.eql({ execArgv: ['--my-args'] }) }); From 5148694546bc364ca9cd17a36eb3440f8b84752f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Dec 2017 13:22:28 +0100 Subject: [PATCH 193/224] v0.10.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 701a904c..c73c136d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.10.0 + +- Make threads debuggable / inspectable by auto-incrementing debugger ports (#68, credits to @scinos) + ## 0.9.0 - Add option parameter to Pool for passing arguments to worker processes [#66](https://github.com/andywer/threads.js/pull/66), credits to https://github.com/ryanchristopherwong8 diff --git a/package.json b/package.json index 9cb69d0f..c81a7b0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.9.0", + "version": "0.10.0", "keywords": [ "threads", "web worker", From 3103bdf37e623eed69526b36c3cf7a879318222f Mon Sep 17 00:00:00 2001 From: Keyholder Date: Fri, 19 Jan 2018 12:04:07 +0300 Subject: [PATCH 194/224] Hiding this.module.exports from importScripts in initByMethod (#72) Needed to avoid triggering of false CommonJS detection inside some modules (e.g. https://github.com/emn178/js-sha3) --- src/worker.browser/slave.js.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/worker.browser/slave.js.txt b/src/worker.browser/slave.js.txt index 4f98b109..a9ada638 100644 --- a/src/worker.browser/slave.js.txt +++ b/src/worker.browser/slave.js.txt @@ -52,12 +52,15 @@ self.onmessage = function (event) { } if (event.data.initByMethod) { - var method = event.data.method; - this.module.exports = Function.apply(null, method.args.concat(method.body)); - +   // Clear `this.module.exports` first, to avoid trouble with importScripts' CommonJS detection +   delete this.module.exports; + if (scripts && scripts.length > 0) { importScripts.apply(null, scripts); } + + var method = event.data.method; + this.module.exports = Function.apply(null, method.args.concat(method.body)); } if (event.data.doRun) { From 634d4c1f33a2dfda304ec6b029b410170f438527 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 19 Jan 2018 10:07:32 +0100 Subject: [PATCH 195/224] v0.10.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c73c136d..87c64fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.10.1 + +- Fix issue with Common JS detection in imported web worker scripts (#72, credits to @Keyholder) + ## 0.10.0 - Make threads debuggable / inspectable by auto-incrementing debugger ports (#68, credits to @scinos) diff --git a/package.json b/package.json index c81a7b0c..5c4a04bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.10.0", + "version": "0.10.1", "keywords": [ "threads", "web worker", From f647243377fdca379f283c62523be57d4682c301 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 28 Apr 2018 11:21:45 +0200 Subject: [PATCH 196/224] Update gulp for node 10 compatibility (#79) --- package-lock.json | 1526 +++++++++++++++++++++++++++++++++++++++------ package.json | 2 +- 2 files changed, 1331 insertions(+), 197 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c89854a..5b99a253 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.8.1", + "version": "0.10.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -177,6 +177,12 @@ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, "array-differ": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", @@ -208,9 +214,9 @@ "dev": true }, "array-slice": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.0.0.tgz", - "integrity": "sha1-5zA08A3MH0CHYAj9IP6ud71LfC8=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", "dev": true }, "array-union": { @@ -278,6 +284,12 @@ "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", "dev": true }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, "astw": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", @@ -892,6 +904,79 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "1.0.1", + "class-utils": "0.3.6", + "component-emitter": "1.2.1", + "define-property": "1.0.0", + "isobject": "3.0.1", + "mixin-deep": "1.3.1", + "pascalcase": "0.1.1" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "base64-arraybuffer": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", @@ -1251,6 +1336,37 @@ "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", "dev": true }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "1.0.0", + "component-emitter": "1.2.1", + "get-value": "2.0.6", + "has-value": "1.0.0", + "isobject": "3.0.1", + "set-value": "2.0.0", + "to-object-path": "0.3.0", + "union-value": "1.0.0", + "unset-value": "1.0.0" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "cached-path-relative": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", @@ -1346,6 +1462,35 @@ "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "define-property": "0.2.5", + "isobject": "3.0.1", + "static-extend": "0.1.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "cli-cursor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", @@ -1433,6 +1578,16 @@ "request": "2.74.0" } }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "1.0.0", + "object-visit": "1.0.1" + } + }, "colors": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", @@ -1589,6 +1744,12 @@ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", "dev": true }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, "core-js": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", @@ -1831,6 +1992,12 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", @@ -1852,6 +2019,59 @@ "clone": "1.0.2" } }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "1.0.2", + "isobject": "3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -1922,13 +2142,10 @@ } }, "detect-file": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", - "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", - "dev": true, - "requires": { - "fs-exists-sync": "0.1.0" - } + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "dev": true }, "detect-indent": { "version": "4.0.0", @@ -2535,12 +2752,12 @@ } }, "expand-tilde": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", - "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "homedir-polyfill": "1.0.1" } }, "expect.js": { @@ -2555,6 +2772,27 @@ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", "dev": true }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -2727,115 +2965,395 @@ "dev": true }, "findup-sync": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", - "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", - "dev": true, - "requires": { - "detect-file": "0.1.0", - "is-glob": "2.0.1", - "micromatch": "2.3.11", - "resolve-dir": "0.1.1" - } - }, - "fined": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.0.tgz", - "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", - "dev": true, - "requires": { - "expand-tilde": "2.0.2", - "is-plain-object": "2.0.4", - "object.defaults": "1.1.0", - "object.pick": "1.3.0", - "parse-filepath": "1.0.1" - }, - "dependencies": { - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "1.0.1" - } - } - } - }, - "first-chunk-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", - "dev": true - }, - "flagged-respawn": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", - "integrity": "sha1-/xke3c1wiKZ1smEP/8l2vpuAdLU=", - "dev": true - }, - "flat-cache": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", - "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", + "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", "dev": true, "requires": { - "circular-json": "0.3.3", - "del": "2.2.2", - "graceful-fs": "4.1.11", - "write": "0.2.1" + "detect-file": "1.0.0", + "is-glob": "3.1.0", + "micromatch": "3.1.10", + "resolve-dir": "1.0.1" }, "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", "dev": true - } - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "1.0.2" - } - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", - "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", - "dev": true, - "requires": { - "async": "2.5.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - }, - "dependencies": { - "async": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "1.1.0", + "array-unique": "0.3.2", + "extend-shallow": "2.0.1", + "fill-range": "4.0.0", + "isobject": "3.0.1", + "repeat-element": "1.1.2", + "snapdragon": "0.8.2", + "snapdragon-node": "2.1.1", + "split-string": "3.1.0", + "to-regex": "3.0.2" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "lodash": "4.17.4" - } - } - } + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "posix-character-classes": "0.1.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "0.3.2", + "define-property": "1.0.0", + "expand-brackets": "2.1.4", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "braces": "2.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "extglob": "2.0.4", + "fragment-cache": "0.2.1", + "kind-of": "6.0.2", + "nanomatch": "1.2.9", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + } + } + } + }, + "fined": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.0.tgz", + "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", + "dev": true, + "requires": { + "expand-tilde": "2.0.2", + "is-plain-object": "2.0.4", + "object.defaults": "1.1.0", + "object.pick": "1.3.0", + "parse-filepath": "1.0.2" + } + }, + "first-chunk-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", + "dev": true + }, + "flagged-respawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.0.tgz", + "integrity": "sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=", + "dev": true + }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "dev": true, + "requires": { + "for-in": "1.0.2" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", + "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", + "dev": true, + "requires": { + "async": "2.5.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + }, + "dependencies": { + "async": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", + "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + } + } }, "formatio": { "version": "1.1.1", @@ -2846,6 +3364,15 @@ "samsam": "1.1.2" } }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "0.2.2" + } + }, "fs-access": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", @@ -2855,12 +3382,6 @@ "null-check": "1.0.0" } }, - "fs-exists-sync": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", - "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", - "dev": true - }, "fs-extra": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", @@ -3815,6 +4336,12 @@ "is-property": "1.0.2" } }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -3949,24 +4476,26 @@ } }, "global-modules": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", - "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { - "global-prefix": "0.1.5", - "is-windows": "0.2.0" + "global-prefix": "1.0.2", + "is-windows": "1.0.2", + "resolve-dir": "1.0.1" } }, "global-prefix": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", - "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, "requires": { + "expand-tilde": "2.0.2", "homedir-polyfill": "1.0.1", - "ini": "1.3.4", - "is-windows": "0.2.0", + "ini": "1.3.5", + "is-windows": "1.0.2", "which": "1.3.0" } }, @@ -4065,7 +4594,7 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "1.1.0" + "natives": "1.1.3" } }, "graceful-readlink": { @@ -4091,7 +4620,7 @@ "deprecated": "0.0.1", "gulp-util": "3.0.8", "interpret": "1.0.4", - "liftoff": "2.3.0", + "liftoff": "2.5.0", "minimist": "1.2.0", "orchestrator": "0.3.8", "pretty-hrtime": "1.0.3", @@ -4394,6 +4923,66 @@ "sparkles": "1.0.0" } }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "1.0.0", + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + } + } + }, "hash-base": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", @@ -4593,9 +5182,9 @@ "dev": true }, "ini": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inline-source-map": { @@ -4666,13 +5255,22 @@ "dev": true }, "is-absolute": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", - "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "dev": true, + "requires": { + "is-relative": "1.0.0", + "is-windows": "1.0.2" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "is-relative": "0.2.1", - "is-windows": "0.2.0" + "kind-of": "3.2.2" } }, "is-binary-path": { @@ -4690,6 +5288,34 @@ "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", "dev": true }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "is-dotfile": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", @@ -4765,6 +5391,23 @@ "kind-of": "3.2.2" } }, + "is-odd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", + "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", + "dev": true, + "requires": { + "is-number": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -4825,12 +5468,12 @@ "dev": true }, "is-relative": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", - "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, "requires": { - "is-unc-path": "0.1.2" + "is-unc-path": "1.0.0" } }, "is-resolvable": { @@ -4855,9 +5498,9 @@ "dev": true }, "is-unc-path": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", - "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, "requires": { "unc-path-regex": "0.1.2" @@ -4870,9 +5513,9 @@ "dev": true }, "is-windows": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", - "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", "dev": true }, "isarray": { @@ -5798,18 +6441,17 @@ } }, "liftoff": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", - "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz", + "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", "dev": true, "requires": { "extend": "3.0.1", - "findup-sync": "0.4.3", + "findup-sync": "2.0.0", "fined": "1.1.0", - "flagged-respawn": "0.3.2", - "lodash.isplainobject": "4.0.6", - "lodash.isstring": "4.0.1", - "lodash.mapvalues": "4.6.0", + "flagged-respawn": "1.0.0", + "is-plain-object": "2.0.4", + "object.map": "1.0.1", "rechoir": "0.6.2", "resolve": "1.4.0" } @@ -5922,18 +6564,6 @@ "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", "dev": true }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", - "dev": true - }, - "lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", - "dev": true - }, "lodash.keys": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", @@ -5945,12 +6575,6 @@ "lodash.isarray": "3.0.4" } }, - "lodash.mapvalues": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", - "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", - "dev": true - }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -6068,12 +6692,38 @@ "make-error": "1.3.0" } }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "1.0.1" + } + }, "md5.js": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", @@ -6181,6 +6831,27 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "1.0.2", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -6341,15 +7012,55 @@ "dev": true, "optional": true }, + "nanomatch": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", + "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "fragment-cache": "0.2.1", + "is-odd": "2.0.0", + "is-windows": "1.0.2", + "kind-of": "6.0.2", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "native-promise-only": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=" }, "natives": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", - "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.3.tgz", + "integrity": "sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g==", "dev": true }, "natural-compare": { @@ -6418,6 +7129,45 @@ "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", "dev": true }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "0.1.1", + "define-property": "0.2.5", + "kind-of": "3.2.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", @@ -6425,7 +7175,7 @@ "dev": true, "requires": { "array-each": "1.0.1", - "array-slice": "1.0.0", + "array-slice": "1.1.0", "for-own": "1.0.0", "isobject": "3.0.1" }, @@ -6447,6 +7197,27 @@ } } }, + "object.map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "dev": true, + "requires": { + "for-own": "1.0.0", + "make-iterator": "1.0.1" + }, + "dependencies": { + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dev": true, + "requires": { + "for-in": "1.0.2" + } + } + } + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -6550,7 +7321,7 @@ "requires": { "end-of-stream": "0.1.5", "sequencify": "0.0.7", - "stream-consume": "0.1.0" + "stream-consume": "0.1.1" } }, "ordered-read-streams": { @@ -6621,12 +7392,12 @@ } }, "parse-filepath": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", - "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, "requires": { - "is-absolute": "0.2.6", + "is-absolute": "1.0.0", "map-cache": "0.2.2", "path-root": "0.1.1" } @@ -6682,6 +7453,12 @@ "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", "dev": true }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, "path-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", @@ -6941,6 +7718,12 @@ "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", "dev": true }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -7230,6 +8013,16 @@ "is-equal-shallow": "0.1.3" } }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2", + "safe-regex": "1.1.0" + } + }, "regexpu-core": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", @@ -7385,13 +8178,13 @@ } }, "resolve-dir": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", - "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, "requires": { - "expand-tilde": "1.2.2", - "global-modules": "0.2.3" + "expand-tilde": "2.0.2", + "global-modules": "1.0.0" } }, "resolve-from": { @@ -7416,6 +8209,12 @@ "onetime": "1.1.0" } }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, "right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", @@ -7465,6 +8264,15 @@ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "0.1.15" + } + }, "samsam": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", @@ -7489,6 +8297,29 @@ "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", "dev": true }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "split-string": "3.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } + } + }, "setprototypeof": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", @@ -7568,6 +8399,139 @@ "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "0.11.2", + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "map-cache": "0.2.2", + "source-map": "0.5.7", + "source-map-resolve": "0.5.1", + "use": "3.1.0" + }, + "dependencies": { + "atob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", + "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", + "dev": true + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "source-map-resolve": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.1.tgz", + "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", + "dev": true, + "requires": { + "atob": "2.1.1", + "decode-uri-component": "0.2.0", + "resolve-url": "0.2.1", + "source-map-url": "0.4.0", + "urix": "0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "1.0.0", + "isobject": "3.0.1", + "snapdragon-util": "3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, "sntp": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", @@ -7758,6 +8722,15 @@ "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", "dev": true }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -7788,6 +8761,27 @@ } } }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "0.2.5", + "object-copy": "0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + } + } + }, "statuses": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", @@ -7815,9 +8809,9 @@ } }, "stream-consume": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", - "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz", + "integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==", "dev": true }, "stream-http": { @@ -8059,6 +9053,48 @@ "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", "dev": true }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "regex-not": "1.0.2", + "safe-regex": "1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "3.0.0", + "repeat-string": "1.6.1" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + } + } + }, "tough-cookie": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", @@ -8166,6 +9202,41 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "get-value": "2.0.6", + "is-extendable": "0.1.1", + "set-value": "0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "to-object-path": "0.3.0" + } + } + } + }, "unique-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", @@ -8178,6 +9249,52 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "0.3.1", + "isobject": "3.0.1" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "0.1.4", + "isobject": "2.1.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -8202,6 +9319,23 @@ } } }, + "use": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", + "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "user-home": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", diff --git a/package.json b/package.json index 5c4a04bd..b7ffca2d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "codeclimate-test-reporter": "^0.4.0", "coveralls": "^2.11.4", "expect.js": "^0.3.1", - "gulp": "^3.8.11", + "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-concat": "^2.5.2", "gulp-eslint": "^3.0.1", From 0252f6a6cf0dd34b6db8863f3d026cf21ce19d03 Mon Sep 17 00:00:00 2001 From: Liu's DeskTop Date: Fri, 27 Apr 2018 19:55:07 +0800 Subject: [PATCH 197/224] Add job abortion resolve #76 --- src/job.js | 9 +++- src/pool.js | 22 ++++++++- test/spec/pool.spec.js | 109 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 137 insertions(+), 3 deletions(-) diff --git a/src/job.js b/src/job.js index 54d44246..759cfb0e 100644 --- a/src/job.js +++ b/src/job.js @@ -10,6 +10,8 @@ export default class Job extends EventEmitter { this.runArgs = []; this.sendArgs = []; + this.isAborted = false; + pool.emit('newJob', this); } @@ -43,7 +45,7 @@ export default class Job extends EventEmitter { this.emit('error', ...args); thread.removeListener('progress', onProgress); }; - + thread .on('progress', onProgress) .once('message', onMessage) @@ -70,6 +72,11 @@ export default class Job extends EventEmitter { }); } + abort() { + this.isAborted = true; + this.emit('abort'); + } + destroy () { this.removeAllListeners(); delete this.runArgs; diff --git a/src/pool.js b/src/pool.js index dc4a5b5a..4a8c4026 100644 --- a/src/pool.js +++ b/src/pool.js @@ -10,6 +10,7 @@ export default class Pool extends EventEmitter { this.idleThreads = this.threads.slice(); this.jobQueue = []; this.runArgs = []; + this.spawnOptions = options; this.on('newJob', (job) => this.handleNewJob(job)); this.on('threadAvailable', () => this.dequeue()); @@ -46,11 +47,18 @@ export default class Pool extends EventEmitter { } const job = this.jobQueue.shift(); + + if (job.isAborted) { + job.destroy(); + return this.dequeue(); + } + const thread = this.idleThreads.shift(); job .once('done', (...args) => this.handleJobSuccess(thread, job, ...args)) - .once('error', (...args) => this.handleJobError(thread, job, ...args)); + .once('error', (...args) => this.handleJobError(thread, job, ...args)) + .once('abort', () => this.handleJobAbort(thread, job)); job.executeOn(thread); } @@ -79,6 +87,18 @@ export default class Pool extends EventEmitter { setTimeout(() => { this.emit('finished'); }, 0); } } + + handleJobAbort(thread, job) { + thread.kill(); + + const index = this.threads.indexOf(thread); + this.threads.splice(index, 1); + + const newThread = spawn(null, [], this.spawnOptions) + this.threads.push(newThread) + + this.handleJobDone(newThread, job) + } } Pool.spawn = (threadCount, options) => { diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index 78af6032..d2b6f60d 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -38,6 +38,23 @@ class FakeWorker extends EventEmitter { } } +class RunnableFakeWorker extends FakeWorker { + send(parameter, transferables = []) { + + this.parameter = parameter; + this.transferables = transferables; + + setTimeout(() => { + if (parameter.error) { + this.emit('error', parameter.error); + } else { + this.runnable(this.parameter, () => this.emit('message', parameter)); + } + }, 0); + return this; + } +} + function noop() { return this; } function doTimes(callback, times) { @@ -50,7 +67,6 @@ function doTimes(callback, times) { return returns; } - describe('Pool', () => { const origSpawn = Pool.spawn; @@ -248,4 +264,95 @@ describe('Pool', () => { }); }); + describe('', () => { + let fakeSpawn; + + before(() => { + fakeSpawn = RunnableFakeWorker; + Pool.spawn = origSpawn; + }); + + after(() => { + Pool.spawn = fakeSpawn; + }); + + it('can abort a job', (done) => { + const pool = new Pool(5); + let jobDone = false; + const job = pool.run( + (input, done) => setTimeout(() => { jobDone = true; done(); }, 20) + ).send('...'); + + setTimeout(() => { + job.abort(); + }, 0) + + setTimeout(() => { + expect(jobDone).to.equal(false); + + done(); + }, 100); + }); + + it('can abort a job before it is started', (done) => { + const pool = new Pool(1); + const theThread = pool.threads[0]; + let jobDone = false; + + pool.run((input, done) => setTimeout(() => { done(); }, 100)).send('...'); + + const job = pool.run( + (input, done) => setTimeout(() => { jobDone = true; done(); }, 20) + ).send('...'); + + setTimeout(() => { + job.abort(); + }, 10) + + setTimeout(() => { + expect(jobDone).to.equal(false); + + expect(pool.threads.length).to.equal(1) + expect(pool.idleThreads.length).to.equal(1) + + // the original thread are not been deleted + expect(pool.threads[0]).to.equal(theThread) + expect(pool.idleThreads[0]).to.equal(theThread) + + done(); + }, 500); + }); + + it('can remove old thread and spawn new thread when a job is aborted', (done) => { + const pool = new Pool(5); + let killedThreads = 0; + + pool.threads.forEach(thread => { + thread.on('exit', () => { + ++killedThreads; + }); + }); + + const job = pool.run(() => null) + .send('...'); + const thread = job.thread; + + setTimeout(() => { + job.abort(); + }, 10) + + setTimeout(() => { + expect(killedThreads).to.equal(1); + + expect(pool.threads.length).to.equal(5); + expect(pool.idleThreads.length).to.equal(5); + + expect(pool.threads.indexOf(thread)).to.equal(-1); + expect(pool.idleThreads.indexOf(thread)).to.equal(-1); + + done(); + }, 100); + }); + }); + }); From 119c1385ac50c75c888eeadf2ed929f61b60b014 Mon Sep 17 00:00:00 2001 From: Liu's DeskTop Date: Sat, 28 Apr 2018 13:21:28 +0800 Subject: [PATCH 198/224] Refactor job abortion to make it cleaner --- src/job.js | 3 --- src/pool.js | 16 ++++++++++------ test/spec/pool.spec.js | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/job.js b/src/job.js index 759cfb0e..20404db8 100644 --- a/src/job.js +++ b/src/job.js @@ -10,8 +10,6 @@ export default class Job extends EventEmitter { this.runArgs = []; this.sendArgs = []; - this.isAborted = false; - pool.emit('newJob', this); } @@ -73,7 +71,6 @@ export default class Job extends EventEmitter { } abort() { - this.isAborted = true; this.emit('abort'); } diff --git a/src/pool.js b/src/pool.js index 4a8c4026..37d74a5f 100644 --- a/src/pool.js +++ b/src/pool.js @@ -37,24 +37,28 @@ export default class Pool extends EventEmitter { } queueJob(job) { + job.once('abort', () => this.dropJob(job)); // triggered by job.abort() this.jobQueue.push(job); this.dequeue(); } + dropJob(job) { + const index = this.jobQueue.indexOf(job); + if (index !== -1) { + this.jobQueue.splice(index, 1); + } + } + dequeue() { if (this.jobQueue.length === 0 || this.idleThreads.length === 0) { return; } const job = this.jobQueue.shift(); - - if (job.isAborted) { - job.destroy(); - return this.dequeue(); - } - const thread = this.idleThreads.shift(); + job.removeAllListeners('abort'); // remove previous listener + job .once('done', (...args) => this.handleJobSuccess(thread, job, ...args)) .once('error', (...args) => this.handleJobError(thread, job, ...args)) diff --git a/test/spec/pool.spec.js b/test/spec/pool.spec.js index d2b6f60d..a02e6fff 100644 --- a/test/spec/pool.spec.js +++ b/test/spec/pool.spec.js @@ -276,7 +276,7 @@ describe('Pool', () => { Pool.spawn = fakeSpawn; }); - it('can abort a job', (done) => { + it('can abort a running job', (done) => { const pool = new Pool(5); let jobDone = false; const job = pool.run( From 6e999c2196bd460d7dacf41581d3be0a2854a733 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 28 Apr 2018 10:38:25 +0200 Subject: [PATCH 199/224] Make handleJobAbort() code a little more concise --- src/pool.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pool.js b/src/pool.js index 37d74a5f..0140efbb 100644 --- a/src/pool.js +++ b/src/pool.js @@ -96,12 +96,10 @@ export default class Pool extends EventEmitter { thread.kill(); const index = this.threads.indexOf(thread); - this.threads.splice(index, 1); + const newThread = spawn(null, [], this.spawnOptions); - const newThread = spawn(null, [], this.spawnOptions) - this.threads.push(newThread) - - this.handleJobDone(newThread, job) + this.threads.splice(index, 1, newThread); + this.handleJobDone(newThread, job); } } From 6b3a03a92dfea865cb23c38b511697aff0063f2e Mon Sep 17 00:00:00 2001 From: Liu233w Date: Sat, 28 Apr 2018 17:13:03 +0800 Subject: [PATCH 200/224] Add document for Job Abortion in README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 13172fb5..f2e87a42 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,25 @@ pool }); ``` +#### Job Abortion + +You can abort a job by calling `job.abort()`. + +```javascript +const Pool = require('threads').Pool; + +const pool = new Pool(); + +const job = pool + .run('/path/to/worker') + .send({ do : 'something' }); + +job.on('abort', () => { console.log('Job Aborted'); }); + +// somewhere else +job.abort(); +``` + ### Streaming You can also spawn a thread for streaming purposes. The following example shows From d04afaba28de3f1e555e372253ff453c76358bba Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 28 Apr 2018 11:54:00 +0200 Subject: [PATCH 201/224] 0.11.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5b99a253..19d5079b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.10.1", + "version": "0.11.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b7ffca2d..90f6be51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.10.1", + "version": "0.11.0", "keywords": [ "threads", "web worker", From 1c96b7cc3cf06fbc4b97b5bb71775ce22ce14f28 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sat, 28 Apr 2018 11:55:41 +0200 Subject: [PATCH 202/224] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87c64fe4..6968c2b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.11.0 + +- Implement job abortion (#78, credits to @Liu233w) + ## 0.10.1 - Fix issue with Common JS detection in imported web worker scripts (#72, credits to @Keyholder) From 574e72f04b6a7d9a323b884bb73b9d2d954cf579 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 19 Jun 2018 21:56:35 +0200 Subject: [PATCH 203/224] Drop phantomjs (#85) --- .travis.yml | 4 + karma.conf.js | 8 +- package-lock.json | 3920 ++++++++++++++++++++------------------------- package.json | 2 - 4 files changed, 1739 insertions(+), 2195 deletions(-) diff --git a/.travis.yml b/.travis.yml index 175b5d8e..a98417f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ env: - DISPLAY=:99.0 - TRAVISCI=1 +sudo: required +addons: + chrome: stable + before_script: - sh -e /etc/init.d/xvfb start diff --git a/karma.conf.js b/karma.conf.js index 588b2e60..8a5fa7ea 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -57,12 +57,12 @@ module.exports = function configureKarma(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: process.env.TRAVISCI ? ['Firefox'] : ['ChromeInsecure', 'Firefox'], + browsers: ['ChromeHeadlessInsecure', 'Firefox'], customLaunchers: { - ChromeInsecure: { - base: 'Chrome', - flags: ['--disable-web-security', '--no-sandbox'] + ChromeHeadlessInsecure: { + base: 'ChromeHeadless', + flags: ['--disable-web-security', '--headless', '--no-sandbox'] } }, diff --git a/package-lock.json b/package-lock.json index 19d5079b..92b0a5ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", "dev": true, "requires": { - "normalize-path": "2.1.1", - "through2": "2.0.3" + "normalize-path": "^2.0.1", + "through2": "^2.0.3" } }, "Base64": { @@ -26,8 +26,8 @@ "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", "dev": true, "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" } }, "abbrev": { @@ -42,7 +42,7 @@ "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", "dev": true, "requires": { - "mime-types": "2.1.17", + "mime-types": "~2.1.11", "negotiator": "0.6.1" } }, @@ -58,7 +58,7 @@ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { - "acorn": "3.3.0" + "acorn": "^3.0.4" }, "dependencies": { "acorn": { @@ -81,8 +81,8 @@ "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "dev": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" }, "dependencies": { "json-stable-stringify": { @@ -91,7 +91,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } } } @@ -108,9 +108,9 @@ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" } }, "amdefine": { @@ -143,8 +143,8 @@ "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", "dev": true, "requires": { - "micromatch": "2.3.11", - "normalize-path": "2.1.1" + "micromatch": "^2.1.5", + "normalize-path": "^2.0.0" } }, "archy": { @@ -159,7 +159,7 @@ "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", "dev": true, "requires": { - "sprintf-js": "1.0.3" + "sprintf-js": "~1.0.2" } }, "arr-diff": { @@ -168,7 +168,7 @@ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-flatten": { @@ -225,7 +225,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "1.0.3" + "array-uniq": "^1.0.1" } }, "array-uniq": { @@ -264,9 +264,9 @@ "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", "dev": true, "requires": { - "bn.js": "4.11.8", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "assert": { @@ -296,7 +296,7 @@ "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", "dev": true, "requires": { - "acorn": "4.0.13" + "acorn": "^4.0.3" } }, "async": { @@ -341,9 +341,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" } }, "babel-core": { @@ -352,25 +352,25 @@ "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-generator": "6.26.0", - "babel-helpers": "6.24.1", - "babel-messages": "6.23.0", - "babel-register": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "convert-source-map": "1.5.0", - "debug": "2.6.9", - "json5": "0.5.1", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "path-is-absolute": "1.0.1", - "private": "0.1.7", - "slash": "1.0.0", - "source-map": "0.5.7" + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.0", + "debug": "^2.6.8", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.7", + "slash": "^1.0.0", + "source-map": "^0.5.6" }, "dependencies": { "convert-source-map": { @@ -387,14 +387,14 @@ "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", "dev": true, "requires": { - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "detect-indent": "4.0.0", - "jsesc": "1.3.0", - "lodash": "4.17.4", - "source-map": "0.5.7", - "trim-right": "1.0.1" + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.6", + "trim-right": "^1.0.1" }, "dependencies": { "jsesc": { @@ -411,10 +411,10 @@ "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", "dev": true, "requires": { - "babel-helper-hoist-variables": "6.24.1", - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-define-map": { @@ -423,10 +423,10 @@ "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.4" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-helper-function-name": { @@ -435,11 +435,11 @@ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "dev": true, "requires": { - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-get-function-arity": { @@ -448,8 +448,8 @@ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-hoist-variables": { @@ -458,8 +458,8 @@ "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-optimise-call-expression": { @@ -468,8 +468,8 @@ "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-regex": { @@ -478,9 +478,9 @@ "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.4" + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-helper-replace-supers": { @@ -489,12 +489,12 @@ "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", "dev": true, "requires": { - "babel-helper-optimise-call-expression": "6.24.1", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helpers": { @@ -503,8 +503,8 @@ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-messages": { @@ -513,7 +513,7 @@ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-check-es2015-constants": { @@ -522,7 +522,7 @@ "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-arrow-functions": { @@ -531,7 +531,7 @@ "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-block-scoped-functions": { @@ -540,7 +540,7 @@ "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-block-scoping": { @@ -549,11 +549,11 @@ "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.4" + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-plugin-transform-es2015-classes": { @@ -562,15 +562,15 @@ "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", "dev": true, "requires": { - "babel-helper-define-map": "6.26.0", - "babel-helper-function-name": "6.24.1", - "babel-helper-optimise-call-expression": "6.24.1", - "babel-helper-replace-supers": "6.24.1", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-define-map": "^6.24.1", + "babel-helper-function-name": "^6.24.1", + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-helper-replace-supers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-computed-properties": { @@ -579,8 +579,8 @@ "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-destructuring": { @@ -589,7 +589,7 @@ "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-duplicate-keys": { @@ -598,8 +598,8 @@ "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-for-of": { @@ -608,7 +608,7 @@ "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-function-name": { @@ -617,9 +617,9 @@ "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-literals": { @@ -628,7 +628,7 @@ "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-modules-amd": { @@ -637,9 +637,9 @@ "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", "dev": true, "requires": { - "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-commonjs": { @@ -648,10 +648,10 @@ "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", "dev": true, "requires": { - "babel-plugin-transform-strict-mode": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-types": "6.26.0" + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" } }, "babel-plugin-transform-es2015-modules-systemjs": { @@ -660,9 +660,9 @@ "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", "dev": true, "requires": { - "babel-helper-hoist-variables": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-umd": { @@ -671,9 +671,9 @@ "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", "dev": true, "requires": { - "babel-plugin-transform-es2015-modules-amd": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-object-super": { @@ -682,8 +682,8 @@ "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", "dev": true, "requires": { - "babel-helper-replace-supers": "6.24.1", - "babel-runtime": "6.26.0" + "babel-helper-replace-supers": "^6.24.1", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-parameters": { @@ -692,12 +692,12 @@ "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", "dev": true, "requires": { - "babel-helper-call-delegate": "6.24.1", - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-shorthand-properties": { @@ -706,8 +706,8 @@ "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-spread": { @@ -716,7 +716,7 @@ "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-sticky-regex": { @@ -725,9 +725,9 @@ "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-template-literals": { @@ -736,7 +736,7 @@ "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-typeof-symbol": { @@ -745,7 +745,7 @@ "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-unicode-regex": { @@ -754,9 +754,9 @@ "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "regexpu-core": "2.0.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" } }, "babel-plugin-transform-regenerator": { @@ -765,7 +765,7 @@ "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", "dev": true, "requires": { - "regenerator-transform": "0.10.1" + "regenerator-transform": "^0.10.0" } }, "babel-plugin-transform-strict-mode": { @@ -774,8 +774,8 @@ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-preset-es2015": { @@ -784,30 +784,30 @@ "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", "dev": true, "requires": { - "babel-plugin-check-es2015-constants": "6.22.0", - "babel-plugin-transform-es2015-arrow-functions": "6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0", - "babel-plugin-transform-es2015-block-scoping": "6.26.0", - "babel-plugin-transform-es2015-classes": "6.24.1", - "babel-plugin-transform-es2015-computed-properties": "6.24.1", - "babel-plugin-transform-es2015-destructuring": "6.23.0", - "babel-plugin-transform-es2015-duplicate-keys": "6.24.1", - "babel-plugin-transform-es2015-for-of": "6.23.0", - "babel-plugin-transform-es2015-function-name": "6.24.1", - "babel-plugin-transform-es2015-literals": "6.22.0", - "babel-plugin-transform-es2015-modules-amd": "6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", - "babel-plugin-transform-es2015-modules-systemjs": "6.24.1", - "babel-plugin-transform-es2015-modules-umd": "6.24.1", - "babel-plugin-transform-es2015-object-super": "6.24.1", - "babel-plugin-transform-es2015-parameters": "6.24.1", - "babel-plugin-transform-es2015-shorthand-properties": "6.24.1", - "babel-plugin-transform-es2015-spread": "6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "6.24.1", - "babel-plugin-transform-es2015-template-literals": "6.22.0", - "babel-plugin-transform-es2015-typeof-symbol": "6.23.0", - "babel-plugin-transform-es2015-unicode-regex": "6.24.1", - "babel-plugin-transform-regenerator": "6.26.0" + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.24.1", + "babel-plugin-transform-es2015-classes": "^6.24.1", + "babel-plugin-transform-es2015-computed-properties": "^6.24.1", + "babel-plugin-transform-es2015-destructuring": "^6.22.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", + "babel-plugin-transform-es2015-for-of": "^6.22.0", + "babel-plugin-transform-es2015-function-name": "^6.24.1", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-umd": "^6.24.1", + "babel-plugin-transform-es2015-object-super": "^6.24.1", + "babel-plugin-transform-es2015-parameters": "^6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", + "babel-plugin-transform-regenerator": "^6.24.1" } }, "babel-preset-es2015-loose": { @@ -816,7 +816,7 @@ "integrity": "sha1-gu4pOrMTKcepRoa2RLYq37zcP1c=", "dev": true, "requires": { - "modify-babel-preset": "3.2.1" + "modify-babel-preset": "^3.1.0" } }, "babel-register": { @@ -825,13 +825,13 @@ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "dev": true, "requires": { - "babel-core": "6.26.0", - "babel-runtime": "6.26.0", - "core-js": "2.5.1", - "home-or-tmp": "2.0.0", - "lodash": "4.17.4", - "mkdirp": "0.5.1", - "source-map-support": "0.4.18" + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" } }, "babel-runtime": { @@ -840,8 +840,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.1", - "regenerator-runtime": "0.11.0" + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" } }, "babel-template": { @@ -850,11 +850,11 @@ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "lodash": "4.17.4" + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" } }, "babel-traverse": { @@ -863,15 +863,15 @@ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "debug": "2.6.9", - "globals": "9.18.0", - "invariant": "2.2.2", - "lodash": "4.17.4" + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" } }, "babel-types": { @@ -880,10 +880,10 @@ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "esutils": "2.0.2", - "lodash": "4.17.4", - "to-fast-properties": "1.0.3" + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" } }, "babylon": { @@ -910,13 +910,13 @@ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { "component-emitter": { @@ -931,7 +931,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -940,7 +940,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -949,7 +949,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -958,9 +958,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -1002,7 +1002,7 @@ "dev": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "beeper": { @@ -1032,7 +1032,7 @@ "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", "dev": true, "requires": { - "readable-stream": "2.0.6" + "readable-stream": "~2.0.5" }, "dependencies": { "readable-stream": { @@ -1041,12 +1041,12 @@ "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" } } } @@ -1076,15 +1076,15 @@ "dev": true, "requires": { "bytes": "3.0.0", - "content-type": "1.0.4", + "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "1.1.1", - "http-errors": "1.6.2", + "depd": "~1.1.1", + "http-errors": "~1.6.2", "iconv-lite": "0.4.19", - "on-finished": "2.3.0", + "on-finished": "~2.3.0", "qs": "6.5.1", "raw-body": "2.3.2", - "type-is": "1.6.15" + "type-is": "~1.6.15" }, "dependencies": { "qs": { @@ -1101,7 +1101,7 @@ "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "brace-expansion": { @@ -1110,7 +1110,7 @@ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -1120,9 +1120,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, "brorand": { @@ -1137,11 +1137,11 @@ "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.7.2", - "defined": "1.0.0", - "through2": "2.0.3", - "umd": "3.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.7.1", + "defined": "^1.0.0", + "through2": "^2.0.0", + "umd": "^3.0.0" } }, "browser-resolve": { @@ -1173,53 +1173,53 @@ "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "assert": "1.4.1", - "browser-pack": "6.0.2", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", - "buffer": "4.9.1", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", - "defined": "1.0.0", - "deps-sort": "2.0.0", - "domain-browser": "1.1.7", - "duplexer2": "0.1.4", - "events": "1.1.1", - "glob": "7.1.2", - "has": "1.0.1", - "htmlescape": "1.1.1", - "https-browserify": "0.0.1", - "inherits": "2.0.3", - "insert-module-globals": "7.0.1", - "labeled-stream-splicer": "2.0.0", - "module-deps": "4.1.1", - "os-browserify": "0.1.2", - "parents": "1.0.1", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "2.0.0", - "readable-stream": "2.3.3", - "resolve": "1.4.0", - "shasum": "1.0.2", - "shell-quote": "1.6.1", - "stream-browserify": "2.0.1", - "stream-http": "2.7.2", - "string_decoder": "0.10.31", - "subarg": "1.0.0", - "syntax-error": "1.3.0", - "through2": "2.0.3", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.0", - "url": "0.11.0", - "util": "0.10.3", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^1.11.0", + "browserify-zlib": "~0.1.2", + "buffer": "^4.1.0", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.1", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.0", + "domain-browser": "~1.1.0", + "duplexer2": "~0.1.2", + "events": "~1.1.0", + "glob": "^7.1.0", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "~0.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.0.0", + "labeled-stream-splicer": "^2.0.0", + "module-deps": "^4.0.8", + "os-browserify": "~0.1.1", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^2.0.0", + "stream-http": "^2.0.0", + "string_decoder": "~0.10.0", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "~0.0.0", + "url": "~0.11.0", + "util": "~0.10.1", + "vm-browserify": "~0.0.1", + "xtend": "^4.0.0" } }, "browserify-aes": { @@ -1228,12 +1228,12 @@ "integrity": "sha512-WYCMOT/PtGTlpOKFht0YJFYcPy6pLCR98CtWfzK13zoynLlBMvAdEMSRGmgnJCw2M2j/5qxBkinZQFobieM8dQ==", "dev": true, "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.1.3", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.1" + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "browserify-cipher": { @@ -1242,9 +1242,9 @@ "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", "dev": true, "requires": { - "browserify-aes": "1.0.8", - "browserify-des": "1.0.0", - "evp_bytestokey": "1.0.3" + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" } }, "browserify-des": { @@ -1253,9 +1253,9 @@ "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", "dev": true, "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3" + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1" } }, "browserify-rsa": { @@ -1264,8 +1264,8 @@ "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { - "bn.js": "4.11.8", - "randombytes": "2.0.5" + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" } }, "browserify-sign": { @@ -1274,13 +1274,13 @@ "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.1.3", - "create-hmac": "1.1.6", - "elliptic": "6.4.0", - "inherits": "2.0.3", - "parse-asn1": "5.1.0" + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" } }, "browserify-zlib": { @@ -1289,7 +1289,7 @@ "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", "dev": true, "requires": { - "pako": "0.2.9" + "pako": "~0.2.0" } }, "buffer": { @@ -1298,9 +1298,9 @@ "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "dev": true, "requires": { - "base64-js": "1.2.1", - "ieee754": "1.1.8", - "isarray": "1.0.0" + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" } }, "buffer-xor": { @@ -1315,7 +1315,7 @@ "integrity": "sha1-AWE3MGCsWYjv+ZBYcxEU9uGV1R4=", "dev": true, "requires": { - "readable-stream": "2.3.3" + "readable-stream": "^2.0.2" } }, "builtin-status-codes": { @@ -1342,15 +1342,15 @@ "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" }, "dependencies": { "component-emitter": { @@ -1379,7 +1379,7 @@ "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, "requires": { - "callsites": "0.2.0" + "callsites": "^0.2.0" } }, "callsite": { @@ -1412,8 +1412,8 @@ "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", "dev": true, "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" } }, "chalk": { @@ -1422,11 +1422,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "chokidar": { @@ -1435,15 +1435,15 @@ "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", "dev": true, "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.1.2", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" } }, "cipher-base": { @@ -1452,8 +1452,8 @@ "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "circular-json": { @@ -1468,10 +1468,10 @@ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" }, "dependencies": { "define-property": { @@ -1480,7 +1480,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "isobject": { @@ -1497,7 +1497,7 @@ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "restore-cursor": "^1.0.1" } }, "cli-width": { @@ -1512,8 +1512,8 @@ "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", "dev": true, "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", + "center-align": "^0.1.1", + "right-align": "^0.1.1", "wordwrap": "0.0.2" }, "dependencies": { @@ -1549,9 +1549,9 @@ "integrity": "sha1-pikNQT8hemEjL5XkWP84QYz7ARc=", "dev": true, "requires": { - "inherits": "2.0.3", - "process-nextick-args": "1.0.7", - "through2": "2.0.3" + "inherits": "^2.0.1", + "process-nextick-args": "^1.0.6", + "through2": "^2.0.1" } }, "co": { @@ -1572,10 +1572,10 @@ "integrity": "sha1-nyD22C02qrmdIKvk9sc3L0xtGRU=", "dev": true, "requires": { - "async": "1.5.2", + "async": "~1.5.2", "commander": "2.9.0", "lcov-parse": "0.0.10", - "request": "2.74.0" + "request": "~2.74.0" } }, "collection-visit": { @@ -1584,8 +1584,8 @@ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" } }, "colors": { @@ -1600,7 +1600,7 @@ "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=", "dev": true, "requires": { - "lodash": "4.17.4" + "lodash": "^4.5.0" } }, "combine-source-map": { @@ -1609,10 +1609,10 @@ "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", "dev": true, "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.6.2", - "lodash.memoize": "3.0.4", - "source-map": "0.5.7" + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" } }, "combined-stream": { @@ -1621,7 +1621,7 @@ "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", "dev": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "commander": { @@ -1630,7 +1630,7 @@ "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { - "graceful-readlink": "1.0.1" + "graceful-readlink": ">= 1.0.0" } }, "commondir": { @@ -1669,9 +1669,9 @@ "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.0.6", - "typedarray": "0.0.6" + "inherits": "~2.0.1", + "readable-stream": "~2.0.0", + "typedarray": "~0.0.5" }, "dependencies": { "readable-stream": { @@ -1680,12 +1680,12 @@ "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" } } } @@ -1696,7 +1696,7 @@ "integrity": "sha1-9Vs74q60dgGxCi1SWcz7cP0vHdY=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.1" } }, "connect": { @@ -1707,7 +1707,7 @@ "requires": { "debug": "2.6.9", "finalhandler": "1.0.6", - "parseurl": "1.3.2", + "parseurl": "~1.3.2", "utils-merge": "1.0.1" } }, @@ -1717,7 +1717,7 @@ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, "requires": { - "date-now": "0.1.4" + "date-now": "^0.1.4" } }, "constants-browserify": { @@ -1781,9 +1781,9 @@ "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", "dev": true, "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" } }, "qs": { @@ -1798,26 +1798,26 @@ "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", "dev": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.11.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "qs": "6.3.2", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.4.3", - "uuid": "3.1.0" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.11.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~2.0.6", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "qs": "~6.3.0", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "~0.4.1", + "uuid": "^3.0.0" } }, "uuid": { @@ -1834,8 +1834,8 @@ "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", "dev": true, "requires": { - "bn.js": "4.11.8", - "elliptic": "6.4.0" + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" } }, "create-hash": { @@ -1844,10 +1844,10 @@ "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", "dev": true, "requires": { - "cipher-base": "1.0.4", - "inherits": "2.0.3", - "ripemd160": "2.0.1", - "sha.js": "2.4.9" + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "sha.js": "^2.4.0" } }, "create-hmac": { @@ -1856,12 +1856,12 @@ "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", "dev": true, "requires": { - "cipher-base": "1.0.4", - "create-hash": "1.1.3", - "inherits": "2.0.3", - "ripemd160": "2.0.1", - "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "cryptiles": { @@ -1870,7 +1870,7 @@ "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", "dev": true, "requires": { - "boom": "2.10.1" + "boom": "2.x.x" } }, "crypto-browserify": { @@ -1879,16 +1879,16 @@ "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", "dev": true, "requires": { - "browserify-cipher": "1.0.0", - "browserify-sign": "4.0.4", - "create-ecdh": "4.0.0", - "create-hash": "1.1.3", - "create-hmac": "1.1.6", - "diffie-hellman": "5.0.2", - "inherits": "2.0.3", - "pbkdf2": "3.0.14", - "public-encrypt": "4.0.0", - "randombytes": "2.0.5" + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0" } }, "css": { @@ -1897,10 +1897,10 @@ "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", "dev": true, "requires": { - "inherits": "2.0.3", - "source-map": "0.1.43", - "source-map-resolve": "0.3.1", - "urix": "0.1.0" + "inherits": "^2.0.1", + "source-map": "^0.1.38", + "source-map-resolve": "^0.3.0", + "urix": "^0.1.0" }, "dependencies": { "source-map": { @@ -1909,7 +1909,7 @@ "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -1926,7 +1926,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.31" + "es5-ext": "^0.10.9" } }, "dashdash": { @@ -1935,7 +1935,7 @@ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -1973,8 +1973,8 @@ "integrity": "sha1-+gccXYdIRoVCSAdCHKSxawsaB2M=", "dev": true, "requires": { - "debug": "2.6.9", - "lazy-debug-legacy": "0.0.1", + "debug": "2.X", + "lazy-debug-legacy": "0.0.X", "object-assign": "4.1.0" }, "dependencies": { @@ -2016,7 +2016,7 @@ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "dev": true, "requires": { - "clone": "1.0.2" + "clone": "^1.0.2" } }, "define-property": { @@ -2025,8 +2025,8 @@ "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" }, "dependencies": { "is-accessor-descriptor": { @@ -2035,7 +2035,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -2044,7 +2044,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -2053,9 +2053,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -2084,13 +2084,13 @@ "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, "requires": { - "globby": "5.0.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.0", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "rimraf": "2.6.2" + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" }, "dependencies": { "object-assign": { @@ -2125,10 +2125,10 @@ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "2.0.3" + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" } }, "des.js": { @@ -2137,8 +2137,8 @@ "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "detect-file": { @@ -2153,7 +2153,7 @@ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } }, "detect-newline": { @@ -2168,8 +2168,8 @@ "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", "dev": true, "requires": { - "acorn": "4.0.13", - "defined": "1.0.0" + "acorn": "^4.0.3", + "defined": "^1.0.0" } }, "di": { @@ -2190,9 +2190,9 @@ "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", "dev": true, "requires": { - "bn.js": "4.11.8", - "miller-rabin": "4.0.1", - "randombytes": "2.0.5" + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" } }, "doctrine": { @@ -2201,8 +2201,8 @@ "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", "dev": true, "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "esutils": "^2.0.2", + "isarray": "^1.0.0" } }, "dom-serialize": { @@ -2211,10 +2211,10 @@ "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", "dev": true, "requires": { - "custom-event": "1.0.1", - "ent": "2.2.0", - "extend": "3.0.1", - "void-elements": "2.0.1" + "custom-event": "~1.0.0", + "ent": "~2.2.0", + "extend": "^3.0.0", + "void-elements": "^2.0.0" } }, "domain-browser": { @@ -2229,7 +2229,7 @@ "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { - "readable-stream": "2.3.3" + "readable-stream": "^2.0.2" } }, "ecc-jsbn": { @@ -2239,7 +2239,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "ee-first": { @@ -2254,13 +2254,13 @@ "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0", - "hash.js": "1.1.3", - "hmac-drbg": "1.0.1", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.0", - "minimalistic-crypto-utils": "1.0.1" + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" } }, "encodeurl": { @@ -2275,7 +2275,7 @@ "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", "dev": true, "requires": { - "once": "1.3.3" + "once": "~1.3.0" }, "dependencies": { "once": { @@ -2284,7 +2284,7 @@ "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } } } @@ -2389,8 +2389,8 @@ "integrity": "sha1-e7k4yVp/G59ygJLcCcQe3MOY7v4=", "dev": true, "requires": { - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1" + "es6-iterator": "~2.0.1", + "es6-symbol": "~3.1.1" } }, "es6-iterator": { @@ -2399,9 +2399,9 @@ "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-symbol": "3.1.1" + "d": "1", + "es5-ext": "^0.10.14", + "es6-symbol": "^3.1" } }, "es6-map": { @@ -2410,31 +2410,25 @@ "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", - "es6-set": "0.1.5", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" + "d": "1", + "es5-ext": "~0.10.14", + "es6-iterator": "~2.0.1", + "es6-set": "~0.1.5", + "es6-symbol": "~3.1.1", + "event-emitter": "~0.3.5" } }, - "es6-promise": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.0.5.tgz", - "integrity": "sha1-eILzCt3lskDM+n99eMVIMwlRrkI=", - "dev": true - }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", + "d": "1", + "es5-ext": "~0.10.14", + "es6-iterator": "~2.0.1", "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" + "event-emitter": "~0.3.5" } }, "es6-symbol": { @@ -2443,8 +2437,8 @@ "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31" + "d": "1", + "es5-ext": "~0.10.14" } }, "es6-weak-map": { @@ -2453,10 +2447,10 @@ "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1" + "d": "1", + "es5-ext": "^0.10.14", + "es6-iterator": "^2.0.1", + "es6-symbol": "^3.1.1" } }, "escape-html": { @@ -2477,11 +2471,11 @@ "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { - "esprima": "2.7.3", - "estraverse": "1.9.3", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.2.0" + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" }, "dependencies": { "estraverse": { @@ -2497,7 +2491,7 @@ "dev": true, "optional": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -2508,10 +2502,10 @@ "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", "dev": true, "requires": { - "es6-map": "0.1.5", - "es6-weak-map": "2.0.2", - "esrecurse": "4.2.0", - "estraverse": "4.2.0" + "es6-map": "^0.1.3", + "es6-weak-map": "^2.0.1", + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" } }, "eslint": { @@ -2520,41 +2514,41 @@ "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "chalk": "1.1.3", - "concat-stream": "1.5.2", - "debug": "2.6.9", - "doctrine": "2.0.0", - "escope": "3.6.0", - "espree": "3.5.1", - "esquery": "1.0.0", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "glob": "7.1.2", - "globals": "9.18.0", - "ignore": "3.3.5", - "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.16.1", - "is-resolvable": "1.0.0", - "js-yaml": "3.6.1", - "json-stable-stringify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.4", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", - "require-uncached": "1.0.3", - "shelljs": "0.7.8", - "strip-bom": "3.0.0", - "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" + "babel-code-frame": "^6.16.0", + "chalk": "^1.1.3", + "concat-stream": "^1.5.2", + "debug": "^2.1.1", + "doctrine": "^2.0.0", + "escope": "^3.6.0", + "espree": "^3.4.0", + "esquery": "^1.0.0", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "glob": "^7.0.3", + "globals": "^9.14.0", + "ignore": "^3.2.0", + "imurmurhash": "^0.1.4", + "inquirer": "^0.12.0", + "is-my-json-valid": "^2.10.0", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.5.1", + "json-stable-stringify": "^1.0.0", + "levn": "^0.3.0", + "lodash": "^4.0.0", + "mkdirp": "^0.5.0", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.1", + "pluralize": "^1.2.1", + "progress": "^1.1.8", + "require-uncached": "^1.0.2", + "shelljs": "^0.7.5", + "strip-bom": "^3.0.0", + "strip-json-comments": "~2.0.1", + "table": "^3.7.8", + "text-table": "~0.2.0", + "user-home": "^2.0.0" }, "dependencies": { "json-stable-stringify": { @@ -2563,7 +2557,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "strip-bom": { @@ -2578,7 +2572,7 @@ "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "os-homedir": "^1.0.0" } } } @@ -2589,8 +2583,8 @@ "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=", "dev": true, "requires": { - "acorn": "5.1.2", - "acorn-jsx": "3.0.1" + "acorn": "^5.1.1", + "acorn-jsx": "^3.0.0" }, "dependencies": { "acorn": { @@ -2613,7 +2607,7 @@ "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", "dev": true, "requires": { - "estraverse": "4.2.0" + "estraverse": "^4.0.0" } }, "esrecurse": { @@ -2622,8 +2616,8 @@ "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", "dev": true, "requires": { - "estraverse": "4.2.0", - "object-assign": "4.1.1" + "estraverse": "^4.1.0", + "object-assign": "^4.0.1" }, "dependencies": { "object-assign": { @@ -2652,8 +2646,8 @@ "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31" + "d": "1", + "es5-ext": "~0.10.14" } }, "eventemitter3": { @@ -2673,8 +2667,8 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "1.3.4", - "safe-buffer": "5.1.1" + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" } }, "exit-hook": { @@ -2689,9 +2683,9 @@ "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", "dev": true, "requires": { - "array-slice": "0.2.3", - "array-unique": "0.2.1", - "braces": "0.1.5" + "array-slice": "^0.2.3", + "array-unique": "^0.2.1", + "braces": "^0.1.2" }, "dependencies": { "array-slice": { @@ -2706,7 +2700,7 @@ "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", "dev": true, "requires": { - "expand-range": "0.1.1" + "expand-range": "^0.1.0" } }, "expand-range": { @@ -2715,8 +2709,8 @@ "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", "dev": true, "requires": { - "is-number": "0.1.1", - "repeat-string": "0.2.2" + "is-number": "^0.1.1", + "repeat-string": "^0.2.2" } }, "is-number": { @@ -2739,7 +2733,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "is-posix-bracket": "^0.1.0" } }, "expand-range": { @@ -2748,7 +2742,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "2.2.3" + "fill-range": "^2.1.0" } }, "expand-tilde": { @@ -2757,7 +2751,7 @@ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, "requires": { - "homedir-polyfill": "1.0.1" + "homedir-polyfill": "^1.0.1" } }, "expect.js": { @@ -2778,8 +2772,8 @@ "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -2788,7 +2782,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -2799,62 +2793,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "1.0.0" - } - }, - "extract-zip": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.5.tgz", - "integrity": "sha1-maBnNbbqIOqbcF13ms/8yHz/BEA=", - "dev": true, - "requires": { - "concat-stream": "1.6.0", - "debug": "2.2.0", - "mkdirp": "0.5.0", - "yauzl": "2.4.1" - }, - "dependencies": { - "concat-stream": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "typedarray": "0.0.6" - } - }, - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "0.7.1" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } + "is-extglob": "^1.0.0" } }, "extsprintf": { @@ -2869,8 +2808,8 @@ "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", "dev": true, "requires": { - "chalk": "1.1.3", - "time-stamp": "1.1.0" + "chalk": "^1.1.1", + "time-stamp": "^1.0.0" } }, "fast-levenshtein": { @@ -2879,23 +2818,14 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", - "dev": true, - "requires": { - "pend": "1.2.0" - } - }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" }, "dependencies": { "object-assign": { @@ -2912,8 +2842,8 @@ "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, "requires": { - "flat-cache": "1.3.0", - "object-assign": "4.1.1" + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" }, "dependencies": { "object-assign": { @@ -2936,11 +2866,11 @@ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.7", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, "finalhandler": { @@ -2950,12 +2880,12 @@ "dev": true, "requires": { "debug": "2.6.9", - "encodeurl": "1.0.1", - "escape-html": "1.0.3", - "on-finished": "2.3.0", - "parseurl": "1.3.2", - "statuses": "1.3.1", - "unpipe": "1.0.0" + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.3.1", + "unpipe": "~1.0.0" } }, "find-index": { @@ -2970,10 +2900,10 @@ "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", "dev": true, "requires": { - "detect-file": "1.0.0", - "is-glob": "3.1.0", - "micromatch": "3.1.10", - "resolve-dir": "1.0.1" + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" }, "dependencies": { "arr-diff": { @@ -2994,16 +2924,16 @@ "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -3012,7 +2942,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -3023,13 +2953,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -3038,7 +2968,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -3047,7 +2977,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-accessor-descriptor": { @@ -3056,7 +2986,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3065,7 +2995,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -3076,7 +3006,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3085,7 +3015,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -3096,9 +3026,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -3115,14 +3045,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -3131,7 +3061,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -3140,7 +3070,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -3151,10 +3081,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -3163,7 +3093,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -3174,7 +3104,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -3183,7 +3113,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -3192,9 +3122,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "is-extglob": { @@ -3209,7 +3139,7 @@ "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "is-extglob": "2.1.1" + "is-extglob": "^2.1.0" } }, "is-number": { @@ -3218,7 +3148,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3227,7 +3157,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -3250,19 +3180,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } } } @@ -3273,11 +3203,11 @@ "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "is-plain-object": "2.0.4", - "object.defaults": "1.1.0", - "object.pick": "1.3.0", - "parse-filepath": "1.0.2" + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" } }, "first-chunk-stream": { @@ -3298,10 +3228,10 @@ "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", "dev": true, "requires": { - "circular-json": "0.3.3", - "del": "2.2.2", - "graceful-fs": "4.1.11", - "write": "0.2.1" + "circular-json": "^0.3.1", + "del": "^2.0.2", + "graceful-fs": "^4.1.2", + "write": "^0.2.1" }, "dependencies": { "graceful-fs": { @@ -3324,7 +3254,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "forever-agent": { @@ -3339,9 +3269,9 @@ "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", "dev": true, "requires": { - "async": "2.5.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "async": "^2.0.1", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.11" }, "dependencies": { "async": { @@ -3350,7 +3280,7 @@ "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", "dev": true, "requires": { - "lodash": "4.17.4" + "lodash": "^4.14.0" } } } @@ -3361,7 +3291,7 @@ "integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=", "dev": true, "requires": { - "samsam": "1.1.2" + "samsam": "~1.1" } }, "fragment-cache": { @@ -3370,7 +3300,7 @@ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { - "map-cache": "0.2.2" + "map-cache": "^0.2.2" } }, "fs-access": { @@ -3379,26 +3309,7 @@ "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", "dev": true, "requires": { - "null-check": "1.0.0" - } - }, - "fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "2.4.0", - "klaw": "1.3.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - } + "null-check": "^1.0.0" } }, "fs.realpath": { @@ -3414,8 +3325,8 @@ "dev": true, "optional": true, "requires": { - "nan": "2.7.0", - "node-pre-gyp": "0.6.36" + "nan": "^2.3.0", + "node-pre-gyp": "^0.6.36" }, "dependencies": { "abbrev": { @@ -3430,8 +3341,8 @@ "dev": true, "optional": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" } }, "ansi-regex": { @@ -3451,8 +3362,8 @@ "dev": true, "optional": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "asn1": { @@ -3496,7 +3407,7 @@ "dev": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "block-stream": { @@ -3504,7 +3415,7 @@ "bundled": true, "dev": true, "requires": { - "inherits": "2.0.3" + "inherits": "~2.0.0" } }, "boom": { @@ -3512,7 +3423,7 @@ "bundled": true, "dev": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "brace-expansion": { @@ -3520,7 +3431,7 @@ "bundled": true, "dev": true, "requires": { - "balanced-match": "0.4.2", + "balanced-match": "^0.4.1", "concat-map": "0.0.1" } }, @@ -3551,7 +3462,7 @@ "bundled": true, "dev": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "concat-map": { @@ -3575,7 +3486,7 @@ "dev": true, "optional": true, "requires": { - "boom": "2.10.1" + "boom": "2.x.x" } }, "dashdash": { @@ -3584,7 +3495,7 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -3627,7 +3538,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "extend": { @@ -3653,9 +3564,9 @@ "dev": true, "optional": true, "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" } }, "fs.realpath": { @@ -3668,10 +3579,10 @@ "bundled": true, "dev": true, "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" } }, "fstream-ignore": { @@ -3680,9 +3591,9 @@ "dev": true, "optional": true, "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" } }, "gauge": { @@ -3691,14 +3602,14 @@ "dev": true, "optional": true, "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "getpass": { @@ -3707,7 +3618,7 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -3723,12 +3634,12 @@ "bundled": true, "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-fs": { @@ -3748,8 +3659,8 @@ "dev": true, "optional": true, "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" + "ajv": "^4.9.1", + "har-schema": "^1.0.5" } }, "has-unicode": { @@ -3764,10 +3675,10 @@ "dev": true, "optional": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" } }, "hoek": { @@ -3781,9 +3692,9 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "inflight": { @@ -3791,8 +3702,8 @@ "bundled": true, "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -3811,7 +3722,7 @@ "bundled": true, "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-typedarray": { @@ -3837,7 +3748,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "jsbn": { @@ -3858,7 +3769,7 @@ "dev": true, "optional": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stringify-safe": { @@ -3903,7 +3814,7 @@ "bundled": true, "dev": true, "requires": { - "mime-db": "1.27.0" + "mime-db": "~1.27.0" } }, "minimatch": { @@ -3911,7 +3822,7 @@ "bundled": true, "dev": true, "requires": { - "brace-expansion": "1.1.7" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -3939,15 +3850,15 @@ "dev": true, "optional": true, "requires": { - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", - "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" + "mkdirp": "^0.5.1", + "nopt": "^4.0.1", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "request": "^2.81.0", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^2.2.1", + "tar-pack": "^3.4.0" } }, "nopt": { @@ -3956,8 +3867,8 @@ "dev": true, "optional": true, "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npmlog": { @@ -3966,10 +3877,10 @@ "dev": true, "optional": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -3994,7 +3905,7 @@ "bundled": true, "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -4015,8 +3926,8 @@ "dev": true, "optional": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -4053,10 +3964,10 @@ "dev": true, "optional": true, "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -4072,13 +3983,13 @@ "bundled": true, "dev": true, "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" } }, "request": { @@ -4087,28 +3998,28 @@ "dev": true, "optional": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~4.2.1", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "performance-now": "^0.2.0", + "qs": "~6.4.0", + "safe-buffer": "^5.0.1", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.0.0" } }, "rimraf": { @@ -4116,7 +4027,7 @@ "bundled": true, "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -4148,7 +4059,7 @@ "dev": true, "optional": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "sshpk": { @@ -4157,15 +4068,15 @@ "dev": true, "optional": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jodid25519": "^1.0.0", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "assert-plus": { @@ -4181,9 +4092,9 @@ "bundled": true, "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -4191,7 +4102,7 @@ "bundled": true, "dev": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "stringstream": { @@ -4205,7 +4116,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -4219,9 +4130,9 @@ "bundled": true, "dev": true, "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" } }, "tar-pack": { @@ -4230,14 +4141,14 @@ "dev": true, "optional": true, "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" + "debug": "^2.2.0", + "fstream": "^1.0.10", + "fstream-ignore": "^1.0.5", + "once": "^1.3.3", + "readable-stream": "^2.1.4", + "rimraf": "^2.5.1", + "tar": "^2.2.1", + "uid-number": "^0.0.6" } }, "tough-cookie": { @@ -4246,7 +4157,7 @@ "dev": true, "optional": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { @@ -4255,7 +4166,7 @@ "dev": true, "optional": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -4296,7 +4207,7 @@ "dev": true, "optional": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { @@ -4318,7 +4229,7 @@ "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", "dev": true, "requires": { - "globule": "0.1.0" + "globule": "~0.1.0" } }, "generate-function": { @@ -4333,7 +4244,7 @@ "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", "dev": true, "requires": { - "is-property": "1.0.2" + "is-property": "^1.0.0" } }, "get-value": { @@ -4348,7 +4259,7 @@ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -4365,12 +4276,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "glob-base": { @@ -4379,8 +4290,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, "glob-parent": { @@ -4389,7 +4300,7 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "2.0.1" + "is-glob": "^2.0.0" } }, "glob-stream": { @@ -4398,12 +4309,12 @@ "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", "dev": true, "requires": { - "glob": "4.5.3", - "glob2base": "0.0.12", - "minimatch": "2.0.10", - "ordered-read-streams": "0.1.0", - "through2": "0.6.5", - "unique-stream": "1.0.0" + "glob": "^4.3.1", + "glob2base": "^0.0.12", + "minimatch": "^2.0.1", + "ordered-read-streams": "^0.1.0", + "through2": "^0.6.1", + "unique-stream": "^1.0.0" }, "dependencies": { "glob": { @@ -4412,10 +4323,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.4.0" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" } }, "isarray": { @@ -4430,7 +4341,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.0.0" } }, "readable-stream": { @@ -4439,10 +4350,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "through2": { @@ -4451,8 +4362,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -4463,7 +4374,7 @@ "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", "dev": true, "requires": { - "gaze": "0.5.2" + "gaze": "^0.5.1" } }, "glob2base": { @@ -4472,7 +4383,7 @@ "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", "dev": true, "requires": { - "find-index": "0.1.1" + "find-index": "^0.1.1" } }, "global-modules": { @@ -4481,9 +4392,9 @@ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { - "global-prefix": "1.0.2", - "is-windows": "1.0.2", - "resolve-dir": "1.0.1" + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" } }, "global-prefix": { @@ -4492,11 +4403,11 @@ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "homedir-polyfill": "1.0.1", - "ini": "1.3.5", - "is-windows": "1.0.2", - "which": "1.3.0" + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" } }, "globals": { @@ -4511,12 +4422,12 @@ "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, "requires": { - "array-union": "1.0.2", - "arrify": "1.0.1", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "object-assign": { @@ -4533,9 +4444,9 @@ "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", "dev": true, "requires": { - "glob": "3.1.21", - "lodash": "1.0.2", - "minimatch": "0.2.14" + "glob": "~3.1.21", + "lodash": "~1.0.1", + "minimatch": "~0.2.11" }, "dependencies": { "glob": { @@ -4544,9 +4455,9 @@ "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", "dev": true, "requires": { - "graceful-fs": "1.2.3", - "inherits": "1.0.2", - "minimatch": "0.2.14" + "graceful-fs": "~1.2.0", + "inherits": "1", + "minimatch": "~0.2.11" } }, "graceful-fs": { @@ -4573,8 +4484,8 @@ "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", "dev": true, "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" + "lru-cache": "2", + "sigmund": "~1.0.0" } } } @@ -4585,7 +4496,7 @@ "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", "dev": true, "requires": { - "sparkles": "1.0.0" + "sparkles": "^1.0.0" } }, "graceful-fs": { @@ -4594,7 +4505,7 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "1.1.3" + "natives": "^1.1.0" } }, "graceful-readlink": { @@ -4615,19 +4526,19 @@ "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", "dev": true, "requires": { - "archy": "1.0.0", - "chalk": "1.1.3", - "deprecated": "0.0.1", - "gulp-util": "3.0.8", - "interpret": "1.0.4", - "liftoff": "2.5.0", - "minimist": "1.2.0", - "orchestrator": "0.3.8", - "pretty-hrtime": "1.0.3", - "semver": "4.3.6", - "tildify": "1.2.0", - "v8flags": "2.1.1", - "vinyl-fs": "0.3.14" + "archy": "^1.0.0", + "chalk": "^1.0.0", + "deprecated": "^0.0.1", + "gulp-util": "^3.0.0", + "interpret": "^1.0.0", + "liftoff": "^2.1.0", + "minimist": "^1.1.0", + "orchestrator": "^0.3.0", + "pretty-hrtime": "^1.0.0", + "semver": "^4.1.0", + "tildify": "^1.0.0", + "v8flags": "^2.0.2", + "vinyl-fs": "^0.3.0" } }, "gulp-babel": { @@ -4636,12 +4547,12 @@ "integrity": "sha1-fAF25Lo/JExgWIoMSzIKRdGt784=", "dev": true, "requires": { - "babel-core": "6.26.0", - "gulp-util": "3.0.8", - "object-assign": "4.1.1", + "babel-core": "^6.0.2", + "gulp-util": "^3.0.0", + "object-assign": "^4.0.1", "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl-sourcemaps-apply": "0.2.1" + "through2": "^2.0.0", + "vinyl-sourcemaps-apply": "^0.2.0" }, "dependencies": { "object-assign": { @@ -4658,9 +4569,9 @@ "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", "dev": true, "requires": { - "concat-with-sourcemaps": "1.0.4", - "through2": "2.0.3", - "vinyl": "2.1.0" + "concat-with-sourcemaps": "^1.0.0", + "through2": "^2.0.0", + "vinyl": "^2.0.0" }, "dependencies": { "clone": { @@ -4687,12 +4598,12 @@ "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", "dev": true, "requires": { - "clone": "2.1.1", - "clone-buffer": "1.0.0", - "clone-stats": "1.0.0", - "cloneable-readable": "1.0.0", - "remove-trailing-separator": "1.1.0", - "replace-ext": "1.0.0" + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" } } } @@ -4703,9 +4614,9 @@ "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", "dev": true, "requires": { - "bufferstreams": "1.1.1", - "eslint": "3.19.0", - "gulp-util": "3.0.8" + "bufferstreams": "^1.1.1", + "eslint": "^3.0.0", + "gulp-util": "^3.0.6" } }, "gulp-mocha": { @@ -4714,12 +4625,12 @@ "integrity": "sha1-qwyiw5QDcYF03drXUOY6Yb4X4EE=", "dev": true, "requires": { - "gulp-util": "3.0.8", - "mocha": "3.5.3", - "plur": "2.1.2", - "req-cwd": "1.0.1", - "temp": "0.8.3", - "through": "2.3.8" + "gulp-util": "^3.0.0", + "mocha": "^3.0.0", + "plur": "^2.1.0", + "req-cwd": "^1.0.1", + "temp": "^0.8.3", + "through": "^2.3.4" } }, "gulp-rename": { @@ -4734,17 +4645,17 @@ "integrity": "sha1-eG+XyUoPloSSRl1wVY4EJCxnlZg=", "dev": true, "requires": { - "@gulp-sourcemaps/map-sources": "1.0.0", - "acorn": "4.0.13", - "convert-source-map": "1.1.3", - "css": "2.2.1", - "debug-fabulous": "0.0.4", - "detect-newline": "2.1.0", - "graceful-fs": "4.1.11", - "source-map": "0.5.7", - "strip-bom": "2.0.0", - "through2": "2.0.3", - "vinyl": "1.2.0" + "@gulp-sourcemaps/map-sources": "1.X", + "acorn": "4.X", + "convert-source-map": "1.X", + "css": "2.X", + "debug-fabulous": "0.0.X", + "detect-newline": "2.X", + "graceful-fs": "4.X", + "source-map": "0.X", + "strip-bom": "2.X", + "through2": "2.X", + "vinyl": "1.X" }, "dependencies": { "graceful-fs": { @@ -4759,7 +4670,7 @@ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "is-utf8": "0.2.1" + "is-utf8": "^0.2.0" } }, "vinyl": { @@ -4768,8 +4679,8 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.2", - "clone-stats": "0.0.1", + "clone": "^1.0.0", + "clone-stats": "^0.0.1", "replace-ext": "0.0.1" } } @@ -4781,14 +4692,14 @@ "integrity": "sha1-bbhbHQ7mPRgFhZK2WGSdZcLsRUE=", "dev": true, "requires": { - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash": "4.17.4", - "make-error-cause": "1.2.2", - "through2": "2.0.3", - "uglify-js": "2.8.29", - "uglify-save-license": "0.4.1", - "vinyl-sourcemaps-apply": "0.2.1" + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "lodash": "^4.13.1", + "make-error-cause": "^1.1.1", + "through2": "^2.0.0", + "uglify-js": "~2.8.10", + "uglify-save-license": "^0.4.1", + "vinyl-sourcemaps-apply": "^0.2.0" } }, "gulp-util": { @@ -4797,24 +4708,24 @@ "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", "dev": true, "requires": { - "array-differ": "1.0.0", - "array-uniq": "1.0.3", - "beeper": "1.1.1", - "chalk": "1.1.3", - "dateformat": "2.2.0", - "fancy-log": "1.3.0", - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash._reescape": "3.0.0", - "lodash._reevaluate": "3.0.0", - "lodash._reinterpolate": "3.0.0", - "lodash.template": "3.6.2", - "minimist": "1.2.0", - "multipipe": "0.1.2", - "object-assign": "3.0.0", + "array-differ": "^1.0.0", + "array-uniq": "^1.0.2", + "beeper": "^1.0.0", + "chalk": "^1.0.0", + "dateformat": "^2.0.0", + "fancy-log": "^1.1.0", + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "lodash._reescape": "^3.0.0", + "lodash._reevaluate": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.template": "^3.0.0", + "minimist": "^1.1.0", + "multipipe": "^0.1.2", + "object-assign": "^3.0.0", "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl": "0.5.3" + "through2": "^2.0.0", + "vinyl": "^0.5.0" } }, "gulplog": { @@ -4823,7 +4734,7 @@ "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", "dev": true, "requires": { - "glogg": "1.0.0" + "glogg": "^1.0.0" } }, "handlebars": { @@ -4832,10 +4743,10 @@ "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", "dev": true, "requires": { - "async": "1.5.2", - "optimist": "0.6.1", - "source-map": "0.4.4", - "uglify-js": "2.8.29" + "async": "^1.4.0", + "optimist": "^0.6.1", + "source-map": "^0.4.4", + "uglify-js": "^2.6" }, "dependencies": { "source-map": { @@ -4844,27 +4755,21 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } }, - "har-schema": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "dev": true - }, "har-validator": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", "dev": true, "requires": { - "chalk": "1.1.3", - "commander": "2.9.0", - "is-my-json-valid": "2.16.1", - "pinkie-promise": "2.0.1" + "chalk": "^1.1.1", + "commander": "^2.9.0", + "is-my-json-valid": "^2.12.4", + "pinkie-promise": "^2.0.0" } }, "has": { @@ -4873,7 +4778,7 @@ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", "dev": true, "requires": { - "function-bind": "1.1.1" + "function-bind": "^1.0.2" } }, "has-ansi": { @@ -4882,7 +4787,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "has-binary": { @@ -4920,7 +4825,7 @@ "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", "dev": true, "requires": { - "sparkles": "1.0.0" + "sparkles": "^1.0.0" } }, "has-value": { @@ -4929,9 +4834,9 @@ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -4948,8 +4853,8 @@ "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -4958,7 +4863,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -4967,7 +4872,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -4978,7 +4883,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -4989,7 +4894,7 @@ "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", "dev": true, "requires": { - "inherits": "2.0.3" + "inherits": "^2.0.1" } }, "hash.js": { @@ -4998,18 +4903,8 @@ "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" - } - }, - "hasha": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "requires": { - "is-stream": "1.1.0", - "pinkie-promise": "2.0.1" + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" } }, "hat": { @@ -5024,10 +4919,10 @@ "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "dev": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" } }, "he": { @@ -5042,9 +4937,9 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "1.1.3", - "minimalistic-assert": "1.0.0", - "minimalistic-crypto-utils": "1.0.1" + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" } }, "hoek": { @@ -5059,8 +4954,8 @@ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", "dev": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" } }, "homedir-polyfill": { @@ -5069,7 +4964,7 @@ "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", "dev": true, "requires": { - "parse-passwd": "1.0.0" + "parse-passwd": "^1.0.0" } }, "htmlescape": { @@ -5084,8 +4979,8 @@ "integrity": "sha1-M3la3nLfiKz7/TZ3PO/tp2RzWyA=", "dev": true, "requires": { - "Base64": "0.2.1", - "inherits": "2.0.3" + "Base64": "~0.2.0", + "inherits": "~2.0.1" } }, "http-errors": { @@ -5097,7 +4992,7 @@ "depd": "1.1.1", "inherits": "2.0.3", "setprototypeof": "1.0.3", - "statuses": "1.3.1" + "statuses": ">= 1.3.1 < 2" } }, "http-proxy": { @@ -5106,8 +5001,8 @@ "integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=", "dev": true, "requires": { - "eventemitter3": "1.2.0", - "requires-port": "1.0.0" + "eventemitter3": "1.x.x", + "requires-port": "1.x.x" }, "dependencies": { "eventemitter3": { @@ -5124,9 +5019,9 @@ "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", "dev": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "https-browserify": { @@ -5171,8 +5066,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -5193,7 +5088,7 @@ "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "~0.5.3" } }, "inquirer": { @@ -5202,19 +5097,19 @@ "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", "dev": true, "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", - "cli-width": "2.2.0", - "figures": "1.7.0", - "lodash": "4.17.4", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "through": "2.3.8" + "ansi-escapes": "^1.1.0", + "ansi-regex": "^2.0.0", + "chalk": "^1.0.0", + "cli-cursor": "^1.0.1", + "cli-width": "^2.0.0", + "figures": "^1.3.5", + "lodash": "^4.3.0", + "readline2": "^1.0.1", + "run-async": "^0.1.0", + "rx-lite": "^3.1.2", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.0", + "through": "^2.3.6" } }, "insert-module-globals": { @@ -5223,14 +5118,14 @@ "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.7.2", - "concat-stream": "1.5.2", - "is-buffer": "1.1.5", - "lexical-scope": "1.2.0", - "process": "0.11.10", - "through2": "2.0.3", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.7.1", + "concat-stream": "~1.5.1", + "is-buffer": "^1.1.0", + "lexical-scope": "^1.2.0", + "process": "~0.11.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" } }, "interpret": { @@ -5245,7 +5140,7 @@ "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", "dev": true, "requires": { - "loose-envify": "1.3.1" + "loose-envify": "^1.0.0" } }, "irregular-plurals": { @@ -5260,8 +5155,8 @@ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, "requires": { - "is-relative": "1.0.0", - "is-windows": "1.0.2" + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" } }, "is-accessor-descriptor": { @@ -5270,7 +5165,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-binary-path": { @@ -5279,7 +5174,7 @@ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { - "binary-extensions": "1.10.0" + "binary-extensions": "^1.0.0" } }, "is-buffer": { @@ -5294,7 +5189,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-descriptor": { @@ -5303,9 +5198,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" }, "dependencies": { "kind-of": { @@ -5328,7 +5223,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "2.0.0" + "is-primitive": "^2.0.0" } }, "is-extendable": { @@ -5349,7 +5244,7 @@ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-fullwidth-code-point": { @@ -5358,7 +5253,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-glob": { @@ -5367,7 +5262,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "is-my-json-valid": { @@ -5376,10 +5271,10 @@ "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==", "dev": true, "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" + "generate-function": "^2.0.0", + "generate-object-property": "^1.1.0", + "jsonpointer": "^4.0.0", + "xtend": "^4.0.0" } }, "is-number": { @@ -5388,7 +5283,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-odd": { @@ -5397,7 +5292,7 @@ "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", "dev": true, "requires": { - "is-number": "4.0.0" + "is-number": "^4.0.0" }, "dependencies": { "is-number": { @@ -5420,7 +5315,7 @@ "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", "dev": true, "requires": { - "is-path-inside": "1.0.0" + "is-path-inside": "^1.0.0" } }, "is-path-inside": { @@ -5429,7 +5324,7 @@ "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", "dev": true, "requires": { - "path-is-inside": "1.0.2" + "path-is-inside": "^1.0.1" } }, "is-plain-object": { @@ -5438,7 +5333,7 @@ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -5473,7 +5368,7 @@ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, "requires": { - "is-unc-path": "1.0.0" + "is-unc-path": "^1.0.0" } }, "is-resolvable": { @@ -5482,15 +5377,9 @@ "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", "dev": true, "requires": { - "tryit": "1.0.3" + "tryit": "^1.0.1" } }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -5503,7 +5392,7 @@ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, "requires": { - "unc-path-regex": "0.1.2" + "unc-path-regex": "^0.1.2" } }, "is-utf8": { @@ -5557,20 +5446,20 @@ "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { - "abbrev": "1.0.9", - "async": "1.5.2", - "escodegen": "1.8.1", - "esprima": "2.7.3", - "glob": "5.0.15", - "handlebars": "4.0.10", - "js-yaml": "3.6.1", - "mkdirp": "0.5.1", - "nopt": "3.0.6", - "once": "1.4.0", - "resolve": "1.1.7", - "supports-color": "3.2.3", - "which": "1.3.0", - "wordwrap": "1.0.0" + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" }, "dependencies": { "glob": { @@ -5579,11 +5468,11 @@ "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "resolve": { @@ -5598,7 +5487,7 @@ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } } } @@ -5621,8 +5510,8 @@ "integrity": "sha1-bl/mfYsgXOTSL60Ft3geja3MSzA=", "dev": true, "requires": { - "argparse": "1.0.9", - "esprima": "2.7.3" + "argparse": "^1.0.7", + "esprima": "^2.6.0" } }, "jsbn": { @@ -5650,7 +5539,7 @@ "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stringify-safe": { @@ -5671,24 +5560,6 @@ "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, - "optional": true - } - } - }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -5733,33 +5604,33 @@ "integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==", "dev": true, "requires": { - "bluebird": "3.5.1", - "body-parser": "1.18.2", - "chokidar": "1.7.0", - "colors": "1.1.2", - "combine-lists": "1.0.1", - "connect": "3.6.5", - "core-js": "2.5.1", - "di": "0.0.1", - "dom-serialize": "2.2.1", - "expand-braces": "0.1.2", - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "http-proxy": "1.16.2", - "isbinaryfile": "3.0.2", - "lodash": "3.10.1", - "log4js": "0.6.38", - "mime": "1.4.1", - "minimatch": "3.0.4", - "optimist": "0.6.1", - "qjobs": "1.1.5", - "range-parser": "1.2.0", - "rimraf": "2.6.2", - "safe-buffer": "5.1.1", + "bluebird": "^3.3.0", + "body-parser": "^1.16.1", + "chokidar": "^1.4.1", + "colors": "^1.1.0", + "combine-lists": "^1.0.0", + "connect": "^3.6.0", + "core-js": "^2.2.0", + "di": "^0.0.1", + "dom-serialize": "^2.2.0", + "expand-braces": "^0.1.1", + "glob": "^7.1.1", + "graceful-fs": "^4.1.2", + "http-proxy": "^1.13.0", + "isbinaryfile": "^3.0.0", + "lodash": "^3.8.0", + "log4js": "^0.6.31", + "mime": "^1.3.4", + "minimatch": "^3.0.2", + "optimist": "^0.6.1", + "qjobs": "^1.1.4", + "range-parser": "^1.2.0", + "rimraf": "^2.6.0", + "safe-buffer": "^5.0.1", "socket.io": "1.7.3", - "source-map": "0.5.7", + "source-map": "^0.5.3", "tmp": "0.0.31", - "useragent": "2.2.1" + "useragent": "^2.1.12" }, "dependencies": { "graceful-fs": { @@ -5783,12 +5654,12 @@ "dev": true, "requires": { "browserify": "10.2.3", - "convert-source-map": "0.3.5", + "convert-source-map": "~0.3.3", "hat": "0.0.3", - "js-string-escape": "1.0.1", - "lodash": "3.10.1", - "minimatch": "1.0.0", - "os-shim": "0.1.3", + "js-string-escape": "^1.0.0", + "lodash": "^3.10.1", + "minimatch": "^1.0.0", + "os-shim": "~0.1.2", "watchify": "3.2.1" }, "dependencies": { @@ -5813,11 +5684,11 @@ "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.6.1", - "defined": "1.0.0", - "through2": "1.1.1", - "umd": "3.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.6.1", + "defined": "^1.0.0", + "through2": "^1.0.0", + "umd": "^3.0.0" } }, "browserify": { @@ -5826,56 +5697,56 @@ "integrity": "sha1-9qGNTWqzERP5/fg/ED+gFyioIGo=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "assert": "1.3.0", - "browser-pack": "5.0.1", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", - "buffer": "3.6.0", - "builtins": "0.0.7", + "JSONStream": "^1.0.3", + "assert": "~1.3.0", + "browser-pack": "^5.0.0", + "browser-resolve": "^1.7.1", + "browserify-zlib": "~0.1.2", + "buffer": "^3.0.0", + "builtins": "~0.0.3", "commondir": "0.0.1", - "concat-stream": "1.4.10", - "console-browserify": "1.1.0", - "constants-browserify": "0.0.1", - "crypto-browserify": "3.11.1", - "deep-equal": "1.0.1", - "defined": "1.0.0", - "deps-sort": "1.3.9", - "domain-browser": "1.1.7", - "duplexer2": "0.0.2", - "events": "1.0.2", - "glob": "4.5.3", - "has": "1.0.1", - "htmlescape": "1.1.1", - "http-browserify": "1.7.0", - "https-browserify": "0.0.1", - "inherits": "2.0.3", - "insert-module-globals": "6.6.3", + "concat-stream": "~1.4.1", + "console-browserify": "^1.1.0", + "constants-browserify": "~0.0.1", + "crypto-browserify": "^3.0.0", + "deep-equal": "^1.0.0", + "defined": "^1.0.0", + "deps-sort": "^1.3.7", + "domain-browser": "~1.1.0", + "duplexer2": "~0.0.2", + "events": "~1.0.0", + "glob": "^4.0.5", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "http-browserify": "^1.4.0", + "https-browserify": "~0.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^6.4.1", "isarray": "0.0.1", - "labeled-stream-splicer": "1.0.2", - "module-deps": "3.9.1", - "os-browserify": "0.1.2", - "parents": "1.0.1", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "1.1.1", - "readable-stream": "1.1.14", - "resolve": "1.4.0", - "shasum": "1.0.2", - "shell-quote": "0.0.1", - "stream-browserify": "1.0.0", - "string_decoder": "0.10.31", - "subarg": "1.0.0", - "syntax-error": "1.3.0", - "through2": "1.1.1", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.0", - "url": "0.10.3", - "util": "0.10.3", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" + "labeled-stream-splicer": "^1.0.0", + "module-deps": "^3.7.11", + "os-browserify": "~0.1.1", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^1.1.1", + "readable-stream": "^1.1.13", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "~0.0.1", + "stream-browserify": "^1.0.0", + "string_decoder": "~0.10.0", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^1.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "~0.0.0", + "url": "~0.10.1", + "util": "~0.10.1", + "vm-browserify": "~0.0.1", + "xtend": "^4.0.0" } }, "buffer": { @@ -5885,8 +5756,8 @@ "dev": true, "requires": { "base64-js": "0.0.8", - "ieee754": "1.1.8", - "isarray": "1.0.0" + "ieee754": "^1.1.4", + "isarray": "^1.0.0" }, "dependencies": { "isarray": { @@ -5903,10 +5774,10 @@ "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", "dev": true, "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.5.0", - "lodash.memoize": "3.0.4", - "source-map": "0.4.4" + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.5.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.4.2" }, "dependencies": { "convert-source-map": { @@ -5923,9 +5794,9 @@ "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "1.1.14", - "typedarray": "0.0.6" + "inherits": "~2.0.1", + "readable-stream": "~1.1.9", + "typedarray": "~0.0.5" } }, "constants-browserify": { @@ -5946,10 +5817,10 @@ "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "1.1.1" + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^1.0.0" } }, "duplexer2": { @@ -5958,7 +5829,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "~1.1.9" } }, "events": { @@ -5973,10 +5844,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.4.0" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" }, "dependencies": { "minimatch": { @@ -5985,7 +5856,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.0.0" } } } @@ -5996,7 +5867,7 @@ "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", "dev": true, "requires": { - "source-map": "0.4.4" + "source-map": "~0.4.0" } }, "insert-module-globals": { @@ -6005,14 +5876,14 @@ "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.6.1", - "concat-stream": "1.4.10", - "is-buffer": "1.1.5", - "lexical-scope": "1.2.0", - "process": "0.11.10", - "through2": "1.1.1", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.6.1", + "concat-stream": "~1.4.1", + "is-buffer": "^1.1.0", + "lexical-scope": "^1.2.0", + "process": "~0.11.0", + "through2": "^1.0.0", + "xtend": "^4.0.0" } }, "isarray": { @@ -6027,9 +5898,9 @@ "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", "dev": true, "requires": { - "inherits": "2.0.3", - "isarray": "0.0.1", - "stream-splicer": "1.3.2" + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "stream-splicer": "^1.1.0" } }, "lodash": { @@ -6044,8 +5915,8 @@ "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=", "dev": true, "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" + "lru-cache": "2", + "sigmund": "~1.0.0" } }, "module-deps": { @@ -6054,20 +5925,20 @@ "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "browser-resolve": "1.11.2", - "concat-stream": "1.4.10", - "defined": "1.0.0", - "detective": "4.5.0", + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "concat-stream": "~1.4.5", + "defined": "^1.0.0", + "detective": "^4.0.0", "duplexer2": "0.0.2", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "1.1.14", - "resolve": "1.4.0", - "stream-combiner2": "1.0.2", - "subarg": "1.0.0", - "through2": "1.1.1", - "xtend": "4.0.1" + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^1.1.13", + "resolve": "^1.1.3", + "stream-combiner2": "~1.0.0", + "subarg": "^1.0.0", + "through2": "^1.0.0", + "xtend": "^4.0.0" } }, "read-only-stream": { @@ -6076,8 +5947,8 @@ "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "readable-wrap": "1.0.0" + "readable-stream": "^1.0.31", + "readable-wrap": "^1.0.0" } }, "readable-stream": { @@ -6086,10 +5957,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "shell-quote": { @@ -6104,7 +5975,7 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } }, "stream-browserify": { @@ -6113,8 +5984,8 @@ "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "1.1.14" + "inherits": "~2.0.1", + "readable-stream": "^1.0.27-1" } }, "stream-combiner2": { @@ -6123,8 +5994,8 @@ "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", "dev": true, "requires": { - "duplexer2": "0.0.2", - "through2": "0.5.1" + "duplexer2": "~0.0.2", + "through2": "~0.5.1" }, "dependencies": { "readable-stream": { @@ -6133,10 +6004,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "through2": { @@ -6145,8 +6016,8 @@ "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "3.0.0" + "readable-stream": "~1.0.17", + "xtend": "~3.0.0" } }, "xtend": { @@ -6164,11 +6035,11 @@ "dev": true, "requires": { "indexof": "0.0.1", - "inherits": "2.0.3", - "isarray": "0.0.1", - "readable-stream": "1.1.14", - "readable-wrap": "1.0.0", - "through2": "1.1.1" + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "readable-stream": "^1.1.13-1", + "readable-wrap": "^1.0.0", + "through2": "^1.0.0" } }, "through2": { @@ -6177,8 +6048,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } }, "url": { @@ -6207,8 +6078,8 @@ "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", "dev": true, "requires": { - "fs-access": "1.0.1", - "which": "1.3.0" + "fs-access": "^1.0.0", + "which": "^1.2.1" } }, "karma-expect": { @@ -6217,7 +6088,7 @@ "integrity": "sha1-xrClb/GJA9sRr08JjMbnzxmM4nU=", "dev": true, "requires": { - "expect.js": "0.3.1" + "expect.js": "^0.3.1" } }, "karma-firefox-launcher": { @@ -6235,153 +6106,13 @@ "minimist": "1.2.0" } }, - "karma-phantomjs-launcher": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", - "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", - "dev": true, - "requires": { - "lodash": "4.17.4", - "phantomjs-prebuilt": "2.1.15" - }, - "dependencies": { - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "form-data": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "har-validator": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "dev": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "phantomjs-prebuilt": { - "version": "2.1.15", - "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.15.tgz", - "integrity": "sha1-IPhugtM0nFBZF1J3RbekEeCLOQM=", - "dev": true, - "requires": { - "es6-promise": "4.0.5", - "extract-zip": "1.6.5", - "fs-extra": "1.0.0", - "hasha": "2.2.0", - "kew": "0.7.0", - "progress": "1.1.8", - "request": "2.81.0", - "request-progress": "2.0.1", - "which": "1.2.14" - } - }, - "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", - "dev": true - }, - "request": { - "version": "2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", - "dev": true - }, - "which": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", - "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", - "dev": true, - "requires": { - "isexe": "2.0.0" - } - } - } - }, - "kew": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" - } - }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, - "optional": true - } + "is-buffer": "^1.1.5" } }, "labeled-stream-splicer": { @@ -6390,9 +6121,9 @@ "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", "dev": true, "requires": { - "inherits": "2.0.3", - "isarray": "0.0.1", - "stream-splicer": "2.0.0" + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { @@ -6427,8 +6158,8 @@ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" } }, "lexical-scope": { @@ -6437,7 +6168,7 @@ "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", "dev": true, "requires": { - "astw": "2.2.0" + "astw": "^2.0.0" } }, "liftoff": { @@ -6446,14 +6177,14 @@ "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", "dev": true, "requires": { - "extend": "3.0.1", - "findup-sync": "2.0.0", - "fined": "1.1.0", - "flagged-respawn": "1.0.0", - "is-plain-object": "2.0.4", - "object.map": "1.0.1", - "rechoir": "0.6.2", - "resolve": "1.4.0" + "extend": "^3.0.0", + "findup-sync": "^2.0.0", + "fined": "^1.0.1", + "flagged-respawn": "^1.0.0", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.0", + "rechoir": "^0.6.2", + "resolve": "^1.1.7" } }, "lodash": { @@ -6468,8 +6199,8 @@ "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", "dev": true, "requires": { - "lodash._basecopy": "3.0.1", - "lodash.keys": "3.1.2" + "lodash._basecopy": "^3.0.0", + "lodash.keys": "^3.0.0" } }, "lodash._basecopy": { @@ -6538,9 +6269,9 @@ "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", "dev": true, "requires": { - "lodash._baseassign": "3.2.0", - "lodash._basecreate": "3.0.3", - "lodash._isiterateecall": "3.0.9" + "lodash._baseassign": "^3.0.0", + "lodash._basecreate": "^3.0.0", + "lodash._isiterateecall": "^3.0.0" } }, "lodash.escape": { @@ -6549,7 +6280,7 @@ "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", "dev": true, "requires": { - "lodash._root": "3.0.1" + "lodash._root": "^3.0.0" } }, "lodash.isarguments": { @@ -6570,9 +6301,9 @@ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "lodash.memoize": { @@ -6593,15 +6324,15 @@ "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", "dev": true, "requires": { - "lodash._basecopy": "3.0.1", - "lodash._basetostring": "3.0.1", - "lodash._basevalues": "3.0.0", - "lodash._isiterateecall": "3.0.9", - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0", - "lodash.keys": "3.1.2", - "lodash.restparam": "3.6.1", - "lodash.templatesettings": "3.1.1" + "lodash._basecopy": "^3.0.0", + "lodash._basetostring": "^3.0.0", + "lodash._basevalues": "^3.0.0", + "lodash._isiterateecall": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0", + "lodash.keys": "^3.0.0", + "lodash.restparam": "^3.0.0", + "lodash.templatesettings": "^3.0.0" } }, "lodash.templatesettings": { @@ -6610,8 +6341,8 @@ "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", "dev": true, "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0" + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0" } }, "log-driver": { @@ -6626,8 +6357,8 @@ "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "semver": "4.3.6" + "readable-stream": "~1.0.2", + "semver": "~4.3.3" }, "dependencies": { "isarray": { @@ -6642,10 +6373,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } } } @@ -6668,7 +6399,7 @@ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", "dev": true, "requires": { - "js-tokens": "3.0.2" + "js-tokens": "^3.0.0" } }, "lru-cache": { @@ -6689,7 +6420,7 @@ "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=", "dev": true, "requires": { - "make-error": "1.3.0" + "make-error": "^1.2.0" } }, "make-iterator": { @@ -6698,7 +6429,7 @@ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" }, "dependencies": { "kind-of": { @@ -6721,7 +6452,7 @@ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { - "object-visit": "1.0.1" + "object-visit": "^1.0.0" } }, "md5.js": { @@ -6730,8 +6461,8 @@ "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", "dev": true, "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" }, "dependencies": { "hash-base": { @@ -6740,8 +6471,8 @@ "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } } } @@ -6758,19 +6489,19 @@ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.4" + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, "miller-rabin": { @@ -6779,8 +6510,8 @@ "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0" + "bn.js": "^4.0.0", + "brorand": "^1.0.1" } }, "mime": { @@ -6801,7 +6532,7 @@ "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", "dev": true, "requires": { - "mime-db": "1.30.0" + "mime-db": "~1.30.0" } }, "minimalistic-assert": { @@ -6822,7 +6553,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -6837,8 +6568,8 @@ "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -6847,7 +6578,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -6904,12 +6635,12 @@ "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "supports-color": { @@ -6918,7 +6649,7 @@ "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } } } @@ -6929,7 +6660,7 @@ "integrity": "sha1-1xcqo8CCLtP8COMI/QlxKVE2q1A=", "dev": true, "requires": { - "require-relative": "0.8.7" + "require-relative": "^0.8.7" } }, "module-deps": { @@ -6938,21 +6669,21 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "browser-resolve": "1.11.2", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "defined": "1.0.0", - "detective": "4.5.0", - "duplexer2": "0.1.4", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "2.3.3", - "resolve": "1.4.0", - "stream-combiner2": "1.1.1", - "subarg": "1.0.0", - "through2": "2.0.3", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.0", + "defined": "^1.0.0", + "detective": "^4.0.0", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.3", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" } }, "ms": { @@ -6976,7 +6707,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "~1.1.9" } }, "isarray": { @@ -6991,10 +6722,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } } } @@ -7018,18 +6749,18 @@ "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-odd": "2.0.0", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-odd": "^2.0.0", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "arr-diff": { @@ -7087,7 +6818,7 @@ "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { - "abbrev": "1.0.9" + "abbrev": "1" } }, "normalize-path": { @@ -7096,7 +6827,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "null-check": { @@ -7135,9 +6866,9 @@ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" }, "dependencies": { "define-property": { @@ -7146,7 +6877,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -7157,7 +6888,7 @@ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -7174,10 +6905,10 @@ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, "requires": { - "array-each": "1.0.1", - "array-slice": "1.1.0", - "for-own": "1.0.0", - "isobject": "3.0.1" + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" }, "dependencies": { "for-own": { @@ -7186,7 +6917,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "isobject": { @@ -7203,8 +6934,8 @@ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, "requires": { - "for-own": "1.0.0", - "make-iterator": "1.0.1" + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" }, "dependencies": { "for-own": { @@ -7213,7 +6944,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } } } @@ -7224,8 +6955,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, "object.pick": { @@ -7234,7 +6965,7 @@ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -7260,7 +6991,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "onetime": { @@ -7275,8 +7006,8 @@ "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "minimist": "0.0.10", - "wordwrap": "0.0.3" + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" }, "dependencies": { "minimist": { @@ -7299,12 +7030,12 @@ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" } }, "options": { @@ -7319,9 +7050,9 @@ "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", "dev": true, "requires": { - "end-of-stream": "0.1.5", - "sequencify": "0.0.7", - "stream-consume": "0.1.1" + "end-of-stream": "~0.1.5", + "sequencify": "~0.0.7", + "stream-consume": "~0.1.0" } }, "ordered-read-streams": { @@ -7360,7 +7091,7 @@ "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", "dev": true, "requires": { - "shell-quote": "1.6.1" + "shell-quote": "^1.4.2" } }, "pako": { @@ -7375,7 +7106,7 @@ "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, "requires": { - "path-platform": "0.11.15" + "path-platform": "~0.11.15" } }, "parse-asn1": { @@ -7384,11 +7115,11 @@ "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", "dev": true, "requires": { - "asn1.js": "4.9.1", - "browserify-aes": "1.0.8", - "create-hash": "1.1.3", - "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.14" + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3" } }, "parse-filepath": { @@ -7397,9 +7128,9 @@ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, "requires": { - "is-absolute": "1.0.0", - "map-cache": "0.2.2", - "path-root": "0.1.1" + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" } }, "parse-glob": { @@ -7408,10 +7139,10 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, "parse-passwd": { @@ -7426,7 +7157,7 @@ "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=", "dev": true, "requires": { - "better-assert": "1.0.2" + "better-assert": "~1.0.0" } }, "parseqs": { @@ -7435,7 +7166,7 @@ "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", "dev": true, "requires": { - "better-assert": "1.0.2" + "better-assert": "~1.0.0" } }, "parseuri": { @@ -7444,7 +7175,7 @@ "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", "dev": true, "requires": { - "better-assert": "1.0.2" + "better-assert": "~1.0.0" } }, "parseurl": { @@ -7495,7 +7226,7 @@ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, "requires": { - "path-root-regex": "0.1.2" + "path-root-regex": "^0.1.0" } }, "path-root-regex": { @@ -7510,176 +7241,11 @@ "integrity": "sha512-gjsZW9O34fm0R7PaLHRJmLLVfSoesxztjPjE9o6R+qtVJij90ltg1joIovN9GKrRW3t1PzhDDG3UMEMFfZ+1wA==", "dev": true, "requires": { - "create-hash": "1.1.3", - "create-hmac": "1.1.6", - "ripemd160": "2.0.1", - "safe-buffer": "5.1.1", - "sha.js": "2.4.9" - } - }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "dev": true - }, - "phantomjs": { - "version": "1.9.20", - "resolved": "https://registry.npmjs.org/phantomjs/-/phantomjs-1.9.20.tgz", - "integrity": "sha1-RCSsog4U0lXAsIia9va4lz2hDg0=", - "dev": true, - "requires": { - "extract-zip": "1.5.0", - "fs-extra": "0.26.7", - "hasha": "2.2.0", - "kew": "0.7.0", - "progress": "1.1.8", - "request": "2.67.0", - "request-progress": "2.0.1", - "which": "1.2.14" - }, - "dependencies": { - "bl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", - "integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=", - "dev": true, - "requires": { - "readable-stream": "2.0.6" - } - }, - "concat-stream": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.0.tgz", - "integrity": "sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.0.6", - "typedarray": "0.0.6" - } - }, - "debug": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", - "integrity": "sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk=", - "dev": true - }, - "extract-zip": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.5.0.tgz", - "integrity": "sha1-ksz22B73Cp+kwXRxFMzvbYaIpsQ=", - "dev": true, - "requires": { - "concat-stream": "1.5.0", - "debug": "0.7.4", - "mkdirp": "0.5.0", - "yauzl": "2.4.1" - } - }, - "fs-extra": { - "version": "0.26.7", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", - "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "2.4.0", - "klaw": "1.3.1", - "path-is-absolute": "1.0.1", - "rimraf": "2.6.2" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "qs": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.1.tgz", - "integrity": "sha1-gB/uAw4LlFDWOFrcSKTMVbRK7fw=", - "dev": true - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.67.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.67.0.tgz", - "integrity": "sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I=", - "dev": true, - "requires": { - "aws-sign2": "0.6.0", - "bl": "1.0.3", - "caseless": "0.11.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "1.0.1", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "node-uuid": "1.4.8", - "oauth-sign": "0.8.2", - "qs": "5.2.1", - "stringstream": "0.0.5", - "tough-cookie": "2.2.2", - "tunnel-agent": "0.4.3" - } - }, - "tough-cookie": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", - "integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=", - "dev": true - }, - "which": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", - "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", - "dev": true, - "requires": { - "isexe": "2.0.0" - } - } + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "pify": { @@ -7700,7 +7266,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "2.0.4" + "pinkie": "^2.0.0" } }, "plur": { @@ -7709,7 +7275,7 @@ "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", "dev": true, "requires": { - "irregular-plurals": "1.3.0" + "irregular-plurals": "^1.0.0" } }, "pluralize": { @@ -7772,11 +7338,11 @@ "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.1.3", - "parse-asn1": "5.1.0", - "randombytes": "2.0.5" + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1" } }, "punycode": { @@ -7815,8 +7381,8 @@ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -7825,7 +7391,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7834,7 +7400,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -7845,7 +7411,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "^1.1.5" } } } @@ -7856,7 +7422,7 @@ "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", "dev": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.1.0" } }, "range-parser": { @@ -7883,7 +7449,7 @@ "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, "requires": { - "readable-stream": "2.3.3" + "readable-stream": "^2.0.2" } }, "readable-stream": { @@ -7892,13 +7458,13 @@ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.0.3", + "util-deprecate": "~1.0.1" }, "dependencies": { "string_decoder": { @@ -7907,7 +7473,7 @@ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } } } @@ -7918,7 +7484,7 @@ "integrity": "sha1-O1ohHGMeEjA6VJkcgGwX564ga/8=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "^1.1.13-1" }, "dependencies": { "isarray": { @@ -7933,10 +7499,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } } } @@ -7947,10 +7513,10 @@ "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.3", - "set-immediate-shim": "1.0.1" + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" }, "dependencies": { "graceful-fs": { @@ -7967,8 +7533,8 @@ "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", "mute-stream": "0.0.5" } }, @@ -7978,7 +7544,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "1.4.0" + "resolve": "^1.1.6" } }, "regenerate": { @@ -7999,9 +7565,9 @@ "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "private": "0.1.7" + "babel-runtime": "^6.18.0", + "babel-types": "^6.19.0", + "private": "^0.1.6" } }, "regex-cache": { @@ -8010,7 +7576,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "0.1.3" + "is-equal-shallow": "^0.1.3" } }, "regex-not": { @@ -8019,8 +7585,8 @@ "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, "regexpu-core": { @@ -8029,9 +7595,9 @@ "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "dev": true, "requires": { - "regenerate": "1.3.3", - "regjsgen": "0.2.0", - "regjsparser": "0.1.5" + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" } }, "regjsgen": { @@ -8046,7 +7612,7 @@ "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { - "jsesc": "0.5.0" + "jsesc": "~0.5.0" } }, "remove-trailing-separator": { @@ -8073,7 +7639,7 @@ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { - "is-finite": "1.0.2" + "is-finite": "^1.0.0" } }, "replace-ext": { @@ -8088,7 +7654,7 @@ "integrity": "sha1-DXOurpJm5penj3l2AZZ352rPD/8=", "dev": true, "requires": { - "req-from": "1.0.1" + "req-from": "^1.0.1" } }, "req-from": { @@ -8097,7 +7663,7 @@ "integrity": "sha1-v4HaUUeUfTLRO5R9wSpYrUWHNQ4=", "dev": true, "requires": { - "resolve-from": "2.0.0" + "resolve-from": "^2.0.0" }, "dependencies": { "resolve-from": { @@ -8114,36 +7680,27 @@ "integrity": "sha1-dpPKdou7DqXIzgjAhKRe+gW4kqs=", "dev": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "bl": "1.1.2", - "caseless": "0.11.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "1.0.1", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "node-uuid": "1.4.8", - "oauth-sign": "0.8.2", - "qs": "6.2.3", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.4.3" - } - }, - "request-progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", - "dev": true, - "requires": { - "throttleit": "1.0.0" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "bl": "~1.1.2", + "caseless": "~0.11.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~1.0.0-rc4", + "har-validator": "~2.0.6", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "node-uuid": "~1.4.7", + "oauth-sign": "~0.8.1", + "qs": "~6.2.0", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "~0.4.1" } }, "require-relative": { @@ -8158,8 +7715,8 @@ "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { - "caller-path": "0.1.0", - "resolve-from": "1.0.1" + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" } }, "requires-port": { @@ -8174,7 +7731,7 @@ "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resolve-dir": { @@ -8183,8 +7740,8 @@ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "global-modules": "1.0.0" + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" } }, "resolve-from": { @@ -8205,8 +7762,8 @@ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" } }, "ret": { @@ -8221,7 +7778,7 @@ "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", "dev": true, "requires": { - "align-text": "0.1.4" + "align-text": "^0.1.1" } }, "rimraf": { @@ -8230,7 +7787,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "ripemd160": { @@ -8239,8 +7796,8 @@ "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", "dev": true, "requires": { - "hash-base": "2.0.2", - "inherits": "2.0.3" + "hash-base": "^2.0.0", + "inherits": "^2.0.1" } }, "run-async": { @@ -8249,7 +7806,7 @@ "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", "dev": true, "requires": { - "once": "1.4.0" + "once": "^1.3.0" } }, "rx-lite": { @@ -8270,7 +7827,7 @@ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { - "ret": "0.1.15" + "ret": "~0.1.10" } }, "samsam": { @@ -8303,10 +7860,10 @@ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -8315,7 +7872,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -8332,8 +7889,8 @@ "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "shasum": { @@ -8342,8 +7899,8 @@ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { - "json-stable-stringify": "0.0.1", - "sha.js": "2.4.9" + "json-stable-stringify": "~0.0.0", + "sha.js": "~2.4.4" } }, "shell-quote": { @@ -8352,10 +7909,10 @@ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "dev": true, "requires": { - "array-filter": "0.0.1", - "array-map": "0.0.0", - "array-reduce": "0.0.0", - "jsonify": "0.0.0" + "array-filter": "~0.0.0", + "array-map": "~0.0.0", + "array-reduce": "~0.0.0", + "jsonify": "~0.0.0" } }, "shelljs": { @@ -8364,9 +7921,9 @@ "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", "dev": true, "requires": { - "glob": "7.1.2", - "interpret": "1.0.4", - "rechoir": "0.6.2" + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" } }, "sigmund": { @@ -8384,7 +7941,7 @@ "formatio": "1.1.1", "lolex": "1.3.2", "samsam": "1.1.2", - "util": "0.10.3" + "util": ">=0.10.3 <1" } }, "slash": { @@ -8405,14 +7962,14 @@ "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.1", - "use": "3.1.0" + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" }, "dependencies": { "atob": { @@ -8427,7 +7984,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -8436,7 +7993,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "source-map-resolve": { @@ -8445,11 +8002,11 @@ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", "dev": true, "requires": { - "atob": "2.1.1", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" + "atob": "^2.0.0", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-url": { @@ -8466,9 +8023,9 @@ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" }, "dependencies": { "define-property": { @@ -8477,7 +8034,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -8486,7 +8043,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -8495,7 +8052,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -8504,9 +8061,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -8529,7 +8086,7 @@ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.2.0" } }, "sntp": { @@ -8538,7 +8095,7 @@ "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "dev": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "socket.io": { @@ -8695,10 +8252,10 @@ "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", "dev": true, "requires": { - "atob": "1.1.3", - "resolve-url": "0.2.1", - "source-map-url": "0.3.0", - "urix": "0.1.0" + "atob": "~1.1.0", + "resolve-url": "~0.2.1", + "source-map-url": "~0.3.0", + "urix": "~0.1.0" } }, "source-map-support": { @@ -8707,7 +8264,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.6" } }, "source-map-url": { @@ -8728,7 +8285,7 @@ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "extend-shallow": "3.0.2" + "extend-shallow": "^3.0.0" } }, "sprintf-js": { @@ -8743,14 +8300,14 @@ "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", "dev": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "assert-plus": { @@ -8767,8 +8324,8 @@ "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" + "define-property": "^0.2.5", + "object-copy": "^0.1.0" }, "dependencies": { "define-property": { @@ -8777,7 +8334,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -8794,8 +8351,8 @@ "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3" + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" } }, "stream-combiner2": { @@ -8804,8 +8361,8 @@ "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "duplexer2": "0.1.4", - "readable-stream": "2.3.3" + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" } }, "stream-consume": { @@ -8820,11 +8377,11 @@ "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", "dev": true, "requires": { - "builtin-status-codes": "3.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "to-arraybuffer": "1.0.1", - "xtend": "4.0.1" + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.2.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" } }, "stream-splicer": { @@ -8833,8 +8390,8 @@ "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3" + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" } }, "string-width": { @@ -8843,9 +8400,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -8866,7 +8423,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-bom": { @@ -8875,8 +8432,8 @@ "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", "dev": true, "requires": { - "first-chunk-stream": "1.0.0", - "is-utf8": "0.2.1" + "first-chunk-stream": "^1.0.0", + "is-utf8": "^0.2.0" } }, "strip-json-comments": { @@ -8891,7 +8448,7 @@ "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, "requires": { - "minimist": "1.2.0" + "minimist": "^1.1.0" } }, "supports-color": { @@ -8906,7 +8463,7 @@ "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", "dev": true, "requires": { - "acorn": "4.0.13" + "acorn": "^4.0.3" } }, "table": { @@ -8915,12 +8472,12 @@ "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", "dev": true, "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", - "lodash": "4.17.4", + "ajv": "^4.7.0", + "ajv-keywords": "^1.0.0", + "chalk": "^1.1.1", + "lodash": "^4.0.0", "slice-ansi": "0.0.4", - "string-width": "2.1.1" + "string-width": "^2.0.0" }, "dependencies": { "ansi-regex": { @@ -8941,8 +8498,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "strip-ansi": { @@ -8951,7 +8508,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -8962,8 +8519,8 @@ "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", "dev": true, "requires": { - "os-tmpdir": "1.0.2", - "rimraf": "2.2.8" + "os-tmpdir": "^1.0.0", + "rimraf": "~2.2.6" }, "dependencies": { "rimraf": { @@ -8980,12 +8537,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "throttleit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", - "dev": true - }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -8998,8 +8549,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" } }, "tildify": { @@ -9008,7 +8559,7 @@ "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "os-homedir": "^1.0.0" } }, "time-stamp": { @@ -9023,7 +8574,7 @@ "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, "requires": { - "process": "0.11.10" + "process": "~0.11.0" } }, "tmp": { @@ -9032,7 +8583,7 @@ "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", "dev": true, "requires": { - "os-tmpdir": "1.0.2" + "os-tmpdir": "~1.0.1" } }, "to-array": { @@ -9059,7 +8610,7 @@ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "to-regex": { @@ -9068,10 +8619,10 @@ "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" } }, "to-regex-range": { @@ -9080,8 +8631,8 @@ "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" }, "dependencies": { "is-number": { @@ -9090,7 +8641,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } } } @@ -9101,7 +8652,7 @@ "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", "dev": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "trim-right": { @@ -9141,7 +8692,7 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { - "prelude-ls": "1.1.2" + "prelude-ls": "~1.1.2" } }, "type-is": { @@ -9151,7 +8702,7 @@ "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "2.1.17" + "mime-types": "~2.1.15" } }, "typedarray": { @@ -9166,9 +8717,9 @@ "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", "dev": true, "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" } }, "uglify-save-license": { @@ -9208,10 +8759,10 @@ "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "dev": true, "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" }, "dependencies": { "extend-shallow": { @@ -9220,7 +8771,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "set-value": { @@ -9229,10 +8780,10 @@ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" } } } @@ -9255,8 +8806,8 @@ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" + "has-value": "^0.3.1", + "isobject": "^3.0.0" }, "dependencies": { "has-value": { @@ -9265,9 +8816,9 @@ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" }, "dependencies": { "isobject": { @@ -9325,7 +8876,7 @@ "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" }, "dependencies": { "kind-of": { @@ -9348,8 +8899,8 @@ "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=", "dev": true, "requires": { - "lru-cache": "2.2.4", - "tmp": "0.0.31" + "lru-cache": "2.2.x", + "tmp": "0.0.x" }, "dependencies": { "lru-cache": { @@ -9395,7 +8946,7 @@ "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", "dev": true, "requires": { - "user-home": "1.1.1" + "user-home": "^1.1.1" } }, "verror": { @@ -9404,9 +8955,9 @@ "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" }, "dependencies": { "assert-plus": { @@ -9423,8 +8974,8 @@ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "dev": true, "requires": { - "clone": "1.0.2", - "clone-stats": "0.0.1", + "clone": "^1.0.0", + "clone-stats": "^0.0.1", "replace-ext": "0.0.1" } }, @@ -9434,14 +8985,14 @@ "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", "dev": true, "requires": { - "defaults": "1.0.3", - "glob-stream": "3.1.18", - "glob-watcher": "0.0.6", - "graceful-fs": "3.0.11", - "mkdirp": "0.5.1", - "strip-bom": "1.0.0", - "through2": "0.6.5", - "vinyl": "0.4.6" + "defaults": "^1.0.0", + "glob-stream": "^3.1.5", + "glob-watcher": "^0.0.6", + "graceful-fs": "^3.0.0", + "mkdirp": "^0.5.0", + "strip-bom": "^1.0.0", + "through2": "^0.6.1", + "vinyl": "^0.4.0" }, "dependencies": { "clone": { @@ -9462,10 +9013,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "through2": { @@ -9474,8 +9025,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } }, "vinyl": { @@ -9484,8 +9035,8 @@ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" + "clone": "^0.2.0", + "clone-stats": "^0.0.1" } } } @@ -9496,8 +9047,8 @@ "integrity": "sha1-RMvlEIIFJ53rDFZTwJSiiHk4sas=", "dev": true, "requires": { - "through2": "0.6.5", - "vinyl": "0.4.6" + "through2": "^0.6.1", + "vinyl": "^0.4.3" }, "dependencies": { "clone": { @@ -9518,10 +9069,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "through2": { @@ -9530,8 +9081,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } }, "vinyl": { @@ -9540,8 +9091,8 @@ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" + "clone": "^0.2.0", + "clone-stats": "^0.0.1" } } } @@ -9552,7 +9103,7 @@ "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.1" } }, "vm-browserify": { @@ -9576,12 +9127,12 @@ "integrity": "sha1-Gbz9e/y/Qdf0/jwpdAvORfdk4gM=", "dev": true, "requires": { - "browserify": "10.2.6", - "chokidar": "1.7.0", - "defined": "1.0.0", - "outpipe": "1.1.1", - "through2": "0.6.5", - "xtend": "4.0.1" + "browserify": "^10.0.0", + "chokidar": "^1.0.0", + "defined": "^1.0.0", + "outpipe": "^1.1.0", + "through2": "~0.6.3", + "xtend": "^4.0.0" }, "dependencies": { "assert": { @@ -9605,11 +9156,11 @@ "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.6.1", - "defined": "1.0.0", - "through2": "1.1.1", - "umd": "3.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.6.1", + "defined": "^1.0.0", + "through2": "^1.0.0", + "umd": "^3.0.0" }, "dependencies": { "through2": { @@ -9618,8 +9169,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -9630,55 +9181,55 @@ "integrity": "sha1-3L/veU9Uj1+EmCFIFPaXpcUMCJY=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "assert": "1.3.0", - "browser-pack": "5.0.1", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", - "buffer": "3.6.0", - "builtins": "0.0.7", + "JSONStream": "^1.0.3", + "assert": "~1.3.0", + "browser-pack": "^5.0.0", + "browser-resolve": "^1.7.1", + "browserify-zlib": "~0.1.2", + "buffer": "^3.0.0", + "builtins": "~0.0.3", "commondir": "0.0.1", - "concat-stream": "1.4.10", - "console-browserify": "1.1.0", - "constants-browserify": "0.0.1", - "crypto-browserify": "3.11.1", - "defined": "1.0.0", - "deps-sort": "1.3.9", - "domain-browser": "1.1.7", - "duplexer2": "0.0.2", - "events": "1.0.2", - "glob": "4.5.3", - "has": "1.0.1", - "htmlescape": "1.1.1", - "http-browserify": "1.7.0", - "https-browserify": "0.0.1", - "inherits": "2.0.3", - "insert-module-globals": "6.6.3", + "concat-stream": "~1.4.1", + "console-browserify": "^1.1.0", + "constants-browserify": "~0.0.1", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^1.3.7", + "domain-browser": "~1.1.0", + "duplexer2": "~0.0.2", + "events": "~1.0.0", + "glob": "^4.0.5", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "http-browserify": "^1.4.0", + "https-browserify": "~0.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^6.4.1", "isarray": "0.0.1", - "labeled-stream-splicer": "1.0.2", - "module-deps": "3.9.1", - "os-browserify": "0.1.2", - "parents": "1.0.1", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "1.1.1", - "readable-stream": "1.1.14", - "resolve": "1.4.0", - "shasum": "1.0.2", - "shell-quote": "0.0.1", - "stream-browserify": "1.0.0", - "string_decoder": "0.10.31", - "subarg": "1.0.0", - "syntax-error": "1.3.0", - "through2": "1.1.1", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.0", - "url": "0.10.3", - "util": "0.10.3", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" + "labeled-stream-splicer": "^1.0.0", + "module-deps": "^3.7.11", + "os-browserify": "~0.1.1", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^1.1.1", + "readable-stream": "^1.1.13", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "~0.0.1", + "stream-browserify": "^1.0.0", + "string_decoder": "~0.10.0", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^1.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "~0.0.0", + "url": "~0.10.1", + "util": "~0.10.1", + "vm-browserify": "~0.0.1", + "xtend": "^4.0.0" }, "dependencies": { "through2": { @@ -9687,8 +9238,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -9700,8 +9251,8 @@ "dev": true, "requires": { "base64-js": "0.0.8", - "ieee754": "1.1.8", - "isarray": "1.0.0" + "ieee754": "^1.1.4", + "isarray": "^1.0.0" }, "dependencies": { "isarray": { @@ -9718,10 +9269,10 @@ "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", "dev": true, "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.5.0", - "lodash.memoize": "3.0.4", - "source-map": "0.4.4" + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.5.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.4.2" } }, "concat-stream": { @@ -9730,9 +9281,9 @@ "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "1.1.14", - "typedarray": "0.0.6" + "inherits": "~2.0.1", + "readable-stream": "~1.1.9", + "typedarray": "~0.0.5" } }, "constants-browserify": { @@ -9747,10 +9298,10 @@ "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "1.1.1" + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^1.0.0" }, "dependencies": { "through2": { @@ -9759,8 +9310,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -9771,7 +9322,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "~1.1.9" } }, "events": { @@ -9786,10 +9337,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.4.0" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" } }, "inline-source-map": { @@ -9798,7 +9349,7 @@ "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", "dev": true, "requires": { - "source-map": "0.4.4" + "source-map": "~0.4.0" } }, "insert-module-globals": { @@ -9807,14 +9358,14 @@ "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.6.1", - "concat-stream": "1.4.10", - "is-buffer": "1.1.5", - "lexical-scope": "1.2.0", - "process": "0.11.10", - "through2": "1.1.1", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.6.1", + "concat-stream": "~1.4.1", + "is-buffer": "^1.1.0", + "lexical-scope": "^1.2.0", + "process": "~0.11.0", + "through2": "^1.0.0", + "xtend": "^4.0.0" }, "dependencies": { "through2": { @@ -9823,8 +9374,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -9841,9 +9392,9 @@ "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", "dev": true, "requires": { - "inherits": "2.0.3", - "isarray": "0.0.1", - "stream-splicer": "1.3.2" + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "stream-splicer": "^1.1.0" } }, "minimatch": { @@ -9852,7 +9403,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.0.0" } }, "module-deps": { @@ -9861,20 +9412,20 @@ "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "browser-resolve": "1.11.2", - "concat-stream": "1.4.10", - "defined": "1.0.0", - "detective": "4.5.0", + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "concat-stream": "~1.4.5", + "defined": "^1.0.0", + "detective": "^4.0.0", "duplexer2": "0.0.2", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "1.1.14", - "resolve": "1.4.0", - "stream-combiner2": "1.0.2", - "subarg": "1.0.0", - "through2": "1.1.1", - "xtend": "4.0.1" + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^1.1.13", + "resolve": "^1.1.3", + "stream-combiner2": "~1.0.0", + "subarg": "^1.0.0", + "through2": "^1.0.0", + "xtend": "^4.0.0" }, "dependencies": { "through2": { @@ -9883,8 +9434,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -9895,8 +9446,8 @@ "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "readable-wrap": "1.0.0" + "readable-stream": "^1.0.31", + "readable-wrap": "^1.0.0" } }, "readable-stream": { @@ -9905,10 +9456,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "shell-quote": { @@ -9923,7 +9474,7 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } }, "stream-browserify": { @@ -9932,8 +9483,8 @@ "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "1.1.14" + "inherits": "~2.0.1", + "readable-stream": "^1.0.27-1" } }, "stream-combiner2": { @@ -9942,8 +9493,8 @@ "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", "dev": true, "requires": { - "duplexer2": "0.0.2", - "through2": "0.5.1" + "duplexer2": "~0.0.2", + "through2": "~0.5.1" }, "dependencies": { "readable-stream": { @@ -9952,10 +9503,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "through2": { @@ -9964,8 +9515,8 @@ "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "3.0.0" + "readable-stream": "~1.0.17", + "xtend": "~3.0.0" } }, "xtend": { @@ -9983,11 +9534,11 @@ "dev": true, "requires": { "indexof": "0.0.1", - "inherits": "2.0.3", - "isarray": "0.0.1", - "readable-stream": "1.1.14", - "readable-wrap": "1.0.0", - "through2": "1.1.1" + "inherits": "^2.0.1", + "isarray": "~0.0.1", + "readable-stream": "^1.1.13-1", + "readable-wrap": "^1.0.0", + "through2": "^1.0.0" }, "dependencies": { "through2": { @@ -9996,8 +9547,8 @@ "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", "dev": true, "requires": { - "readable-stream": "1.1.14", - "xtend": "4.0.1" + "readable-stream": ">=1.1.13-1 <1.2.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -10008,8 +9559,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" }, "dependencies": { "readable-stream": { @@ -10018,10 +9569,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } } } @@ -10052,7 +9603,7 @@ "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, "window-size": { @@ -10079,7 +9630,7 @@ "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, "requires": { - "mkdirp": "0.5.1" + "mkdirp": "^0.5.1" } }, "ws": { @@ -10088,8 +9639,8 @@ "integrity": "sha1-iiRPoFJAHgjJiGz0SoUYnh/UBn8=", "dev": true, "requires": { - "options": "0.0.6", - "ultron": "1.0.2" + "options": ">=0.0.5", + "ultron": "1.0.x" } }, "wtf-8": { @@ -10116,21 +9667,12 @@ "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", "window-size": "0.1.0" } }, - "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", - "dev": true, - "requires": { - "fd-slicer": "1.0.1" - } - }, "yeast": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", diff --git a/package.json b/package.json index 90f6be51..3e65f624 100644 --- a/package.json +++ b/package.json @@ -60,9 +60,7 @@ "karma-expect": "^1.1.0", "karma-firefox-launcher": "^1.0.0", "karma-mocha": "^1.3.0", - "karma-phantomjs-launcher": "^1.0.2", "mocha": "^3.1.2", - "phantomjs": "^1.9.18", "sinon": "^1.16.1", "through2": "^2.0.0", "vinyl-source-stream": "^1.1.0" From 9534f5485bc17dcbaa20e7762f2d2548bb2cfcf4 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 19 Jun 2018 22:14:19 +0200 Subject: [PATCH 204/224] Fix UMD bundling (#84) * Mend UMD bundling, rename global: `thread` => `threads` * Improve UMD bundle documentation * Drop bundle.browser.js, since browserify will add the UMD wrapper --- README.md | 2 +- gulpfile.js | 4 ++-- src/bundle.browser.js | 14 -------------- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 src/bundle.browser.js diff --git a/README.md b/README.md index f2e87a42..00bc1377 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ bower install --save threads ``` -(where `VERSION` is the library's version to use, like `v0.7.3`) +Note: Replace `VERSION` with the library's version you want to use, like `v0.12.0`. The library will be exposed on the global window scope as `threads`. ## How To diff --git a/gulpfile.js b/gulpfile.js index 5a06b0eb..f385022d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -90,8 +90,8 @@ gulp.task('browser-slave-module', () => { gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], () => { - return browserify() - .add('./lib/bundle.browser.js') + return browserify({ standalone: 'threads' }) + .add('./lib/index.js') // overrides, so the node-specific files won't make their way into the bundle .require('./lib/worker.browser/worker.js', { expose : './worker' }) diff --git a/src/bundle.browser.js b/src/bundle.browser.js deleted file mode 100644 index 408d3c29..00000000 --- a/src/bundle.browser.js +++ /dev/null @@ -1,14 +0,0 @@ -/*eslint-env browser, amd, commonjs*/ -/*global module*/ - -import threadLib from './index'; - -if (typeof window === 'object') { - window.thread = threadLib; -} - -if (typeof define === 'function') { - define([], function() { return threadLib; }); -} else if (typeof module === 'object') { - module.exports = threadLib; -} From b8f0cae16e8602464715e0dcc7c611ae2d3f1efc Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 19 Jun 2018 22:15:31 +0200 Subject: [PATCH 205/224] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6968c2b6..ab500e47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.12.0 + +- Fix UMD bundling (#84) + ## 0.11.0 - Implement job abortion (#78, credits to @Liu233w) From 9c2d0d86c8ae3c0059538eedf95a2f63d3df75a1 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 19 Jun 2018 22:15:50 +0200 Subject: [PATCH 206/224] 0.12.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 92b0a5ce..112b3a73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3e65f624..f3b3bf02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.11.0", + "version": "0.12.0", "keywords": [ "threads", "web worker", From 55e31441fe07669248307acdbcaffcf4ba984817 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 19 Jun 2018 22:21:49 +0200 Subject: [PATCH 207/224] Fix script tag src description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00bc1377..cf7d15e1 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ bower install --save threads ``` -Note: Replace `VERSION` with the library's version you want to use, like `v0.12.0`. The library will be exposed on the global window scope as `threads`. +Note: Replace `VERSION` with the library's version you want to use, like `0.12.0`. The library will be exposed on the global window scope as `threads`. ## How To From 2aab763e03951c945953252120c156f0a64c283a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Fri, 22 Jun 2018 08:33:16 +0200 Subject: [PATCH 208/224] Add link the v1.0 API draft to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cf7d15e1..055e692c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ when run by node.js. Also supports browsers which do not support web workers. - Well tested - ES6 and backwards-compatible +Side note: Using threads.js? Check out the [Version 1.0 API draft](https://github.com/andywer/threads.js/issues/88) and feel free to leave feedback! + ## Basic usage From 7035e6a7abcb989bb9818417acdb992a70b4202e Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:02:11 +0000 Subject: [PATCH 209/224] Update package `natives` to fix node 11 crash (#97) See . --- package-lock.json | 6 +++--- package.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 112b3a73..15b50ef6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6789,9 +6789,9 @@ "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=" }, "natives": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.3.tgz", - "integrity": "sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", + "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==", "dev": true }, "natural-compare": { diff --git a/package.json b/package.json index f3b3bf02..b1325f64 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "karma-firefox-launcher": "^1.0.0", "karma-mocha": "^1.3.0", "mocha": "^3.1.2", + "natives": "^1.1.6", "sinon": "^1.16.1", "through2": "^2.0.0", "vinyl-source-stream": "^1.1.0" From 962b708b5fe43114310113dee39a624dab9f5ccb Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:14:29 +0000 Subject: [PATCH 210/224] Update most outdated dev dependencies, use karma with puppeteer --- gulpfile.js | 2 +- karma.conf.js | 1 + package-lock.json | 3714 +++++++++++++++++---------------------------- package.json | 9 +- 4 files changed, 1397 insertions(+), 2329 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f385022d..95689c31 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -128,7 +128,7 @@ gulp.task('test-browser-after-node', ['test-node'], done => { gulp.task('test-node', ['dist', 'babel-spec'], () => { return gulp.src('test/spec-build/*.spec.js', { read: false }) - .pipe(mocha()); + .pipe(mocha({ exit: true })); }); diff --git a/karma.conf.js b/karma.conf.js index 8a5fa7ea..43139c08 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,4 +1,5 @@ // Karma configuration +process.env.CHROME_BIN = require('puppeteer').executablePath() module.exports = function configureKarma(config) { config.set({ diff --git a/package-lock.json b/package-lock.json index 15b50ef6..4dc4682d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,12 +14,6 @@ "through2": "^2.0.3" } }, - "Base64": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/Base64/-/Base64-0.2.1.tgz", - "integrity": "sha1-ujpCMHCOGGcFBl5mur3Uw1z2ACg=", - "dev": true - }, "JSONStream": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", @@ -37,13 +31,30 @@ "dev": true }, "accepts": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", "dev": true, "requires": { - "mime-types": "~2.1.11", + "mime-types": "~2.1.18", "negotiator": "0.6.1" + }, + "dependencies": { + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "dev": true + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "dev": true, + "requires": { + "mime-db": "~1.37.0" + } + } } }, "acorn": { @@ -75,6 +86,15 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", "dev": true }, + "agent-base": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "dev": true, + "requires": { + "es6-promisify": "^5.0.0" + } + }, "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", @@ -119,6 +139,15 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", @@ -137,14 +166,20 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "ansi-wrap": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "dev": true + }, "anymatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, "requires": { - "micromatch": "^2.1.5", - "normalize-path": "^2.0.0" + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" } }, "archy": { @@ -163,13 +198,10 @@ } }, "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true }, "arr-flatten": { "version": "1.1.0", @@ -235,15 +267,15 @@ "dev": true }, "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, "arraybuffer.slice": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", - "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", "dev": true }, "arrify": { @@ -253,10 +285,13 @@ "dev": true }, "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "dev": true + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } }, "asn1.js": { "version": "4.9.1", @@ -311,6 +346,12 @@ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -318,9 +359,9 @@ "dev": true }, "atob": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", - "integrity": "sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, "aws-sign2": { @@ -347,9 +388,9 @@ } }, "babel-core": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", - "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", + "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", "dev": true, "requires": { "babel-code-frame": "^6.26.0", @@ -362,29 +403,38 @@ "babel-traverse": "^6.26.0", "babel-types": "^6.26.0", "babylon": "^6.18.0", - "convert-source-map": "^1.5.0", - "debug": "^2.6.8", + "convert-source-map": "^1.5.1", + "debug": "^2.6.9", "json5": "^0.5.1", "lodash": "^4.17.4", "minimatch": "^3.0.4", "path-is-absolute": "^1.0.1", - "private": "^0.1.7", + "private": "^0.1.8", "slash": "^1.0.0", - "source-map": "^0.5.6" + "source-map": "^0.5.7" }, "dependencies": { "convert-source-map": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.0.tgz", - "integrity": "sha1-ms1whRxtXf3ZPZKC5e35SgP/RrU=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", "dev": true } } }, "babel-generator": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz", - "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", + "version": "6.26.1", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", + "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "dev": true, "requires": { "babel-messages": "^6.23.0", @@ -393,7 +443,7 @@ "detect-indent": "^4.0.0", "jsesc": "^1.3.0", "lodash": "^4.17.4", - "source-map": "^0.5.6", + "source-map": "^0.5.7", "trim-right": "^1.0.1" }, "dependencies": { @@ -643,9 +693,9 @@ } }, "babel-plugin-transform-es2015-modules-commonjs": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz", - "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", + "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", "dev": true, "requires": { "babel-plugin-transform-strict-mode": "^6.24.1", @@ -996,11 +1046,10 @@ "dev": true }, "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "dev": true, - "optional": true, "requires": { "tweetnacl": "^0.14.3" } @@ -1021,9 +1070,9 @@ } }, "binary-extensions": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.10.0.tgz", - "integrity": "sha1-muuabF6IY4qtFx4Wf1kAq+JINdA=", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.0.tgz", + "integrity": "sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw==", "dev": true }, "bl": { @@ -1052,15 +1101,15 @@ } }, "blob": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==", "dev": true }, "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", + "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", "dev": true }, "bn.js": { @@ -1070,27 +1119,27 @@ "dev": true }, "body-parser": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", - "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", "dev": true, "requires": { "bytes": "3.0.0", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.1", - "http-errors": "~1.6.2", - "iconv-lite": "0.4.19", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", "on-finished": "~2.3.0", - "qs": "6.5.1", - "raw-body": "2.3.2", - "type-is": "~1.6.15" + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" }, "dependencies": { "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true } } @@ -1115,14 +1164,32 @@ } }, "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } } }, "brorand": { @@ -1162,9 +1229,9 @@ } }, "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "browserify": { @@ -1303,6 +1370,34 @@ "isarray": "^1.0.0" } }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dev": true, + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", + "dev": true + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -1324,12 +1419,6 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, - "builtins": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-0.0.7.tgz", - "integrity": "sha1-NVIZzWzxjb58Acx/0tznZc/cVJo=", - "dev": true - }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -1430,20 +1519,24 @@ } }, "chokidar": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", - "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", + "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", "dev": true, "requires": { - "anymatch": "^1.3.0", + "anymatch": "^2.0.0", "async-each": "^1.0.0", - "fsevents": "^1.0.0", - "glob-parent": "^2.0.0", + "braces": "^2.3.0", + "fsevents": "^1.2.2", + "glob-parent": "^3.1.0", "inherits": "^2.0.1", "is-binary-path": "^1.0.0", - "is-glob": "^2.0.0", + "is-glob": "^4.0.0", + "lodash.debounce": "^4.0.8", + "normalize-path": "^2.1.1", "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0" + "readdirp": "^2.0.0", + "upath": "^1.0.5" } }, "cipher-base": { @@ -1589,9 +1682,9 @@ } }, "colors": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", "dev": true }, "combine-lists": { @@ -1633,12 +1726,6 @@ "graceful-readlink": ">= 1.0.0" } }, - "commondir": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-0.0.1.tgz", - "integrity": "sha1-ifAP3NUbUZxXhzP+xWPmptp/W+I=", - "dev": true - }, "component-bind": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", @@ -1646,9 +1733,9 @@ "dev": true }, "component-emitter": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", - "integrity": "sha1-KWWU8nU9qmOZbSrwjRWpURbJrsM=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", "dev": true }, "component-inherit": { @@ -1691,22 +1778,30 @@ } }, "concat-with-sourcemaps": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.0.4.tgz", - "integrity": "sha1-9Vs74q60dgGxCi1SWcz7cP0vHdY=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz", + "integrity": "sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==", "dev": true, "requires": { - "source-map": "^0.5.1" + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "connect": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.5.tgz", - "integrity": "sha1-+43ee6B2OHfQ7J352sC0tA5yx9o=", + "version": "3.6.6", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", + "integrity": "sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ=", "dev": true, "requires": { "debug": "2.6.9", - "finalhandler": "1.0.6", + "finalhandler": "1.1.0", "parseurl": "~1.3.2", "utils-merge": "1.0.1" } @@ -1864,6 +1959,27 @@ "sha.js": "^2.4.8" } }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true + } + } + }, "cryptiles": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", @@ -1892,25 +2008,22 @@ } }, "css": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/css/-/css-2.2.1.tgz", - "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", + "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", "dev": true, "requires": { - "inherits": "^2.0.1", - "source-map": "^0.1.38", - "source-map-resolve": "^0.3.0", + "inherits": "^2.0.3", + "source-map": "^0.6.1", + "source-map-resolve": "^0.5.2", "urix": "^0.1.0" }, "dependencies": { "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true } } }, @@ -1929,6 +2042,12 @@ "es5-ext": "^0.10.9" } }, + "dargs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/dargs/-/dargs-5.1.0.tgz", + "integrity": "sha1-7H6lDHhWTNNsnV7Bj2Yyn63ieCk=", + "dev": true + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -1946,6 +2065,12 @@ } } }, + "date-format": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz", + "integrity": "sha1-YV6CjiM90aubua4JUODOzPpuytg=", + "dev": true + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -1998,12 +2123,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", - "dev": true - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -2108,9 +2227,9 @@ "dev": true }, "depd": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", - "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, "deprecated": { @@ -2179,9 +2298,9 @@ "dev": true }, "diff": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", - "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, "diffie-hellman": { @@ -2233,13 +2352,13 @@ } }, "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "dev": true, - "optional": true, "requires": { - "jsbn": "~0.1.0" + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" } }, "ee-first": { @@ -2264,9 +2383,9 @@ } }, "encodeurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", - "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", "dev": true }, "end-of-stream": { @@ -2290,91 +2409,71 @@ } }, "engine.io": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-1.8.3.tgz", - "integrity": "sha1-jef5eJXSDTm4X4ju7nd7K9QrE9Q=", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.2.1.tgz", + "integrity": "sha512-+VlKzHzMhaU+GsCIg4AoXF1UdDFjHHwMmMKqMJNDNLlUlejz58FCy4LBqB2YVJskHGYl06BatYWKP2TVdVXE5w==", "dev": true, "requires": { - "accepts": "1.3.3", + "accepts": "~1.3.4", "base64id": "1.0.0", "cookie": "0.3.1", - "debug": "2.3.3", - "engine.io-parser": "1.3.2", - "ws": "1.1.2" + "debug": "~3.1.0", + "engine.io-parser": "~2.1.0", + "ws": "~3.3.1" }, "dependencies": { "debug": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "0.7.2" + "ms": "2.0.0" } - }, - "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true } } }, "engine.io-client": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-1.8.3.tgz", - "integrity": "sha1-F5jtk0USRkU9TG9jXXogH+lA1as=", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", + "integrity": "sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw==", "dev": true, "requires": { "component-emitter": "1.2.1", "component-inherit": "0.0.3", - "debug": "2.3.3", - "engine.io-parser": "1.3.2", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.1", "has-cors": "1.1.0", "indexof": "0.0.1", - "parsejson": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "ws": "1.1.2", - "xmlhttprequest-ssl": "1.5.3", + "ws": "~3.3.1", + "xmlhttprequest-ssl": "~1.5.4", "yeast": "0.1.2" }, "dependencies": { - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, "debug": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "0.7.2" + "ms": "2.0.0" } - }, - "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true } } }, "engine.io-parser": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.2.tgz", - "integrity": "sha1-k3sHnwAH0Ik+xW1GyyILjLQ1Igo=", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.3.tgz", + "integrity": "sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA==", "dev": true, "requires": { "after": "0.8.2", - "arraybuffer.slice": "0.0.6", + "arraybuffer.slice": "~0.0.7", "base64-arraybuffer": "0.1.5", - "blob": "0.0.4", - "has-binary": "0.1.7", - "wtf-8": "1.0.0" + "blob": "0.0.5", + "has-binary2": "~1.0.2" } }, "ent": { @@ -2418,6 +2517,21 @@ "event-emitter": "~0.3.5" } }, + "es6-promise": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", + "dev": true + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "dev": true, + "requires": { + "es6-promise": "^4.0.3" + } + }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", @@ -2671,6 +2785,21 @@ "safe-buffer": "^5.1.1" } }, + "execa": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", + "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, "exit-hook": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", @@ -2694,6 +2823,12 @@ "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", "dev": true }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "dev": true + }, "braces": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", @@ -2702,17 +2837,54 @@ "requires": { "expand-range": "^0.1.0" } - }, - "expand-range": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", - "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", + } + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-number": "^0.1.1", - "repeat-string": "^0.2.2" + "is-descriptor": "^0.1.0" } }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-range": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", + "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", + "dev": true, + "requires": { + "is-number": "^0.1.1", + "repeat-string": "^0.2.2" + }, + "dependencies": { "is-number": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", @@ -2727,24 +2899,6 @@ } } }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "^2.1.0" - } - }, "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", @@ -2788,24 +2942,112 @@ } }, "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "fancy-log": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "dev": true, + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fancy-log": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", + "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", "dev": true, "requires": { "chalk": "^1.1.1", @@ -2818,6 +3060,15 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -2854,29 +3105,33 @@ } } }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^1.1.3", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } } }, "finalhandler": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.6.tgz", - "integrity": "sha1-AHrqM9Gk0+QgF/YkhIrVjSEvgU8=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", "dev": true, "requires": { "debug": "2.6.9", @@ -2886,6 +3141,14 @@ "parseurl": "~1.3.2", "statuses": "~1.3.1", "unpipe": "~1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + } } }, "find-index": { @@ -3242,21 +3505,38 @@ } } }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", "dev": true }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "follow-redirects": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", + "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", "dev": true, "requires": { - "for-in": "^1.0.1" + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -3319,45 +3599,35 @@ "dev": true }, "fsevents": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", - "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.7.tgz", + "integrity": "sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw==", "dev": true, "optional": true, "requires": { - "nan": "^2.3.0", - "node-pre-gyp": "^0.6.36" + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" }, "dependencies": { "abbrev": { - "version": "1.1.0", + "version": "1.1.1", "bundled": true, "dev": true, "optional": true }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" - } - }, "ansi-regex": { "version": "2.1.1", "bundled": true, "dev": true }, "aproba": { - "version": "1.1.1", + "version": "1.2.0", "bundled": true, "dev": true, "optional": true }, "are-we-there-yet": { - "version": "1.1.4", + "version": "1.1.5", "bundled": true, "dev": true, "optional": true, @@ -3366,88 +3636,22 @@ "readable-stream": "^2.0.6" } }, - "asn1": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true, - "dev": true, - "optional": true - }, "balanced-match": { - "version": "0.4.2", + "version": "1.0.0", "bundled": true, "dev": true }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "dev": true, - "requires": { - "inherits": "~2.0.0" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.x.x" - } - }, "brace-expansion": { - "version": "1.1.7", + "version": "1.1.11", "bundled": true, "dev": true, "requires": { - "balanced-match": "^0.4.1", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "buffer-shims": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "caseless": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true - }, - "co": { - "version": "4.6.0", + "chownr": { + "version": "1.1.1", "bundled": true, "dev": true, "optional": true @@ -3457,14 +3661,6 @@ "bundled": true, "dev": true }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, "concat-map": { "version": "0.0.1", "bundled": true, @@ -3478,36 +3674,11 @@ "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "boom": "2.x.x" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, "dev": true, - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } + "optional": true }, "debug": { - "version": "2.6.8", + "version": "2.6.9", "bundled": true, "dev": true, "optional": true, @@ -3516,88 +3687,40 @@ } }, "deep-extend": { - "version": "0.4.2", + "version": "0.6.0", "bundled": true, "dev": true, "optional": true }, - "delayed-stream": { + "delegates": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, - "delegates": { - "version": "1.0.0", + "detect-libc": { + "version": "1.0.3", "bundled": true, "dev": true, "optional": true }, - "ecc-jsbn": { - "version": "0.1.1", + "fs-minipass": { + "version": "1.2.5", "bundled": true, "dev": true, "optional": true, "requires": { - "jsbn": "~0.1.0" + "minipass": "^2.2.1" } }, - "extend": { - "version": "3.0.1", + "fs.realpath": { + "version": "1.0.0", "bundled": true, "dev": true, "optional": true }, - "extsprintf": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true, - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fstream": "^1.0.0", - "inherits": "2", - "minimatch": "^3.0.0" - } - }, - "gauge": { - "version": "2.7.4", + "gauge": { + "version": "2.7.4", "bundled": true, "dev": true, "optional": true, @@ -3612,27 +3735,11 @@ "wide-align": "^1.1.0" } }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, "glob": { - "version": "7.1.2", + "version": "7.1.3", "bundled": true, "dev": true, + "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -3642,65 +3749,35 @@ "path-is-absolute": "^1.0.0" } }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true, - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ajv": "^4.9.1", - "har-schema": "^1.0.5" - } - }, "has-unicode": { "version": "2.0.1", "bundled": true, "dev": true, "optional": true }, - "hawk": { - "version": "3.1.3", + "iconv-lite": { + "version": "0.4.24", "bundled": true, "dev": true, "optional": true, "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" + "safer-buffer": ">= 2.1.2 < 3" } }, - "hoek": { - "version": "2.16.3", - "bundled": true, - "dev": true - }, - "http-signature": { - "version": "1.1.1", + "ignore-walk": { + "version": "3.0.1", "bundled": true, "dev": true, "optional": true, "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "minimatch": "^3.0.4" } }, "inflight": { "version": "1.0.6", "bundled": true, "dev": true, + "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -3712,7 +3789,7 @@ "dev": true }, "ini": { - "version": "1.3.4", + "version": "1.3.5", "bundled": true, "dev": true, "optional": true @@ -3725,111 +3802,43 @@ "number-is-nan": "^1.0.0" } }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, "isarray": { "version": "1.0.0", "bundled": true, - "dev": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true, "dev": true, "optional": true }, - "jodid25519": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "~0.1.0" - } - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", + "minimatch": { + "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } + "brace-expansion": "^1.1.7" } }, - "mime-db": { - "version": "1.27.0", + "minimist": { + "version": "0.0.8", "bundled": true, "dev": true }, - "mime-types": { - "version": "2.1.15", + "minipass": { + "version": "2.3.5", "bundled": true, "dev": true, "requires": { - "mime-db": "~1.27.0" + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" } }, - "minimatch": { - "version": "3.0.4", + "minizlib": { + "version": "1.2.1", "bundled": true, "dev": true, + "optional": true, "requires": { - "brace-expansion": "^1.1.7" + "minipass": "^2.2.1" } }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, "mkdirp": { "version": "0.5.1", "bundled": true, @@ -3844,21 +3853,33 @@ "dev": true, "optional": true }, + "needle": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, "node-pre-gyp": { - "version": "0.6.36", + "version": "0.10.3", "bundled": true, "dev": true, "optional": true, "requires": { + "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", + "needle": "^2.2.1", "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", "npmlog": "^4.0.2", - "rc": "^1.1.7", - "request": "^2.81.0", + "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", - "tar": "^2.2.1", - "tar-pack": "^3.4.0" + "tar": "^4" } }, "nopt": { @@ -3871,8 +3892,24 @@ "osenv": "^0.1.4" } }, + "npm-bundled": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, "npmlog": { - "version": "4.1.0", + "version": "4.1.2", "bundled": true, "dev": true, "optional": true, @@ -3888,12 +3925,6 @@ "bundled": true, "dev": true }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true, - "dev": true, - "optional": true - }, "object-assign": { "version": "4.1.1", "bundled": true, @@ -3921,7 +3952,7 @@ "optional": true }, "osenv": { - "version": "0.1.4", + "version": "0.1.5", "bundled": true, "dev": true, "optional": true, @@ -3933,38 +3964,22 @@ "path-is-absolute": { "version": "1.0.1", "bundled": true, - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true, "dev": true, "optional": true }, "process-nextick-args": { - "version": "1.0.7", - "bundled": true, - "dev": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", + "version": "2.0.0", "bundled": true, "dev": true, "optional": true }, "rc": { - "version": "1.2.1", + "version": "1.2.8", "bundled": true, "dev": true, "optional": true, "requires": { - "deep-extend": "~0.4.0", + "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" @@ -3979,113 +3994,63 @@ } }, "readable-stream": { - "version": "2.2.9", + "version": "2.3.6", "bundled": true, "dev": true, + "optional": true, "requires": { - "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "inherits": "~2.0.3", "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, - "request": { - "version": "2.81.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~4.2.1", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "performance-now": "^0.2.0", - "qs": "~6.4.0", - "safe-buffer": "^5.0.1", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.0.0" - } - }, "rimraf": { - "version": "2.6.1", + "version": "2.6.3", "bundled": true, "dev": true, + "optional": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { - "version": "5.0.1", + "version": "5.1.2", "bundled": true, "dev": true }, - "semver": { - "version": "5.3.0", + "safer-buffer": { + "version": "2.1.2", "bundled": true, "dev": true, "optional": true }, - "set-blocking": { - "version": "2.0.0", + "sax": { + "version": "1.2.4", "bundled": true, "dev": true, "optional": true }, - "signal-exit": { - "version": "3.0.2", + "semver": { + "version": "5.6.0", "bundled": true, "dev": true, "optional": true }, - "sntp": { - "version": "1.0.9", + "set-blocking": { + "version": "2.0.0", "bundled": true, "dev": true, - "optional": true, - "requires": { - "hoek": "2.x.x" - } + "optional": true }, - "sshpk": { - "version": "1.13.0", + "signal-exit": { + "version": "3.0.2", "bundled": true, "dev": true, - "optional": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jodid25519": "^1.0.0", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } + "optional": true }, "string-width": { "version": "1.0.2", @@ -4098,19 +4063,14 @@ } }, "string_decoder": { - "version": "1.0.1", + "version": "1.1.1", "bundled": true, "dev": true, + "optional": true, "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "~5.1.0" } }, - "stringstream": { - "version": "0.0.5", - "bundled": true, - "dev": true, - "optional": true - }, "strip-ansi": { "version": "3.0.1", "bundled": true, @@ -4126,94 +4086,44 @@ "optional": true }, "tar": { - "version": "2.2.1", - "bundled": true, - "dev": true, - "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" - } - }, - "tar-pack": { - "version": "3.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "^2.2.0", - "fstream": "^1.0.10", - "fstream-ignore": "^1.0.5", - "once": "^1.3.3", - "readable-stream": "^2.1.4", - "rimraf": "^2.5.1", - "tar": "^2.2.1", - "uid-number": "^0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.2", + "version": "4.4.8", "bundled": true, "dev": true, "optional": true, "requires": { - "punycode": "^1.4.1" + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" } }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true, - "dev": true, - "optional": true - }, "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true - }, - "uuid": { - "version": "3.0.1", - "bundled": true, "dev": true, "optional": true }, - "verror": { - "version": "1.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, "wide-align": { - "version": "1.1.2", + "version": "1.1.3", "bundled": true, "dev": true, "optional": true, "requires": { - "string-width": "^1.0.2" + "string-width": "^1.0.2 || 2" } }, "wrappy": { "version": "1.0.2", "bundled": true, "dev": true + }, + "yallist": { + "version": "3.0.3", + "bundled": true, + "dev": true } } }, @@ -4247,6 +4157,12 @@ "is-property": "^1.0.0" } }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -4284,23 +4200,25 @@ "path-is-absolute": "^1.0.0" } }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - } - }, "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, "requires": { - "is-glob": "^2.0.0" + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + } } }, "glob-stream": { @@ -4515,9 +4433,9 @@ "dev": true }, "growl": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, "gulp": { @@ -4620,17 +4538,98 @@ } }, "gulp-mocha": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/gulp-mocha/-/gulp-mocha-3.0.1.tgz", - "integrity": "sha1-qwyiw5QDcYF03drXUOY6Yb4X4EE=", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gulp-mocha/-/gulp-mocha-6.0.0.tgz", + "integrity": "sha512-FfBldW5ttnDpKf4Sg6/BLOOKCCbr5mbixDGK1t02/8oSrTCwNhgN/mdszG3cuQuYNzuouUdw4EH/mlYtgUscPg==", "dev": true, "requires": { - "gulp-util": "^3.0.0", - "mocha": "^3.0.0", - "plur": "^2.1.0", - "req-cwd": "^1.0.1", - "temp": "^0.8.3", - "through": "^2.3.4" + "dargs": "^5.1.0", + "execa": "^0.10.0", + "mocha": "^5.2.0", + "npm-run-path": "^2.0.2", + "plugin-error": "^1.0.1", + "supports-color": "^5.4.0", + "through2": "^2.0.3" + }, + "dependencies": { + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "gulp-rename": { @@ -4790,19 +4789,19 @@ "ansi-regex": "^2.0.0" } }, - "has-binary": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "integrity": "sha1-aOYesWIQyVRaClzOBqhzkS/h5ow=", + "has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", "dev": true, "requires": { - "isarray": "0.0.1" + "isarray": "2.0.1" }, "dependencies": { "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", "dev": true } } @@ -4973,42 +4972,33 @@ "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", "dev": true }, - "http-browserify": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/http-browserify/-/http-browserify-1.7.0.tgz", - "integrity": "sha1-M3la3nLfiKz7/TZ3PO/tp2RzWyA=", - "dev": true, - "requires": { - "Base64": "~0.2.0", - "inherits": "~2.0.1" - } - }, "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "dev": true, "requires": { - "depd": "1.1.1", + "depd": "~1.1.2", "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": ">= 1.3.1 < 2" + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" } }, "http-proxy": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.16.2.tgz", - "integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.17.0.tgz", + "integrity": "sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g==", "dev": true, "requires": { - "eventemitter3": "1.x.x", - "requires-port": "1.x.x" + "eventemitter3": "^3.0.0", + "follow-redirects": "^1.0.0", + "requires-port": "^1.0.0" }, "dependencies": { "eventemitter3": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", - "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", + "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", "dev": true } } @@ -5030,11 +5020,41 @@ "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", "dev": true }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "dev": true, + "requires": { + "agent-base": "^4.1.0", + "debug": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } }, "ieee754": { "version": "1.1.8", @@ -5143,12 +5163,6 @@ "loose-envify": "^1.0.0" } }, - "irregular-plurals": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.3.0.tgz", - "integrity": "sha512-njf5A+Mxb3kojuHd1DzISjjIl+XhyzovXEOyPPSzdQozq/Lf2tN27mOrAAsxEPZxpn6I4MGzs1oo9TxXxPFpaA==", - "dev": true - }, "is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", @@ -5211,21 +5225,6 @@ } } }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "^2.0.0" - } - }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -5233,9 +5232,9 @@ "dev": true }, "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, "is-finite": { @@ -5257,12 +5256,12 @@ } }, "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", "dev": true, "requires": { - "is-extglob": "^1.0.0" + "is-extglob": "^2.1.1" } }, "is-my-json-valid": { @@ -5278,9 +5277,9 @@ } }, "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -5344,18 +5343,6 @@ } } }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, "is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", @@ -5380,6 +5367,12 @@ "tryit": "^1.0.1" } }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -5414,10 +5407,13 @@ "dev": true }, "isbinaryfile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", - "dev": true + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.3.tgz", + "integrity": "sha512-8cJBL5tTd2OS0dM4jz07wQd5g0dCCqIhUxPIGtZfa5L6hWlvV5MHTITy/DBAsF+Oe2LS1X3krBUhNwaGUWpWxw==", + "dev": true, + "requires": { + "buffer-alloc": "^1.2.0" + } }, "isexe": { "version": "2.0.0", @@ -5426,13 +5422,10 @@ "dev": true }, "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true }, "isstream": { "version": "0.1.2", @@ -5518,8 +5511,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true + "dev": true }, "jsesc": { "version": "0.5.0", @@ -5548,12 +5540,6 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "json3": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", - "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", - "dev": true - }, "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", @@ -5566,512 +5552,102 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - } - } - }, - "karma": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz", - "integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==", - "dev": true, - "requires": { - "bluebird": "^3.3.0", - "body-parser": "^1.16.1", - "chokidar": "^1.4.1", - "colors": "^1.1.0", - "combine-lists": "^1.0.0", - "connect": "^3.6.0", - "core-js": "^2.2.0", - "di": "^0.0.1", - "dom-serialize": "^2.2.0", - "expand-braces": "^0.1.1", - "glob": "^7.1.1", - "graceful-fs": "^4.1.2", - "http-proxy": "^1.13.0", - "isbinaryfile": "^3.0.0", - "lodash": "^3.8.0", - "log4js": "^0.6.31", - "mime": "^1.3.4", - "minimatch": "^3.0.2", - "optimist": "^0.6.1", - "qjobs": "^1.1.4", - "range-parser": "^1.2.0", - "rimraf": "^2.6.0", - "safe-buffer": "^5.0.1", - "socket.io": "1.7.3", - "source-map": "^0.5.3", - "tmp": "0.0.31", - "useragent": "^2.1.12" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - } - } - }, - "karma-browserify": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-4.4.2.tgz", - "integrity": "sha1-QS7h/GMy7SSJ2Ax5l8qjzms61GE=", - "dev": true, - "requires": { - "browserify": "10.2.3", - "convert-source-map": "~0.3.3", - "hat": "0.0.3", - "js-string-escape": "^1.0.0", - "lodash": "^3.10.1", - "minimatch": "^1.0.0", - "os-shim": "~0.1.2", - "watchify": "3.2.1" - }, - "dependencies": { - "assert": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.3.0.tgz", - "integrity": "sha1-A5OaYiWCqBLMICMgoLmlbJuBWEk=", - "dev": true, - "requires": { - "util": "0.10.3" - } - }, - "base64-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", - "integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=", - "dev": true - }, - "browser-pack": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz", - "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "~0.6.1", - "defined": "^1.0.0", - "through2": "^1.0.0", - "umd": "^3.0.0" - } - }, - "browserify": { - "version": "10.2.3", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-10.2.3.tgz", - "integrity": "sha1-9qGNTWqzERP5/fg/ED+gFyioIGo=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "assert": "~1.3.0", - "browser-pack": "^5.0.0", - "browser-resolve": "^1.7.1", - "browserify-zlib": "~0.1.2", - "buffer": "^3.0.0", - "builtins": "~0.0.3", - "commondir": "0.0.1", - "concat-stream": "~1.4.1", - "console-browserify": "^1.1.0", - "constants-browserify": "~0.0.1", - "crypto-browserify": "^3.0.0", - "deep-equal": "^1.0.0", - "defined": "^1.0.0", - "deps-sort": "^1.3.7", - "domain-browser": "~1.1.0", - "duplexer2": "~0.0.2", - "events": "~1.0.0", - "glob": "^4.0.5", - "has": "^1.0.0", - "htmlescape": "^1.1.0", - "http-browserify": "^1.4.0", - "https-browserify": "~0.0.0", - "inherits": "~2.0.1", - "insert-module-globals": "^6.4.1", - "isarray": "0.0.1", - "labeled-stream-splicer": "^1.0.0", - "module-deps": "^3.7.11", - "os-browserify": "~0.1.1", - "parents": "^1.0.1", - "path-browserify": "~0.0.0", - "process": "~0.11.0", - "punycode": "^1.3.2", - "querystring-es3": "~0.2.0", - "read-only-stream": "^1.1.1", - "readable-stream": "^1.1.13", - "resolve": "^1.1.4", - "shasum": "^1.0.0", - "shell-quote": "~0.0.1", - "stream-browserify": "^1.0.0", - "string_decoder": "~0.10.0", - "subarg": "^1.0.0", - "syntax-error": "^1.1.1", - "through2": "^1.0.0", - "timers-browserify": "^1.0.1", - "tty-browserify": "~0.0.0", - "url": "~0.10.1", - "util": "~0.10.1", - "vm-browserify": "~0.0.1", - "xtend": "^4.0.0" - } - }, - "buffer": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", - "integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=", - "dev": true, - "requires": { - "base64-js": "0.0.8", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - } - } - }, - "combine-source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz", - "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", - "dev": true, - "requires": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.5.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.4.2" - }, - "dependencies": { - "convert-source-map": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", - "dev": true - } - } - }, - "concat-stream": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.10.tgz", - "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", - "dev": true, - "requires": { - "inherits": "~2.0.1", - "readable-stream": "~1.1.9", - "typedarray": "~0.0.5" - } - }, - "constants-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-0.0.1.tgz", - "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", - "dev": true - }, - "convert-source-map": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-0.3.5.tgz", - "integrity": "sha1-8dgClQr33SYxof6+BZZVDIarMZA=", - "dev": true - }, - "deps-sort": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-1.3.9.tgz", - "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "shasum": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^1.0.0" - } - }, - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - } - }, - "events": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/events/-/events-1.0.2.tgz", - "integrity": "sha1-dYSdz+k9EPsFfDAFWv29UdBqjiQ=", - "dev": true - }, - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - }, - "dependencies": { - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "^1.0.0" - } - } - } - }, - "inline-source-map": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz", - "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", - "dev": true, - "requires": { - "source-map": "~0.4.0" - } - }, - "insert-module-globals": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-6.6.3.tgz", - "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "~0.6.1", - "concat-stream": "~1.4.1", - "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", - "process": "~0.11.0", - "through2": "^1.0.0", - "xtend": "^4.0.0" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "labeled-stream-splicer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz", - "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "isarray": "~0.0.1", - "stream-splicer": "^1.1.0" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "minimatch": { + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", - "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=", - "dev": true, - "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" - } - }, - "module-deps": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-3.9.1.tgz", - "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "browser-resolve": "^1.7.0", - "concat-stream": "~1.4.5", - "defined": "^1.0.0", - "detective": "^4.0.0", - "duplexer2": "0.0.2", - "inherits": "^2.0.1", - "parents": "^1.0.0", - "readable-stream": "^1.1.13", - "resolve": "^1.1.3", - "stream-combiner2": "~1.0.0", - "subarg": "^1.0.0", - "through2": "^1.0.0", - "xtend": "^4.0.0" - } - }, - "read-only-stream": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-1.1.1.tgz", - "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", - "dev": true, - "requires": { - "readable-stream": "^1.0.31", - "readable-wrap": "^1.0.0" - } - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "shell-quote": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-0.0.1.tgz", - "integrity": "sha1-GkEZbzwDM8SCMjWT1ohuzxU92YY=", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + } + } + }, + "karma": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/karma/-/karma-4.0.0.tgz", + "integrity": "sha512-EFoFs3F6G0BcUGPNOn/YloGOb3h09hzTguyXlg6loHlKY76qbJikkcyPk43m2kfRF65TUGda/mig29QQtyhm1g==", + "dev": true, + "requires": { + "bluebird": "^3.3.0", + "body-parser": "^1.16.1", + "chokidar": "^2.0.3", + "colors": "^1.1.0", + "combine-lists": "^1.0.0", + "connect": "^3.6.0", + "core-js": "^2.2.0", + "di": "^0.0.1", + "dom-serialize": "^2.2.0", + "expand-braces": "^0.1.1", + "flatted": "^2.0.0", + "glob": "^7.1.1", + "graceful-fs": "^4.1.2", + "http-proxy": "^1.13.0", + "isbinaryfile": "^3.0.0", + "lodash": "^4.17.5", + "log4js": "^3.0.0", + "mime": "^2.3.1", + "minimatch": "^3.0.2", + "optimist": "^0.6.1", + "qjobs": "^1.1.4", + "range-parser": "^1.2.0", + "rimraf": "^2.6.0", + "safe-buffer": "^5.0.1", + "socket.io": "2.1.1", + "source-map": "^0.6.1", + "tmp": "0.0.33", + "useragent": "2.3.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } - }, - "stream-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-1.0.0.tgz", - "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", - "dev": true, - "requires": { - "inherits": "~2.0.1", - "readable-stream": "^1.0.27-1" - } - }, - "stream-combiner2": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.0.2.tgz", - "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", - "dev": true, - "requires": { - "duplexer2": "~0.0.2", - "through2": "~0.5.1" - }, - "dependencies": { - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "through2": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", - "dev": true, - "requires": { - "readable-stream": "~1.0.17", - "xtend": "~3.0.0" - } - }, - "xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", - "dev": true - } - } - }, - "stream-splicer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz", - "integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=", - "dev": true, - "requires": { - "indexof": "0.0.1", - "inherits": "^2.0.1", - "isarray": "~0.0.1", - "readable-stream": "^1.1.13-1", - "readable-wrap": "^1.0.0", - "through2": "^1.0.0" - } - }, - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - }, - "url": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", - "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", - "dev": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true } } }, + "karma-browserify": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-6.0.0.tgz", + "integrity": "sha512-G3dGjoy1/6P8I6qTp799fbcAxs4P+1JcyEKUzy9g1/xMakqf9FFPwW2T9iEtCbWoH5WIKD3z+YwGL5ysBhzrsg==", + "dev": true, + "requires": { + "convert-source-map": "^1.1.3", + "hat": "^0.0.3", + "js-string-escape": "^1.0.0", + "lodash": "^4.17.10", + "minimatch": "^3.0.0", + "os-shim": "^0.1.3" + } + }, "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", @@ -6188,33 +5764,17 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true, - "requires": { - "lodash._basecopy": "^3.0.0", - "lodash.keys": "^3.0.0" - } - }, "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "dev": true }, - "lodash._basecreate": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", - "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", - "dev": true - }, "lodash._basetostring": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", @@ -6263,16 +5823,11 @@ "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", "dev": true }, - "lodash.create": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", - "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", - "dev": true, - "requires": { - "lodash._baseassign": "^3.0.0", - "lodash._basecreate": "^3.0.0", - "lodash._isiterateecall": "^3.0.0" - } + "lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", + "dev": true }, "lodash.escape": { "version": "3.2.0", @@ -6352,32 +5907,38 @@ "dev": true }, "log4js": { - "version": "0.6.38", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", - "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-3.0.6.tgz", + "integrity": "sha512-ezXZk6oPJCWL483zj64pNkMuY/NcRX5MPiB0zE6tjZM137aeusrOnW1ecxgF9cmwMWkBMhjteQxBPoZBh9FDxQ==", "dev": true, "requires": { - "readable-stream": "~1.0.2", - "semver": "~4.3.3" + "circular-json": "^0.5.5", + "date-format": "^1.2.0", + "debug": "^3.1.0", + "rfdc": "^1.1.2", + "streamroller": "0.7.0" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "circular-json": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz", + "integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ==", "dev": true }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, @@ -6484,24 +6045,32 @@ "dev": true }, "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } } }, "miller-rabin": { @@ -6515,9 +6084,9 @@ } }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", + "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", "dev": true }, "mime-db": { @@ -6601,55 +6170,52 @@ } }, "mocha": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", - "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { - "browser-stdout": "1.3.0", - "commander": "2.9.0", - "debug": "2.6.8", - "diff": "3.2.0", + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", "escape-string-regexp": "1.0.5", - "glob": "7.1.1", - "growl": "1.9.2", + "glob": "7.1.2", + "growl": "1.10.5", "he": "1.1.1", - "json3": "3.3.2", - "lodash.create": "3.1.1", + "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "3.1.2" + "supports-color": "5.4.0" }, "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, "debug": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { "ms": "2.0.0" } }, - "glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.2", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true }, "supports-color": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", - "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^1.0.0" + "has-flag": "^3.0.0" } } } @@ -6737,9 +6303,9 @@ "dev": true }, "nan": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", - "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", + "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", "dev": true, "optional": true }, @@ -6806,6 +6372,12 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, "node-uuid": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", @@ -6830,6 +6402,15 @@ "remove-trailing-separator": "^1.0.1" } }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, "null-check": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", @@ -6949,16 +6530,6 @@ } } }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -7038,12 +6609,6 @@ "wordwrap": "~1.0.0" } }, - "options": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", - "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", - "dev": true - }, "orchestrator": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", @@ -7085,14 +6650,11 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, - "outpipe": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", - "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", - "dev": true, - "requires": { - "shell-quote": "^1.4.2" - } + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true }, "pako": { "version": "0.2.9", @@ -7133,33 +6695,12 @@ "path-root": "^0.1.1" } }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - } - }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, - "parsejson": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz", - "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=", - "dev": true, - "requires": { - "better-assert": "~1.0.0" - } - }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -7196,6 +6737,12 @@ "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", "dev": true }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -7208,6 +6755,12 @@ "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", @@ -7248,6 +6801,12 @@ "sha.js": "^2.4.8" } }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -7269,13 +6828,16 @@ "pinkie": "^2.0.0" } }, - "plur": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", - "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", "dev": true, "requires": { - "irregular-plurals": "^1.0.0" + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" } }, "pluralize": { @@ -7296,12 +6858,6 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", @@ -7332,6 +6888,18 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, "public-encrypt": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", @@ -7351,10 +6919,58 @@ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true }, + "puppeteer": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.12.1.tgz", + "integrity": "sha512-FlMLdgAnURMMtwb2S6XtkBRw+kh1V+gGt09pCJF9mB1eOnF9+JhtvTxFeu1Rm5X1pKMXq5xrosrhBTgmdwzPeA==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^2.2.1", + "mime": "^2.0.3", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "ws": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.3.tgz", + "integrity": "sha512-tbSxiT+qJI223AP4iLfQbkbxkwdFcneYinM2+x46Gx2wgvbaOMO36czfdfVUBRTHvzAMRhDd98sA5d/BuWbQdg==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, "qjobs": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.1.5.tgz", - "integrity": "sha1-ZZ3p8s+NzCehSBJ28gU3cnI4LnM=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", + "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", "dev": true }, "qs": { @@ -7375,47 +6991,6 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, - "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "randombytes": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", @@ -7432,14 +7007,14 @@ "dev": true }, "raw-body": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", - "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", "dev": true, "requires": { "bytes": "3.0.0", - "http-errors": "1.6.2", - "iconv-lite": "0.4.19", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", "unpipe": "1.0.0" } }, @@ -7478,51 +7053,21 @@ } } }, - "readable-wrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/readable-wrap/-/readable-wrap-1.0.0.tgz", - "integrity": "sha1-O1ohHGMeEjA6VJkcgGwX564ga/8=", - "dev": true, - "requires": { - "readable-stream": "^1.1.13-1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - } - } - }, "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" }, "dependencies": { "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true } } @@ -7570,15 +7115,6 @@ "private": "^0.1.6" } }, - "regex-cache": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", - "dev": true, - "requires": { - "is-equal-shallow": "^0.1.3" - } - }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -7648,32 +7184,6 @@ "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", "dev": true }, - "req-cwd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/req-cwd/-/req-cwd-1.0.1.tgz", - "integrity": "sha1-DXOurpJm5penj3l2AZZ352rPD/8=", - "dev": true, - "requires": { - "req-from": "^1.0.1" - } - }, - "req-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/req-from/-/req-from-1.0.1.tgz", - "integrity": "sha1-v4HaUUeUfTLRO5R9wSpYrUWHNQ4=", - "dev": true, - "requires": { - "resolve-from": "^2.0.0" - }, - "dependencies": { - "resolve-from": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", - "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=", - "dev": true - } - } - }, "request": { "version": "2.74.0", "resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", @@ -7772,6 +7282,12 @@ "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, + "rfdc": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.2.tgz", + "integrity": "sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA==", + "dev": true + }, "right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", @@ -7830,6 +7346,12 @@ "ret": "~0.1.10" } }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, "samsam": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", @@ -7848,12 +7370,6 @@ "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", "dev": true }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", @@ -7878,9 +7394,9 @@ } }, "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", "dev": true }, "sha.js": { @@ -7903,6 +7419,21 @@ "sha.js": "~2.4.4" } }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, "shell-quote": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", @@ -7932,6 +7463,12 @@ "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", "dev": true }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, "sinon": { "version": "1.17.7", "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", @@ -8099,143 +7636,93 @@ } }, "socket.io": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-1.7.3.tgz", - "integrity": "sha1-uK+cq6AJSeVo42nxMn6pvp6iRhs=", - "dev": true, - "requires": { - "debug": "2.3.3", - "engine.io": "1.8.3", - "has-binary": "0.1.7", - "object-assign": "4.1.0", - "socket.io-adapter": "0.5.0", - "socket.io-client": "1.7.3", - "socket.io-parser": "2.3.1" - }, - "dependencies": { - "debug": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "0.7.2" - } - }, - "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true - }, - "object-assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=", - "dev": true - } - } - }, - "socket.io-adapter": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz", - "integrity": "sha1-y21LuL7IHhB4uZZ3+c7QBGBmu4s=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", + "integrity": "sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA==", "dev": true, "requires": { - "debug": "2.3.3", - "socket.io-parser": "2.3.1" + "debug": "~3.1.0", + "engine.io": "~3.2.0", + "has-binary2": "~1.0.2", + "socket.io-adapter": "~1.1.0", + "socket.io-client": "2.1.1", + "socket.io-parser": "~3.2.0" }, "dependencies": { "debug": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "0.7.2" + "ms": "2.0.0" } - }, - "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true } } }, + "socket.io-adapter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", + "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=", + "dev": true + }, "socket.io-client": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-1.7.3.tgz", - "integrity": "sha1-sw6GqhDV7zVGYBwJzeR2Xjgdo3c=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.1.1.tgz", + "integrity": "sha512-jxnFyhAuFxYfjqIgduQlhzqTcOEQSn+OHKVfAxWaNWa7ecP7xSNk2Dx/3UEsDcY7NcFafxvNvKPmmO7HTwTxGQ==", "dev": true, "requires": { "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", "component-bind": "1.0.0", "component-emitter": "1.2.1", - "debug": "2.3.3", - "engine.io-client": "1.8.3", - "has-binary": "0.1.7", + "debug": "~3.1.0", + "engine.io-client": "~3.2.0", + "has-binary2": "~1.0.2", + "has-cors": "1.1.0", "indexof": "0.0.1", "object-component": "0.0.3", + "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "2.3.1", + "socket.io-parser": "~3.2.0", "to-array": "0.1.4" }, "dependencies": { - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, "debug": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "0.7.2" + "ms": "2.0.0" } - }, - "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true } } }, "socket.io-parser": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz", - "integrity": "sha1-3VMgJRA85Clpcya+/WQAX8/ltKA=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", + "integrity": "sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA==", "dev": true, "requires": { - "component-emitter": "1.1.2", - "debug": "2.2.0", - "isarray": "0.0.1", - "json3": "3.3.2" + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "isarray": "2.0.1" }, "dependencies": { "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "0.7.1" + "ms": "2.0.0" } }, "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", "dev": true } } @@ -8247,15 +7734,16 @@ "dev": true }, "source-map-resolve": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", - "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, "requires": { - "atob": "~1.1.0", - "resolve-url": "~0.2.1", - "source-map-url": "~0.3.0", - "urix": "~0.1.0" + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-support": { @@ -8268,9 +7756,9 @@ } }, "source-map-url": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", - "integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, "sparkles": { @@ -8295,9 +7783,9 @@ "dev": true }, "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "dev": true, "requires": { "asn1": "~0.2.3", @@ -8307,6 +7795,7 @@ "ecc-jsbn": "~0.1.1", "getpass": "^0.1.1", "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" }, "dependencies": { @@ -8340,9 +7829,9 @@ } }, "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", "dev": true }, "stream-browserify": { @@ -8394,6 +7883,35 @@ "readable-stream": "^2.0.2" } }, + "streamroller": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-0.7.0.tgz", + "integrity": "sha512-WREzfy0r0zUqp3lGO096wRuUp7ho1X6uo/7DJfTlEi0Iv/4gT7YHqXDjKC2ioVGBZtE8QzsQD9nx1nIuoZ57jQ==", + "dev": true, + "requires": { + "date-format": "^1.2.0", + "debug": "^3.1.0", + "mkdirp": "^0.5.1", + "readable-stream": "^2.3.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -8412,9 +7930,9 @@ "dev": true }, "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", + "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", "dev": true }, "strip-ansi": { @@ -8436,6 +7954,12 @@ "is-utf8": "^0.2.0" } }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -8513,24 +8037,6 @@ } } }, - "temp": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", - "dev": true, - "requires": { - "os-tmpdir": "^1.0.0", - "rimraf": "~2.2.6" - }, - "dependencies": { - "rimraf": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", - "dev": true - } - } - }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -8578,12 +8084,12 @@ } }, "tmp": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", - "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { - "os-tmpdir": "~1.0.1" + "os-tmpdir": "~1.0.2" } }, "to-array": { @@ -8683,8 +8189,7 @@ "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true + "dev": true }, "type-check": { "version": "0.3.2", @@ -8696,13 +8201,30 @@ } }, "type-is": { - "version": "1.6.15", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", - "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.15" + "mime-types": "~2.1.18" + }, + "dependencies": { + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "dev": true + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "dev": true, + "requires": { + "mime-db": "~1.37.0" + } + } } }, "typedarray": { @@ -8736,9 +8258,9 @@ "optional": true }, "ultron": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", - "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, "umd": { @@ -8846,6 +8368,12 @@ } } }, + "upath": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", + "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", + "dev": true + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -8894,20 +8422,24 @@ "dev": true }, "useragent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.2.1.tgz", - "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", + "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", "dev": true, "requires": { - "lru-cache": "2.2.x", + "lru-cache": "4.1.x", "tmp": "0.0.x" }, "dependencies": { "lru-cache": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", - "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=", - "dev": true + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } } } }, @@ -9121,482 +8653,6 @@ "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", "dev": true }, - "watchify": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.2.1.tgz", - "integrity": "sha1-Gbz9e/y/Qdf0/jwpdAvORfdk4gM=", - "dev": true, - "requires": { - "browserify": "^10.0.0", - "chokidar": "^1.0.0", - "defined": "^1.0.0", - "outpipe": "^1.1.0", - "through2": "~0.6.3", - "xtend": "^4.0.0" - }, - "dependencies": { - "assert": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.3.0.tgz", - "integrity": "sha1-A5OaYiWCqBLMICMgoLmlbJuBWEk=", - "dev": true, - "requires": { - "util": "0.10.3" - } - }, - "base64-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", - "integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=", - "dev": true - }, - "browser-pack": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz", - "integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "~0.6.1", - "defined": "^1.0.0", - "through2": "^1.0.0", - "umd": "^3.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "browserify": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-10.2.6.tgz", - "integrity": "sha1-3L/veU9Uj1+EmCFIFPaXpcUMCJY=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "assert": "~1.3.0", - "browser-pack": "^5.0.0", - "browser-resolve": "^1.7.1", - "browserify-zlib": "~0.1.2", - "buffer": "^3.0.0", - "builtins": "~0.0.3", - "commondir": "0.0.1", - "concat-stream": "~1.4.1", - "console-browserify": "^1.1.0", - "constants-browserify": "~0.0.1", - "crypto-browserify": "^3.0.0", - "defined": "^1.0.0", - "deps-sort": "^1.3.7", - "domain-browser": "~1.1.0", - "duplexer2": "~0.0.2", - "events": "~1.0.0", - "glob": "^4.0.5", - "has": "^1.0.0", - "htmlescape": "^1.1.0", - "http-browserify": "^1.4.0", - "https-browserify": "~0.0.0", - "inherits": "~2.0.1", - "insert-module-globals": "^6.4.1", - "isarray": "0.0.1", - "labeled-stream-splicer": "^1.0.0", - "module-deps": "^3.7.11", - "os-browserify": "~0.1.1", - "parents": "^1.0.1", - "path-browserify": "~0.0.0", - "process": "~0.11.0", - "punycode": "^1.3.2", - "querystring-es3": "~0.2.0", - "read-only-stream": "^1.1.1", - "readable-stream": "^1.1.13", - "resolve": "^1.1.4", - "shasum": "^1.0.0", - "shell-quote": "~0.0.1", - "stream-browserify": "^1.0.0", - "string_decoder": "~0.10.0", - "subarg": "^1.0.0", - "syntax-error": "^1.1.1", - "through2": "^1.0.0", - "timers-browserify": "^1.0.1", - "tty-browserify": "~0.0.0", - "url": "~0.10.1", - "util": "~0.10.1", - "vm-browserify": "~0.0.1", - "xtend": "^4.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "buffer": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz", - "integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=", - "dev": true, - "requires": { - "base64-js": "0.0.8", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - } - } - }, - "combine-source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz", - "integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=", - "dev": true, - "requires": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.5.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.4.2" - } - }, - "concat-stream": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.10.tgz", - "integrity": "sha1-rMO79WAsuMyYDGrIQPp9hgPj7zY=", - "dev": true, - "requires": { - "inherits": "~2.0.1", - "readable-stream": "~1.1.9", - "typedarray": "~0.0.5" - } - }, - "constants-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-0.0.1.tgz", - "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", - "dev": true - }, - "deps-sort": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-1.3.9.tgz", - "integrity": "sha1-Kd//U+F7Nq7K51MK27v2IsLtGnE=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "shasum": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^1.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - } - }, - "events": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/events/-/events-1.0.2.tgz", - "integrity": "sha1-dYSdz+k9EPsFfDAFWv29UdBqjiQ=", - "dev": true - }, - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - } - }, - "inline-source-map": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz", - "integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=", - "dev": true, - "requires": { - "source-map": "~0.4.0" - } - }, - "insert-module-globals": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-6.6.3.tgz", - "integrity": "sha1-IGOOKaMPntHKLjqCX7wsulJG3fw=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "~0.6.1", - "concat-stream": "~1.4.1", - "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", - "process": "~0.11.0", - "through2": "^1.0.0", - "xtend": "^4.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "labeled-stream-splicer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz", - "integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "isarray": "~0.0.1", - "stream-splicer": "^1.1.0" - } - }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "^1.0.0" - } - }, - "module-deps": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-3.9.1.tgz", - "integrity": "sha1-6nXK+RmQkNJbDVUStaysuW5/h/M=", - "dev": true, - "requires": { - "JSONStream": "^1.0.3", - "browser-resolve": "^1.7.0", - "concat-stream": "~1.4.5", - "defined": "^1.0.0", - "detective": "^4.0.0", - "duplexer2": "0.0.2", - "inherits": "^2.0.1", - "parents": "^1.0.0", - "readable-stream": "^1.1.13", - "resolve": "^1.1.3", - "stream-combiner2": "~1.0.0", - "subarg": "^1.0.0", - "through2": "^1.0.0", - "xtend": "^4.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "read-only-stream": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-1.1.1.tgz", - "integrity": "sha1-Xad8eZ7ROI0++IoYRxu1kk+KC6E=", - "dev": true, - "requires": { - "readable-stream": "^1.0.31", - "readable-wrap": "^1.0.0" - } - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "shell-quote": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-0.0.1.tgz", - "integrity": "sha1-GkEZbzwDM8SCMjWT1ohuzxU92YY=", - "dev": true - }, - "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } - }, - "stream-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-1.0.0.tgz", - "integrity": "sha1-v5tKv7QrJ011FHnkTg/yZWtvEZM=", - "dev": true, - "requires": { - "inherits": "~2.0.1", - "readable-stream": "^1.0.27-1" - } - }, - "stream-combiner2": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.0.2.tgz", - "integrity": "sha1-unKmtQy/q/qVD8i8h2BL0B62BnE=", - "dev": true, - "requires": { - "duplexer2": "~0.0.2", - "through2": "~0.5.1" - }, - "dependencies": { - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "through2": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", - "dev": true, - "requires": { - "readable-stream": "~1.0.17", - "xtend": "~3.0.0" - } - }, - "xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", - "dev": true - } - } - }, - "stream-splicer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz", - "integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=", - "dev": true, - "requires": { - "indexof": "0.0.1", - "inherits": "^2.0.1", - "isarray": "~0.0.1", - "readable-stream": "^1.1.13-1", - "readable-wrap": "^1.0.0", - "through2": "^1.0.0" - }, - "dependencies": { - "through2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz", - "integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=", - "dev": true, - "requires": { - "readable-stream": ">=1.1.13-1 <1.2.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } - } - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - }, - "dependencies": { - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - } - } - }, - "url": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", - "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", - "dev": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } - } - } - }, "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", @@ -9634,25 +8690,20 @@ } }, "ws": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-1.1.2.tgz", - "integrity": "sha1-iiRPoFJAHgjJiGz0SoUYnh/UBn8=", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", "dev": true, "requires": { - "options": ">=0.0.5", - "ultron": "1.0.x" + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" } }, - "wtf-8": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wtf-8/-/wtf-8-1.0.0.tgz", - "integrity": "sha1-OS2LotDxw00e4tYw8V0O+2jhBIo=", - "dev": true - }, "xmlhttprequest-ssl": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", - "integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", + "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, "xtend": { @@ -9661,6 +8712,12 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", @@ -9673,6 +8730,15 @@ "window-size": "0.1.0" } }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "dev": true, + "requires": { + "fd-slicer": "~1.0.1" + } + }, "yeast": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", diff --git a/package.json b/package.json index b1325f64..e3c95467 100644 --- a/package.json +++ b/package.json @@ -49,19 +49,20 @@ "gulp-babel": "^6.1.2", "gulp-concat": "^2.5.2", "gulp-eslint": "^3.0.1", - "gulp-mocha": "^3.0.1", + "gulp-mocha": "^6.0.0", "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^2.0.0", "istanbul": "^0.4.0", - "karma": "^1.3.0", - "karma-browserify": "^4.3.0", + "karma": "^4.0.0", + "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.0.0", "karma-expect": "^1.1.0", "karma-firefox-launcher": "^1.0.0", "karma-mocha": "^1.3.0", - "mocha": "^3.1.2", + "mocha": "^5.2.0", "natives": "^1.1.6", + "puppeteer": "^1.12.1", "sinon": "^1.16.1", "through2": "^2.0.0", "vinyl-source-stream": "^1.1.0" From 095f3ec7b24369ed5c157a4f34b9ee684f8074cd Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:23:02 +0000 Subject: [PATCH 211/224] Update gulp --- gulpfile.js | 21 +- package-lock.json | 1749 ++++++++++++++++++++++++++++----------------- package.json | 2 +- 3 files changed, 1089 insertions(+), 683 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 95689c31..d85e05da 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -89,7 +89,7 @@ gulp.task('browser-slave-module', () => { }); -gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], () => { +gulp.task('browserify-lib', gulp.parallel(['babel-lib', 'browser-slave-module']), () => { return browserify({ standalone: 'threads' }) .add('./lib/index.js') @@ -101,38 +101,37 @@ gulp.task('browserify-lib', ['babel-lib', 'browser-slave-module'], () => { .pipe(gulp.dest('dist/')); }); -gulp.task('uglify-lib', ['browserify-lib'], () => { +gulp.task('uglify-lib', gulp.parallel(['browserify-lib']), () => { return gulp.src('dist/threads.browser.js') .pipe(uglify()) .pipe(concat('threads.browser.min.js')) .pipe(gulp.dest('dist/')); }); -gulp.task('uglify-slave', ['copy-slave'], () => { +gulp.task('uglify-slave', gulp.parallel(['copy-slave']), () => { return gulp.src('dist/slave.js') .pipe(uglify()) .pipe(concat('slave.min.js')) .pipe(gulp.dest('dist/')); }); -gulp.task('uglify', ['uglify-lib', 'uglify-slave']); +gulp.task('uglify', gulp.parallel(['uglify-lib', 'uglify-slave'])); +gulp.task('dist', gulp.parallel(['lint', gulp.series([ 'browserify-lib', 'uglify' ])])); -gulp.task('test-browser', ['dist', 'babel-spec'], done => { +gulp.task('test-browser', gulp.parallel(['dist', 'babel-spec']), done => { runKarma(done); }); -gulp.task('test-browser-after-node', ['test-node'], done => { +gulp.task('test-browser-after-node', done => { runKarma(done); }); -gulp.task('test-node', ['dist', 'babel-spec'], () => { +gulp.task('test-node', gulp.parallel(['dist', 'babel-spec']), () => { return gulp.src('test/spec-build/*.spec.js', { read: false }) .pipe(mocha({ exit: true })); }); +gulp.task('test', gulp.series(['test-node', 'test-browser-after-node'])); -gulp.task('dist', ['lint', 'browserify-lib', 'uglify']); -gulp.task('test', ['test-node', 'test-browser-after-node']); - -gulp.task('default', ['dist', 'test']); +gulp.task('default', gulp.series(['dist', 'test'])); diff --git a/package-lock.json b/package-lock.json index 4dc4682d..14836ec7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -154,6 +154,15 @@ "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", "dev": true }, + "ansi-gray": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", + "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -182,6 +191,15 @@ "normalize-path": "^2.1.1" } }, + "append-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", + "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", + "dev": true, + "requires": { + "buffer-equal": "^1.0.0" + } + }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", @@ -203,12 +221,30 @@ "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", "dev": true }, + "arr-filter": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz", + "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "dev": true, + "requires": { + "make-iterator": "^1.0.0" + } + }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, + "arr-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz", + "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "dev": true, + "requires": { + "make-iterator": "^1.0.0" + } + }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", @@ -233,6 +269,41 @@ "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", "dev": true }, + "array-initial": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", + "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "dev": true, + "requires": { + "array-slice": "^1.0.0", + "is-number": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, + "array-last": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array-last/-/array-last-1.3.0.tgz", + "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", + "dev": true, + "requires": { + "is-number": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, "array-map": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", @@ -251,6 +322,25 @@ "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", "dev": true }, + "array-sort": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-sort/-/array-sort-1.0.0.tgz", + "integrity": "sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg==", + "dev": true, + "requires": { + "default-compare": "^1.0.0", + "get-value": "^2.0.6", + "kind-of": "^5.0.2" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", @@ -340,6 +430,18 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, + "async-done": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.1.tgz", + "integrity": "sha512-R1BaUeJ4PMoLNJuk+0tLJgjmEqVsdN118+Z8O+alhnQDQgy0kmD5Mqi0DNEmMx2LM0Ed5yekKu+ZXYvIHceicg==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.2", + "process-nextick-args": "^1.0.7", + "stream-exhaust": "^1.0.1" + } + }, "async-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", @@ -352,6 +454,15 @@ "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", "dev": true }, + "async-settle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz", + "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "dev": true, + "requires": { + "async-done": "^1.2.2" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -942,6 +1053,23 @@ "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", "dev": true }, + "bach": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", + "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "dev": true, + "requires": { + "arr-filter": "^1.1.1", + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "array-each": "^1.0.0", + "array-initial": "^1.0.0", + "array-last": "^1.1.1", + "async-done": "^1.2.2", + "async-settle": "^1.0.0", + "now-and-later": "^2.0.0" + } + }, "backo2": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", @@ -1386,6 +1514,12 @@ "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", "dev": true }, + "buffer-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", + "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", + "dev": true + }, "buffer-fill": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", @@ -1413,6 +1547,12 @@ "readable-stream": "^2.0.2" } }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -1671,6 +1811,17 @@ "request": "~2.74.0" } }, + "collection-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", + "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "dev": true, + "requires": { + "arr-map": "^2.0.2", + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", @@ -1681,6 +1832,12 @@ "object-visit": "^1.0.0" } }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true + }, "colors": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", @@ -1845,6 +2002,16 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, + "copy-props": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.4.tgz", + "integrity": "sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A==", + "dev": true, + "requires": { + "each-props": "^1.3.0", + "is-plain-object": "^2.0.1" + } + }, "core-js": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", @@ -2129,13 +2296,36 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "default-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", + "integrity": "sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ==", + "dev": true, + "requires": { + "kind-of": "^5.0.2" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "default-resolution": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz", + "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", "dev": true, "requires": { - "clone": "^1.0.2" + "object-keys": "^1.0.12" } }, "define-property": { @@ -2232,12 +2422,6 @@ "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, - "deprecated": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", - "dev": true - }, "deps-sort": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", @@ -2351,6 +2535,28 @@ "readable-stream": "^2.0.2" } }, + "duplexify": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.1.tgz", + "integrity": "sha512-vM58DwdnKmty+FSPzT14K9JXb90H+j5emaR4KYbr2KTIz00WHGbWOe5ghQTx233ZCLZtrGDALzKwcjEtSt35mA==", + "dev": true, + "requires": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + } + }, + "each-props": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/each-props/-/each-props-1.3.2.tgz", + "integrity": "sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.1", + "object.defaults": "^1.1.0" + } + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2389,23 +2595,12 @@ "dev": true }, "end-of-stream": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "~1.3.0" - }, - "dependencies": { - "once": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "1" - } - } + "once": "^1.4.0" } }, "engine.io": { @@ -2482,6 +2677,15 @@ "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", "dev": true }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, "es5-ext": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.31.tgz", @@ -3151,11 +3355,15 @@ } } }, - "find-index": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", - "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", - "dev": true + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } }, "findup-sync": { "version": "2.0.0", @@ -3169,361 +3377,85 @@ "resolve-dir": "^1.0.1" }, "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "is-extglob": "^2.1.0" } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - } - } - }, - "fined": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.0.tgz", - "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "is-plain-object": "^2.0.3", - "object.defaults": "^1.1.0", - "object.pick": "^1.2.0", - "parse-filepath": "^1.0.1" - } - }, - "first-chunk-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", - "dev": true - }, - "flagged-respawn": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.0.tgz", - "integrity": "sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=", - "dev": true - }, - "flat-cache": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", - "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", - "dev": true, - "requires": { - "circular-json": "^0.3.1", - "del": "^2.0.2", - "graceful-fs": "^4.1.2", - "write": "^0.2.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - } - } - }, - "flatted": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", - "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", - "dev": true - }, - "follow-redirects": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", - "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", - "dev": true, - "requires": { - "debug": "=3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + } + } + }, + "fined": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.1.tgz", + "integrity": "sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g==", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" + } + }, + "flagged-respawn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", + "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", + "dev": true + }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "^0.3.1", + "del": "^2.0.2", + "graceful-fs": "^4.1.2", + "write": "^0.2.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "dev": true + }, + "flush-write-stream": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", + "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.4" + } + }, + "follow-redirects": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", + "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", + "dev": true, + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { "ms": "2.0.0" @@ -3537,6 +3469,15 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dev": true, + "requires": { + "for-in": "^1.0.1" + } + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -3592,6 +3533,16 @@ "null-check": "^1.0.0" } }, + "fs-mkdirp-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", + "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "through2": "^2.0.3" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4133,15 +4084,6 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "gaze": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", - "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", - "dev": true, - "requires": { - "globule": "~0.1.0" - } - }, "generate-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", @@ -4157,6 +4099,12 @@ "is-property": "^1.0.0" } }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", @@ -4222,86 +4170,35 @@ } }, "glob-stream": { - "version": "3.1.18", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", + "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", "dev": true, "requires": { - "glob": "^4.3.1", - "glob2base": "^0.0.12", - "minimatch": "^2.0.1", - "ordered-read-streams": "^0.1.0", - "through2": "^0.6.1", - "unique-stream": "^1.0.0" - }, - "dependencies": { - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "^1.0.0" - } - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } - } + "extend": "^3.0.0", + "glob": "^7.1.1", + "glob-parent": "^3.1.0", + "is-negated-glob": "^1.0.0", + "ordered-read-streams": "^1.0.0", + "pumpify": "^1.3.5", + "readable-stream": "^2.1.5", + "remove-trailing-separator": "^1.0.1", + "to-absolute-glob": "^2.0.0", + "unique-stream": "^2.0.2" } }, "glob-watcher": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", - "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.3.tgz", + "integrity": "sha512-8tWsULNEPHKQ2MR4zXuzSmqbdyV5PtwwCaWSGQ1WwHsJ07ilNeN1JB8ntxhckbnpSHaf9dXFUHzIWvm1I13dsg==", "dev": true, "requires": { - "gaze": "^0.5.1" - } - }, - "glob2base": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", - "dev": true, - "requires": { - "find-index": "^0.1.1" + "anymatch": "^2.0.0", + "async-done": "^1.2.0", + "chokidar": "^2.0.0", + "is-negated-glob": "^1.0.0", + "just-debounce": "^1.0.0", + "object.defaults": "^1.1.0" } }, "global-modules": { @@ -4356,58 +4253,6 @@ } } }, - "globule": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", - "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", - "dev": true, - "requires": { - "glob": "~3.1.21", - "lodash": "~1.0.1", - "minimatch": "~0.2.11" - }, - "dependencies": { - "glob": { - "version": "3.1.21", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true, - "requires": { - "graceful-fs": "~1.2.0", - "inherits": "1", - "minimatch": "~0.2.11" - } - }, - "graceful-fs": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "dev": true - }, - "inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", - "dev": true - }, - "lodash": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", - "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", - "dev": true - }, - "minimatch": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true, - "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" - } - } - } - }, "glogg": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", @@ -4418,13 +4263,10 @@ } }, "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "dev": true, - "requires": { - "natives": "^1.1.0" - } + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true }, "graceful-readlink": { "version": "1.0.1", @@ -4439,24 +4281,111 @@ "dev": true }, "gulp": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", - "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.0.tgz", + "integrity": "sha1-lXZsYB2t5Kd+0+eyttwDiBtZY2Y=", "dev": true, "requires": { - "archy": "^1.0.0", - "chalk": "^1.0.0", - "deprecated": "^0.0.1", - "gulp-util": "^3.0.0", - "interpret": "^1.0.0", - "liftoff": "^2.1.0", - "minimist": "^1.1.0", - "orchestrator": "^0.3.0", - "pretty-hrtime": "^1.0.0", - "semver": "^4.1.0", - "tildify": "^1.0.0", - "v8flags": "^2.0.2", - "vinyl-fs": "^0.3.0" + "glob-watcher": "^5.0.0", + "gulp-cli": "^2.0.0", + "undertaker": "^1.0.0", + "vinyl-fs": "^3.0.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "fancy-log": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz", + "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==", + "dev": true, + "requires": { + "ansi-gray": "^0.1.1", + "color-support": "^1.1.3", + "parse-node-version": "^1.0.0", + "time-stamp": "^1.0.0" + } + }, + "gulp-cli": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.0.1.tgz", + "integrity": "sha512-RxujJJdN8/O6IW2nPugl7YazhmrIEjmiVfPKrWt68r71UCaLKS71Hp0gpKT+F6qOUFtr7KqtifDKaAJPRVvMYQ==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "archy": "^1.0.0", + "array-sort": "^1.0.0", + "color-support": "^1.1.3", + "concat-stream": "^1.6.0", + "copy-props": "^2.0.1", + "fancy-log": "^1.3.2", + "gulplog": "^1.0.0", + "interpret": "^1.1.0", + "isobject": "^3.0.1", + "liftoff": "^2.5.0", + "matchdep": "^2.0.0", + "mute-stdout": "^1.0.0", + "pretty-hrtime": "^1.0.0", + "replace-homedir": "^1.0.0", + "semver-greatest-satisfied-range": "^1.1.0", + "v8flags": "^3.0.1", + "yargs": "^7.1.0" + } + }, + "interpret": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", + "dev": true + }, + "yargs": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz", + "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=", + "dev": true, + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^5.0.0" + } + } } }, "gulp-babel": { @@ -4827,6 +4756,12 @@ "sparkles": "^1.0.0" } }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -4966,6 +4901,12 @@ "parse-passwd": "^1.0.0" } }, + "hosted-git-info": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", + "dev": true + }, "htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", @@ -5163,6 +5104,12 @@ "loose-envify": "^1.0.0" } }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, "is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", @@ -5182,6 +5129,12 @@ "kind-of": "^3.0.2" } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -5197,6 +5150,15 @@ "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", "dev": true }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, + "requires": { + "builtin-modules": "^1.0.0" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -5276,6 +5238,12 @@ "xtend": "^4.0.0" } }, + "is-negated-glob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", + "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", + "dev": true + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -5394,6 +5362,12 @@ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, + "is-valid-glob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", + "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -5534,6 +5508,12 @@ "jsonify": "~0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -5584,6 +5564,12 @@ } } }, + "just-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.0.0.tgz", + "integrity": "sha1-h/zPrv/AtozRnVX2cilD+SnqNeo=", + "dev": true + }, "karma": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/karma/-/karma-4.0.0.tgz", @@ -5710,6 +5696,16 @@ } } }, + "last-run": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", + "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "dev": true, + "requires": { + "default-resolution": "^2.0.0", + "es6-weak-map": "^2.0.1" + } + }, "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", @@ -5722,12 +5718,39 @@ "integrity": "sha1-U3cWwHduTPeePtG2IfdljCkRsbE=", "dev": true }, + "lazystream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", + "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", + "dev": true, + "requires": { + "readable-stream": "^2.0.5" + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, "lcov-parse": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", "dev": true }, + "lead": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", + "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", + "dev": true, + "requires": { + "flush-write-stream": "^1.0.2" + } + }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -5763,6 +5786,19 @@ "resolve": "^1.1.7" } }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -5963,12 +5999,6 @@ "js-tokens": "^3.0.0" } }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, "make-error": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", @@ -6016,6 +6046,18 @@ "object-visit": "^1.0.0" } }, + "matchdep": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", + "integrity": "sha1-xvNINKDY28OzfCfui7yyfHd1WC4=", + "dev": true, + "requires": { + "findup-sync": "^2.0.0", + "micromatch": "^3.0.4", + "resolve": "^1.4.0", + "stack-trace": "0.0.10" + } + }, "md5.js": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", @@ -6296,6 +6338,12 @@ } } }, + "mute-stdout": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", + "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", + "dev": true + }, "mute-stream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", @@ -6393,6 +6441,18 @@ "abbrev": "1" } }, + "normalize-package-data": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.2.tgz", + "integrity": "sha512-YcMnjqeoUckXTPKZSAsPjUPLxH85XotbpqK3w4RyCwdFQSU5FxxBys8buehkSfg0j9fKvV1hn7O0+8reEgkAiw==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -6402,6 +6462,15 @@ "remove-trailing-separator": "^1.0.1" } }, + "now-and-later": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.0.tgz", + "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", + "dev": true, + "requires": { + "once": "^1.3.2" + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -6463,6 +6532,12 @@ } } }, + "object-keys": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", + "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", + "dev": true + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -6480,6 +6555,18 @@ } } }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", @@ -6490,23 +6577,6 @@ "array-slice": "^1.0.0", "for-own": "^1.0.0", "isobject": "^3.0.0" - }, - "dependencies": { - "for-own": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } } }, "object.map": { @@ -6517,17 +6587,6 @@ "requires": { "for-own": "^1.0.0", "make-iterator": "^1.0.0" - }, - "dependencies": { - "for-own": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - } } }, "object.pick": { @@ -6547,6 +6606,16 @@ } } }, + "object.reduce": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz", + "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "dev": true, + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -6609,23 +6678,15 @@ "wordwrap": "~1.0.0" } }, - "orchestrator": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", - "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "ordered-read-streams": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", + "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", "dev": true, "requires": { - "end-of-stream": "~0.1.5", - "sequencify": "~0.0.7", - "stream-consume": "~0.1.0" + "readable-stream": "^2.0.1" } }, - "ordered-read-streams": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", - "dev": true - }, "os-browserify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", @@ -6638,6 +6699,15 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "dev": true, + "requires": { + "lcid": "^1.0.0" + } + }, "os-shim": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", @@ -6695,6 +6765,21 @@ "path-root": "^0.1.1" } }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true + }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -6743,6 +6828,15 @@ "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", "dev": true }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -6788,6 +6882,17 @@ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", "dev": true }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, "pbkdf2": { "version": "3.0.14", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", @@ -6913,6 +7018,27 @@ "randombytes": "^2.0.1" } }, + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "pumpify": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", + "dev": true, + "requires": { + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" + } + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -7027,6 +7153,27 @@ "readable-stream": "^2.0.2" } }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", @@ -7151,6 +7298,27 @@ "jsesc": "~0.5.0" } }, + "remove-bom-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz", + "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5", + "is-utf8": "^0.2.1" + } + }, + "remove-bom-stream": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", + "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", + "dev": true, + "requires": { + "remove-bom-buffer": "^3.0.0", + "safe-buffer": "^5.1.0", + "through2": "^2.0.3" + } + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -7184,6 +7352,17 @@ "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", "dev": true }, + "replace-homedir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz", + "integrity": "sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1", + "is-absolute": "^1.0.0", + "remove-trailing-separator": "^1.1.0" + } + }, "request": { "version": "2.74.0", "resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", @@ -7213,6 +7392,18 @@ "tunnel-agent": "~0.4.1" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, "require-relative": { "version": "0.8.7", "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", @@ -7260,6 +7451,15 @@ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, + "resolve-options": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", + "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", + "dev": true, + "requires": { + "value-or-function": "^3.0.0" + } + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -7359,15 +7559,24 @@ "dev": true }, "semver": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, - "sequencify": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", - "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", + "semver-greatest-satisfied-range": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz", + "integrity": "sha1-E+jCZYq5aRywzXEJMkAoDTb3els=", + "dev": true, + "requires": { + "sver-compat": "^1.5.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, "set-value": { @@ -7457,12 +7666,6 @@ "rechoir": "^0.6.2" } }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -7767,6 +7970,38 @@ "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", "dev": true }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", + "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", + "dev": true + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -7807,6 +8042,12 @@ } } }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -7854,10 +8095,10 @@ "readable-stream": "^2.0.2" } }, - "stream-consume": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz", - "integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==", + "stream-exhaust": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", + "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", "dev": true }, "stream-http": { @@ -7873,6 +8114,12 @@ "xtend": "^4.0.0" } }, + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", + "dev": true + }, "stream-splicer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", @@ -7945,12 +8192,11 @@ } }, "strip-bom": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "first-chunk-stream": "^1.0.0", "is-utf8": "^0.2.0" } }, @@ -7981,6 +8227,16 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, + "sver-compat": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", + "integrity": "sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg=", + "dev": true, + "requires": { + "es6-iterator": "^2.0.1", + "es6-symbol": "^3.1.1" + } + }, "syntax-error": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", @@ -8059,13 +8315,14 @@ "xtend": "~4.0.1" } }, - "tildify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", - "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "through2-filter": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz", + "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==", "dev": true, "requires": { - "os-homedir": "^1.0.0" + "through2": "~2.0.0", + "xtend": "~4.0.0" } }, "time-stamp": { @@ -8092,6 +8349,16 @@ "os-tmpdir": "~1.0.2" } }, + "to-absolute-glob": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", + "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", + "dev": true, + "requires": { + "is-absolute": "^1.0.0", + "is-negated-glob": "^1.0.0" + } + }, "to-array": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", @@ -8152,6 +8419,15 @@ } } }, + "to-through": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", + "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", + "dev": true, + "requires": { + "through2": "^2.0.3" + } + }, "tough-cookie": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", @@ -8275,6 +8551,29 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "undertaker": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", + "integrity": "sha1-M52kZGJS0ILcN45wgGcpl1DhG0k=", + "dev": true, + "requires": { + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "bach": "^1.0.0", + "collection-map": "^1.0.0", + "es6-weak-map": "^2.0.1", + "last-run": "^1.1.0", + "object.defaults": "^1.0.0", + "object.reduce": "^1.0.0", + "undertaker-registry": "^1.0.0" + } + }, + "undertaker-registry": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz", + "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=", + "dev": true + }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", @@ -8311,10 +8610,14 @@ } }, "unique-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", - "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", + "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==", + "dev": true, + "requires": { + "json-stable-stringify-without-jsonify": "^1.0.1", + "through2-filter": "^3.0.0" + } }, "unpipe": { "version": "1.0.0", @@ -8415,12 +8718,6 @@ } } }, - "user-home": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", - "dev": true - }, "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", @@ -8473,14 +8770,30 @@ "dev": true }, "v8flags": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", - "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", + "integrity": "sha512-MtivA7GF24yMPte9Rp/BWGCYQNaUj86zeYxV/x2RRJMKagImbbv3u8iJC57lNhWLPcGLJmHcHmFWkNsplbbLWw==", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { - "user-home": "^1.1.1" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, + "value-or-function": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", + "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", + "dev": true + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -8512,19 +8825,72 @@ } }, "vinyl-fs": { - "version": "0.3.14", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", - "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", + "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==", + "dev": true, + "requires": { + "fs-mkdirp-stream": "^1.0.0", + "glob-stream": "^6.1.0", + "graceful-fs": "^4.0.0", + "is-valid-glob": "^1.0.0", + "lazystream": "^1.0.0", + "lead": "^1.0.0", + "object.assign": "^4.0.4", + "pumpify": "^1.3.5", + "readable-stream": "^2.3.3", + "remove-bom-buffer": "^3.0.0", + "remove-bom-stream": "^1.2.0", + "resolve-options": "^1.1.0", + "through2": "^2.0.0", + "to-through": "^2.0.0", + "value-or-function": "^3.0.0", + "vinyl": "^2.0.0", + "vinyl-sourcemap": "^1.1.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true + }, + "vinyl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz", + "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", + "dev": true, + "requires": { + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" + } + } + } + }, + "vinyl-source-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-1.1.0.tgz", + "integrity": "sha1-RMvlEIIFJ53rDFZTwJSiiHk4sas=", "dev": true, "requires": { - "defaults": "^1.0.0", - "glob-stream": "^3.1.5", - "glob-watcher": "^0.0.6", - "graceful-fs": "^3.0.0", - "mkdirp": "^0.5.0", - "strip-bom": "^1.0.0", "through2": "^0.6.1", - "vinyl": "^0.4.0" + "vinyl": "^0.4.3" }, "dependencies": { "clone": { @@ -8573,58 +8939,60 @@ } } }, - "vinyl-source-stream": { + "vinyl-sourcemap": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-1.1.0.tgz", - "integrity": "sha1-RMvlEIIFJ53rDFZTwJSiiHk4sas=", + "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", + "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", "dev": true, "requires": { - "through2": "^0.6.1", - "vinyl": "^0.4.3" + "append-buffer": "^1.0.2", + "convert-source-map": "^1.5.0", + "graceful-fs": "^4.1.6", + "normalize-path": "^2.1.1", + "now-and-later": "^2.0.0", + "remove-bom-buffer": "^3.0.0", + "vinyl": "^2.0.0" }, "dependencies": { "clone": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", "dev": true }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", "dev": true }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "convert-source-map": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "safe-buffer": "~5.1.1" } }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" - } + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true }, "vinyl": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz", + "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", "dev": true, "requires": { - "clone": "^0.2.0", - "clone-stats": "^0.0.1" + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" } } } @@ -8662,6 +9030,12 @@ "isexe": "^2.0.0" } }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "dev": true + }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", @@ -8674,6 +9048,16 @@ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -8712,6 +9096,12 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", @@ -8730,6 +9120,23 @@ "window-size": "0.1.0" } }, + "yargs-parser": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.0.tgz", + "integrity": "sha1-J17PDX/+Bcd+ZOfIbkzZS/DhIoo=", + "dev": true, + "requires": { + "camelcase": "^3.0.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + } + } + }, "yauzl": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", diff --git a/package.json b/package.json index e3c95467..eadbeb86 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "codeclimate-test-reporter": "^0.4.0", "coveralls": "^2.11.4", "expect.js": "^0.3.1", - "gulp": "^3.9.1", + "gulp": "^4.0.0", "gulp-babel": "^6.1.2", "gulp-concat": "^2.5.2", "gulp-eslint": "^3.0.1", From d82b1b2d098abd8667de265f4f4eed3ce7b66708 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:26:16 +0000 Subject: [PATCH 212/224] Update browserify --- package-lock.json | 573 +++++++++++++++++++++++++++++----------------- package.json | 2 +- 2 files changed, 363 insertions(+), 212 deletions(-) diff --git a/package-lock.json b/package-lock.json index 14836ec7..d98cd525 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,9 @@ } }, "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, "requires": { "jsonparse": "^1.2.0", @@ -63,6 +63,12 @@ "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", "dev": true }, + "acorn-dynamic-import": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", + "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", + "dev": true + }, "acorn-jsx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", @@ -80,6 +86,32 @@ } } }, + "acorn-node": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.2.tgz", + "integrity": "sha512-rIhNEZuNI8ibQcL7ANm/mGyPukIaZsRNX9psFNQURyJW0nu6k8wjSDld20z6v2mDBWqX13pIEnk9gGZJHIlEXg==", + "dev": true, + "requires": { + "acorn": "^6.0.2", + "acorn-dynamic-import": "^4.0.0", + "acorn-walk": "^6.1.0", + "xtend": "^4.0.1" + }, + "dependencies": { + "acorn": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.6.tgz", + "integrity": "sha512-5M3G/A4uBSMIlfJ+h9W125vJvPFH/zirISsW5qfxF5YzEvXJCtolLoQvM5yZft0DvMcUrPGKPOlgEu55I6iUtA==", + "dev": true + } + } + }, + "acorn-walk": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", + "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==", + "dev": true + }, "after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -384,9 +416,9 @@ } }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { "bn.js": "^4.0.0", @@ -415,15 +447,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "dev": true, - "requires": { - "acorn": "^4.0.3" - } - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -1162,9 +1185,9 @@ "dev": true }, "base64-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, "base64id": { @@ -1327,22 +1350,23 @@ "dev": true }, "browser-pack": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", - "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", + "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" } }, "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", + "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, "requires": { "resolve": "1.1.7" @@ -1363,36 +1387,37 @@ "dev": true }, "browserify": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-13.3.0.tgz", - "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=", + "version": "16.2.3", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.2.3.tgz", + "integrity": "sha512-zQt/Gd1+W+IY+h/xX2NYMW4orQWhqSwyV+xsblycTtpOuB27h1fZhhNQuipJ4t79ohw4P4mMem0jp/ZkISQtjQ==", "dev": true, "requires": { "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^1.11.0", - "browserify-zlib": "~0.1.2", - "buffer": "^4.1.0", + "browserify-zlib": "~0.2.0", + "buffer": "^5.0.2", "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.1", + "concat-stream": "^1.6.0", "console-browserify": "^1.1.0", "constants-browserify": "~1.0.0", "crypto-browserify": "^3.0.0", "defined": "^1.0.0", "deps-sort": "^2.0.0", - "domain-browser": "~1.1.0", + "domain-browser": "^1.2.0", "duplexer2": "~0.1.2", - "events": "~1.1.0", + "events": "^2.0.0", "glob": "^7.1.0", "has": "^1.0.0", "htmlescape": "^1.1.0", - "https-browserify": "~0.0.0", + "https-browserify": "^1.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", "labeled-stream-splicer": "^2.0.0", - "module-deps": "^4.0.8", - "os-browserify": "~0.1.1", + "mkdirp": "^0.5.0", + "module-deps": "^6.0.0", + "os-browserify": "~0.3.0", "parents": "^1.0.1", "path-browserify": "~0.0.0", "process": "~0.11.0", @@ -1405,22 +1430,45 @@ "shell-quote": "^1.6.1", "stream-browserify": "^2.0.0", "stream-http": "^2.0.0", - "string_decoder": "~0.10.0", + "string_decoder": "^1.1.1", "subarg": "^1.0.0", "syntax-error": "^1.1.1", "through2": "^2.0.0", "timers-browserify": "^1.0.1", - "tty-browserify": "~0.0.0", + "tty-browserify": "0.0.1", "url": "~0.11.0", "util": "~0.10.1", - "vm-browserify": "~0.0.1", + "vm-browserify": "^1.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "browserify-aes": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.8.tgz", - "integrity": "sha512-WYCMOT/PtGTlpOKFht0YJFYcPy6pLCR98CtWfzK13zoynLlBMvAdEMSRGmgnJCw2M2j/5qxBkinZQFobieM8dQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "^1.0.3", @@ -1432,9 +1480,9 @@ } }, "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { "browserify-aes": "^1.0.4", @@ -1443,14 +1491,23 @@ } }, "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "browserify-rsa": { @@ -1479,23 +1536,22 @@ } }, "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "~0.2.0" + "pako": "~1.0.5" } }, "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, "requires": { "base64-js": "^1.0.2", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" + "ieee754": "^1.1.4" } }, "buffer-alloc": { @@ -1597,9 +1653,9 @@ } }, "cached-path-relative": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz", - "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", + "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", "dev": true }, "caller-path": { @@ -1854,9 +1910,9 @@ } }, "combine-source-map": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", - "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { "convert-source-map": "~1.1.0", @@ -2091,9 +2147,9 @@ } }, "create-ecdh": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", - "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -2101,21 +2157,22 @@ } }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", - "ripemd160": "^2.0.0", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", "sha.js": "^2.4.0" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", @@ -2157,9 +2214,9 @@ } }, "crypto-browserify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "^1.0.0", @@ -2171,7 +2228,8 @@ "inherits": "^2.0.1", "pbkdf2": "^3.0.3", "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0" + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" } }, "css": { @@ -2466,13 +2524,14 @@ "dev": true }, "detective": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.5.0.tgz", - "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", + "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", "dev": true, "requires": { - "acorn": "^4.0.3", - "defined": "^1.0.0" + "acorn-node": "^1.6.1", + "defined": "^1.0.0", + "minimist": "^1.1.1" } }, "di": { @@ -2488,9 +2547,9 @@ "dev": true }, "diffie-hellman": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", - "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -2521,9 +2580,9 @@ } }, "domain-browser": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, "duplexer2": { @@ -2574,9 +2633,9 @@ "dev": true }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -2974,9 +3033,9 @@ "integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo=" }, "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", + "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", "dev": true }, "evp_bytestokey": { @@ -4099,6 +4158,12 @@ "is-property": "^1.0.0" } }, + "get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, "get-caller-file": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", @@ -4701,12 +4766,12 @@ } }, "has": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "^1.1.1" } }, "has-ansi": { @@ -4823,22 +4888,23 @@ } }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hat": { @@ -4956,9 +5022,9 @@ } }, "https-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", - "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, "https-proxy-agent": { @@ -4998,9 +5064,9 @@ } }, "ieee754": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, "ignore": { @@ -5074,19 +5140,35 @@ } }, "insert-module-globals": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", - "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", + "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", - "concat-stream": "~1.5.1", + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", + "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } } }, "interpret": { @@ -5678,20 +5760,20 @@ } }, "labeled-stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", - "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", + "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { "inherits": "^2.0.1", - "isarray": "~0.0.1", + "isarray": "^2.0.4", "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", + "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", "dev": true } } @@ -5761,15 +5843,6 @@ "type-check": "~0.3.2" } }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "^2.0.0" - } - }, "liftoff": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz", @@ -6059,24 +6132,21 @@ } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" }, "dependencies": { - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true } } }, @@ -6147,9 +6217,9 @@ } }, "minimalistic-assert": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", - "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { @@ -6272,26 +6342,40 @@ } }, "module-deps": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", - "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.0.tgz", + "integrity": "sha512-hKPmO06so6bL/ZvqVNVqdTVO8UAYsi3tQWlCa+z9KuWhoN4KDQtb5hcqQQv58qYiDE21wIvnttZEPiDgEbpwbA==", "dev": true, "requires": { "JSONStream": "^1.0.3", "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.0", + "concat-stream": "~1.6.0", "defined": "^1.0.0", - "detective": "^4.0.0", + "detective": "^5.0.2", "duplexer2": "^0.1.2", "inherits": "^2.0.1", "parents": "^1.0.0", "readable-stream": "^2.0.2", - "resolve": "^1.1.3", + "resolve": "^1.4.0", "stream-combiner2": "^1.1.1", "subarg": "^1.0.0", "through2": "^2.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } } }, "ms": { @@ -6688,9 +6772,9 @@ } }, "os-browserify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", - "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, "os-homedir": { @@ -6727,9 +6811,9 @@ "dev": true }, "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.8.tgz", + "integrity": "sha512-6i0HVbUfcKaTv+EG8ZTr75az7GFXcLYk9UyLEg7Notv/Ma+z/UG3TCoz6GiNeOrn1E/e63I0X/Hpw18jHOTUnA==", "dev": true }, "parents": { @@ -6742,16 +6826,17 @@ } }, "parse-asn1": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", - "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.3.tgz", + "integrity": "sha512-VrPoetlz7B/FqjBLD2f5wBVZvsZVLnRUrxVLfRYhGXCODa/NWE4p3Wp+6+aV3ZPL3KM7/OZmxDIwwijD7yuucg==", "dev": true, "requires": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3" + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" } }, "parse-filepath": { @@ -6817,9 +6902,9 @@ "dev": true }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-dirname": { @@ -6894,9 +6979,9 @@ } }, "pbkdf2": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", - "integrity": "sha512-gjsZW9O34fm0R7PaLHRJmLLVfSoesxztjPjE9o6R+qtVJij90ltg1joIovN9GKrRW3t1PzhDDG3UMEMFfZ+1wA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -7006,16 +7091,25 @@ "dev": true }, "public-encrypt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", - "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "pump": { @@ -7118,11 +7212,21 @@ "dev": true }, "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { + "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, @@ -7507,12 +7611,12 @@ } }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "^2.0.0", + "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, @@ -7609,9 +7713,9 @@ "dev": true }, "sha.js": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", - "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -7672,6 +7776,12 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "dev": true + }, "sinon": { "version": "1.17.7", "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", @@ -8076,9 +8186,9 @@ "dev": true }, "stream-browserify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", - "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", + "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, "requires": { "inherits": "~2.0.1", @@ -8102,16 +8212,48 @@ "dev": true }, "stream-http": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", - "readable-stream": "^2.2.6", + "readable-stream": "^2.3.6", "to-arraybuffer": "^1.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "stream-shift": { @@ -8238,12 +8380,12 @@ } }, "syntax-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", - "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn": "^4.0.3" + "acorn-node": "^1.2.0" } }, "table": { @@ -8450,9 +8592,9 @@ "dev": true }, "tty-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", - "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, "tunnel-agent": { @@ -8540,9 +8682,9 @@ "dev": true }, "umd": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", - "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, "unc-path-regex": { @@ -8551,6 +8693,18 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "undeclared-identifiers": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", + "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", + "dev": true, + "requires": { + "acorn-node": "^1.3.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + } + }, "undertaker": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", @@ -9007,13 +9161,10 @@ } }, "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "dev": true, - "requires": { - "indexof": "0.0.1" - } + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", + "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", + "dev": true }, "void-elements": { "version": "2.0.1", diff --git a/package.json b/package.json index eadbeb86..7672ac26 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "async": "^1.4.2", "babel-preset-es2015": "^6.18.0", "babel-preset-es2015-loose": "^8.0.0", - "browserify": "^13.1.1", + "browserify": "^16.2.3", "codeclimate-test-reporter": "^0.4.0", "coveralls": "^2.11.4", "expect.js": "^0.3.1", From 43e9b253cf00d964da6adb7cdb84c18572ea84ea Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:27:11 +0000 Subject: [PATCH 213/224] Update coveralls --- package-lock.json | 268 +++++++++++++++++++++++++++++++++++++++------- package.json | 2 +- 2 files changed, 229 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index d98cd525..d60653a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2081,67 +2081,202 @@ "dev": true }, "coveralls": { - "version": "2.13.3", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-2.13.3.tgz", - "integrity": "sha512-iiAmn+l1XqRwNLXhW8Rs5qHZRFMYp9ZIPjEOVRpC/c4so6Y/f4/lFi0FfR5B9cCqgyhkJ5cZmbvcVRfP8MHchw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.2.tgz", + "integrity": "sha512-Tv0LKe/MkBOilH2v7WBiTBdudg2ChfGbdXafc/s330djpF3zKOmuehTeRwjXWc7pzfj9FrDUTA7tEx6Div8NFw==", "dev": true, "requires": { - "js-yaml": "3.6.1", - "lcov-parse": "0.0.10", - "log-driver": "1.2.5", - "minimist": "1.2.0", - "request": "2.79.0" + "growl": "~> 1.10.0", + "js-yaml": "^3.11.0", + "lcov-parse": "^0.0.10", + "log-driver": "^1.2.7", + "minimist": "^1.2.0", + "request": "^2.85.0" }, "dependencies": { + "ajv": { + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.8.1.tgz", + "integrity": "sha512-eqxCp82P+JfqL683wwsL73XmFs1eG6qjw+RD3YHx+Jll1r0jNd4dh8QG9NYAeNGA/hnZjeEDgtTskgJULbxpWQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, "form-data": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "js-yaml": { + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", + "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "dev": true + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "dev": true, + "requires": { + "mime-db": "~1.37.0" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, "qs": { - "version": "6.3.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", - "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, "request": { - "version": "2.79.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", - "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "dev": true, "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.11.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~2.0.6", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "qs": "~6.3.0", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "~0.4.1", - "uuid": "^3.0.0" + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" } }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", "dev": true } } @@ -3317,6 +3452,18 @@ "time-stamp": "^1.0.0" } }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -4753,6 +4900,12 @@ } } }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, "har-validator": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", @@ -5581,6 +5734,12 @@ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, "json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", @@ -6010,9 +6169,9 @@ } }, "log-driver": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.5.tgz", - "integrity": "sha1-euTsJXMC/XkNVXyxDJcQDYV7AFY=", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", "dev": true }, "log4js": { @@ -6997,6 +7156,12 @@ "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", "dev": true }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -7090,6 +7255,12 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "dev": true + }, "public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", @@ -8831,6 +9002,23 @@ "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + } + } + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", diff --git a/package.json b/package.json index 7672ac26..9a964fe6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "babel-preset-es2015-loose": "^8.0.0", "browserify": "^16.2.3", "codeclimate-test-reporter": "^0.4.0", - "coveralls": "^2.11.4", + "coveralls": "^3.0.2", "expect.js": "^0.3.1", "gulp": "^4.0.0", "gulp-babel": "^6.1.2", From 118bed6c8caa5f65697bb3a042728a2835baf97c Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 3 Feb 2019 23:36:33 +0000 Subject: [PATCH 214/224] Drop support for node 4, test node 8.0+ only --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a98417f0..f2aaeaad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - 4 + - 8.0 - node # Latest env: From 56029f5402363665c5986be22097258f21eb8d49 Mon Sep 17 00:00:00 2001 From: francoisc-wemaik <47186320+francoisc-wemaik@users.noreply.github.com> Date: Mon, 4 Feb 2019 23:42:27 +0100 Subject: [PATCH 215/224] Avoid to use node workers in browser (#96) --- src/defaults.js | 2 +- src/worker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/defaults.js b/src/defaults.js index 4d6f39c9..01640895 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -5,7 +5,7 @@ * configuring a browserify override. */ -if (typeof process !== 'undefined' && 'pid' in process) { +if (typeof process !== 'undefined' && process.arch !== 'browser' && 'pid' in process) { module.exports = require('./defaults.node'); } else { module.exports = require('./defaults.browser'); diff --git a/src/worker.js b/src/worker.js index 77eb6396..a9f7a2d7 100644 --- a/src/worker.js +++ b/src/worker.js @@ -5,7 +5,7 @@ * configuring a browserify override. */ -if (typeof process !== 'undefined' && 'pid' in process) { +if (typeof process !== 'undefined' && process.arch !== 'browser' && 'pid' in process) { module.exports = require('./worker.node/worker'); } else { module.exports = require('./worker.browser/worker'); From 2ffd6636dc9f39ca88f077e47661533479c39792 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 4 Feb 2019 22:43:38 +0000 Subject: [PATCH 216/224] 0.12.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15b50ef6..aeb0909e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.12.0", + "version": "0.12.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b1325f64..df27e658 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threads", - "version": "0.12.0", + "version": "0.12.1", "keywords": [ "threads", "web worker", From 9d7496f7c2cbdc73d44019028992f1d6cc6ba0c8 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 4 Feb 2019 22:49:58 +0000 Subject: [PATCH 217/224] Add v0.12.1 to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab500e47..2c30cfce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # threads.js - Changelog +## 0.12.1 + +- Avoid to use node workers in browser (#96, credits to @francoisc-wemaik) + ## 0.12.0 - Fix UMD bundling (#84) From 3a44c6563b6f104f532f5e5e884b31fd91f39437 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 4 Feb 2019 22:50:23 +0000 Subject: [PATCH 218/224] Add some more files to .npmignore --- .npmignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.npmignore b/.npmignore index 60ebcdb6..165911d0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,6 @@ test/ +*.yml +.*.yml +gulpfile.js +karma.conf.js npm-debug.log From 36a67b2419f05194d00886f70b5b8e898cc4907a Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Wed, 8 May 2019 07:48:28 +0200 Subject: [PATCH 219/224] Update v1.0 note in readme (#102) --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 055e692c..185723fe 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,11 @@ when run by node.js. Also supports browsers which do not support web workers. - Well tested - ES6 and backwards-compatible -Side note: Using threads.js? Check out the [Version 1.0 API draft](https://github.com/andywer/threads.js/issues/88) and feel free to leave feedback! +#### Version 1.0 + +Check out the [Version 1.0 Proress](https://github.com/andywer/threads.js/issues/100) and feel free to leave feedback! + +New to the library? You might want to wait for v1.0 to set sail, since it fixes a bunch of issues and comes with a completely new API. ## Basic usage From 565f4a1402a0693329d7cbae05b58a4a26ecac65 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Thu, 9 May 2019 12:01:48 +0200 Subject: [PATCH 220/224] Fix typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 185723fe..9a03b9a3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ when run by node.js. Also supports browsers which do not support web workers. #### Version 1.0 -Check out the [Version 1.0 Proress](https://github.com/andywer/threads.js/issues/100) and feel free to leave feedback! +Check out the [Version 1.0 Progress](https://github.com/andywer/threads.js/issues/100) and feel free to leave feedback! New to the library? You might want to wait for v1.0 to set sail, since it fixes a bunch of issues and comes with a completely new API. From 03438a75f50e1dd4c7e14a4e65b80048fdc505b6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Mon, 10 Jun 2019 20:26:36 +0200 Subject: [PATCH 221/224] Update dependencies (#113) --- package-lock.json | 795 +++++++++++++++++++++------------------------- package.json | 6 +- 2 files changed, 366 insertions(+), 435 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64109f80..69078fcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,28 +31,28 @@ "dev": true }, "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "dev": true, "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" + "mime-types": "~2.1.24", + "negotiator": "0.6.2" }, "dependencies": { "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.37.0" + "mime-db": "1.40.0" } } } @@ -119,9 +119,9 @@ "dev": true }, "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "dev": true, "requires": { "es6-promisify": "^5.0.0" @@ -169,7 +169,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true + "dev": true, + "optional": true }, "ansi-colors": { "version": "1.1.0", @@ -436,9 +437,9 @@ } }, "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, "assign-symbols": { @@ -499,15 +500,15 @@ "dev": true }, "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", "dev": true }, "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", "dev": true }, "babel-code-frame": { @@ -1226,31 +1227,6 @@ "integrity": "sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw==", "dev": true }, - "bl": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", - "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", - "dev": true, - "requires": { - "readable-stream": "~2.0.5" - }, - "dependencies": { - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - } - } - }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -1258,9 +1234,9 @@ "dev": true }, "bluebird": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", - "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", "dev": true }, "bn.js": { @@ -1270,40 +1246,31 @@ "dev": true }, "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "dev": true, "requires": { - "bytes": "3.0.0", + "bytes": "3.1.0", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "~1.6.3", - "iconv-lite": "0.4.23", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "~1.6.16" + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" }, "dependencies": { "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", "dev": true } } }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "2.x.x" - } - }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", @@ -1616,9 +1583,9 @@ "dev": true }, "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", "dev": true }, "cache-base": { @@ -1686,9 +1653,9 @@ "dev": true }, "caseless": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, "center-align": { @@ -1856,15 +1823,15 @@ "dev": true }, "codeclimate-test-reporter": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/codeclimate-test-reporter/-/codeclimate-test-reporter-0.4.1.tgz", - "integrity": "sha1-nyD22C02qrmdIKvk9sc3L0xtGRU=", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/codeclimate-test-reporter/-/codeclimate-test-reporter-0.5.1.tgz", + "integrity": "sha512-XCzmc8dH+R4orK11BCg5pBbXc35abxq9sept4YvUFRkFl9zb9MIVRrCKENe6U1TKAMTgvGJmrYyHn0y2lerpmg==", "dev": true, "requires": { "async": "~1.5.2", "commander": "2.9.0", "lcov-parse": "0.0.10", - "request": "~2.74.0" + "request": "~2.88.0" } }, "collection-map": { @@ -1900,15 +1867,6 @@ "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", "dev": true }, - "combine-lists": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.1.tgz", - "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=", - "dev": true, - "requires": { - "lodash": "^4.5.0" - } - }, "combine-source-map": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", @@ -1922,9 +1880,9 @@ } }, "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, "requires": { "delayed-stream": "~1.0.0" @@ -2008,14 +1966,14 @@ } }, "connect": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", - "integrity": "sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ=", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", + "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", "dev": true, "requires": { "debug": "2.6.9", - "finalhandler": "1.1.0", - "parseurl": "~1.3.2", + "finalhandler": "1.1.2", + "parseurl": "~1.3.3", "utils-merge": "1.0.1" } }, @@ -2184,9 +2142,9 @@ } }, "js-yaml": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", - "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -2339,15 +2297,6 @@ } } }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "requires": { - "boom": "2.x.x" - } - }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -2426,9 +2375,9 @@ } }, "date-format": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz", - "integrity": "sha1-YV6CjiM90aubua4JUODOzPpuytg=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.0.0.tgz", + "integrity": "sha512-M6UqVvZVgFYqZL1SfHsRGIQSz3ZL+qgbsV5Lp1Vj61LZVYuEwcMXYay7DRDtYs2HQQBK5hQtQ0fD9aEJ89V0LA==", "dev": true }, "date-now": { @@ -2916,9 +2865,9 @@ } }, "es6-promise": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", - "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", "dev": true }, "es6-promisify": { @@ -3204,40 +3153,6 @@ "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", "dev": true }, - "expand-braces": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", - "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", - "dev": true, - "requires": { - "array-slice": "^0.2.3", - "array-unique": "^0.2.1", - "braces": "^0.1.2" - }, - "dependencies": { - "array-slice": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", - "dev": true - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "braces": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", - "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", - "dev": true, - "requires": { - "expand-range": "^0.1.0" - } - } - } - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -3273,30 +3188,6 @@ } } }, - "expand-range": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", - "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", - "dev": true, - "requires": { - "is-number": "^0.1.1", - "repeat-string": "^0.2.2" - }, - "dependencies": { - "is-number": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", - "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=", - "dev": true - }, - "repeat-string": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz", - "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=", - "dev": true - } - } - }, "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", @@ -3539,26 +3430,18 @@ } }, "finalhandler": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", - "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", "dev": true, "requires": { "debug": "2.6.9", - "encodeurl": "~1.0.1", + "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.3.1", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", "unpipe": "~1.0.0" - }, - "dependencies": { - "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - } } }, "find-up": { @@ -3650,22 +3533,28 @@ } }, "follow-redirects": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", - "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", + "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", "dev": true, "requires": { - "debug": "=3.1.0" + "debug": "^3.2.6" }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true } } }, @@ -3691,25 +3580,14 @@ "dev": true }, "form-data": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", - "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { - "async": "^2.0.1", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.11" - }, - "dependencies": { - "async": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", - "dev": true, - "requires": { - "lodash": "^4.14.0" - } - } + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" } }, "formatio": { @@ -3739,6 +3617,17 @@ "null-check": "^1.0.0" } }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -4878,24 +4767,39 @@ } }, "handlebars": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", - "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", + "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", "dev": true, "requires": { - "async": "^1.4.0", + "neo-async": "^2.6.0", "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" }, "dependencies": { + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true, + "optional": true + }, "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "uglify-js": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", + "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, + "optional": true, "requires": { - "amdefine": ">=0.0.4" + "commander": "~2.20.0", + "source-map": "~0.6.1" } } } @@ -4907,15 +4811,27 @@ "dev": true }, "har-validator": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "dev": true, "requires": { - "chalk": "^1.1.1", - "commander": "^2.9.0", - "is-my-json-valid": "^2.12.4", - "pinkie-promise": "^2.0.0" + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + } } }, "has": { @@ -5066,18 +4982,6 @@ "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=", "dev": true }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" - } - }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", @@ -5095,12 +4999,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true - }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -5133,15 +5031,16 @@ "dev": true }, "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "dev": true, "requires": { "depd": "~1.1.2", "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" } }, "http-proxy": { @@ -5156,20 +5055,20 @@ }, "dependencies": { "eventemitter3": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", "dev": true } } }, "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, "requires": { - "assert-plus": "^0.2.0", + "assert-plus": "^1.0.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" } @@ -5200,17 +5099,17 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } }, "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" @@ -5707,13 +5606,21 @@ "dev": true }, "js-yaml": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.6.1.tgz", - "integrity": "sha1-bl/mfYsgXOTSL60Ft3geja3MSzA=", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", - "esprima": "^2.6.0" + "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } } }, "jsbn": { @@ -5767,6 +5674,15 @@ "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -5812,28 +5728,27 @@ "dev": true }, "karma": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/karma/-/karma-4.0.0.tgz", - "integrity": "sha512-EFoFs3F6G0BcUGPNOn/YloGOb3h09hzTguyXlg6loHlKY76qbJikkcyPk43m2kfRF65TUGda/mig29QQtyhm1g==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/karma/-/karma-4.1.0.tgz", + "integrity": "sha512-xckiDqyNi512U4dXGOOSyLKPwek6X/vUizSy2f3geYevbLj+UIdvNwbn7IwfUIL2g1GXEPWt/87qFD1fBbl/Uw==", "dev": true, "requires": { "bluebird": "^3.3.0", "body-parser": "^1.16.1", + "braces": "^2.3.2", "chokidar": "^2.0.3", "colors": "^1.1.0", - "combine-lists": "^1.0.0", "connect": "^3.6.0", "core-js": "^2.2.0", "di": "^0.0.1", "dom-serialize": "^2.2.0", - "expand-braces": "^0.1.1", "flatted": "^2.0.0", "glob": "^7.1.1", "graceful-fs": "^4.1.2", "http-proxy": "^1.13.0", "isbinaryfile": "^3.0.0", - "lodash": "^4.17.5", - "log4js": "^3.0.0", + "lodash": "^4.17.11", + "log4js": "^4.0.0", "mime": "^2.3.1", "minimatch": "^3.0.2", "optimist": "^0.6.1", @@ -5847,12 +5762,6 @@ "useragent": "2.3.0" }, "dependencies": { - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6175,37 +6084,31 @@ "dev": true }, "log4js": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-3.0.6.tgz", - "integrity": "sha512-ezXZk6oPJCWL483zj64pNkMuY/NcRX5MPiB0zE6tjZM137aeusrOnW1ecxgF9cmwMWkBMhjteQxBPoZBh9FDxQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-4.3.1.tgz", + "integrity": "sha512-nPGS7w7kBnzNm1j8JycFxwLCbIMae8tHCo0cCdx/khB20Tcod8SZThYEB9E0c27ObcTGA1mlPowaf3hantQ/FA==", "dev": true, "requires": { - "circular-json": "^0.5.5", - "date-format": "^1.2.0", - "debug": "^3.1.0", + "date-format": "^2.0.0", + "debug": "^4.1.1", + "flatted": "^2.0.0", "rfdc": "^1.1.2", - "streamroller": "0.7.0" + "streamroller": "^1.0.5" }, "dependencies": { - "circular-json": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz", - "integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ==", - "dev": true - }, "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { "ms": "^2.1.1" } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -6231,6 +6134,16 @@ "js-tokens": "^3.0.0" } }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, "make-error": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", @@ -6355,24 +6268,24 @@ } }, "mime": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", - "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", "dev": true }, "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.30.0" + "mime-db": "1.40.0" } }, "minimalistic-assert": { @@ -6658,9 +6571,15 @@ "dev": true }, "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "dev": true + }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, "nice-try": { @@ -6669,12 +6588,6 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", - "dev": true - }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -6736,9 +6649,9 @@ "dev": true }, "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, "object-assign": { @@ -7049,9 +6962,9 @@ } }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, "pascalcase": { @@ -7311,9 +7224,9 @@ "dev": true }, "puppeteer": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.12.1.tgz", - "integrity": "sha512-FlMLdgAnURMMtwb2S6XtkBRw+kh1V+gGt09pCJF9mB1eOnF9+JhtvTxFeu1Rm5X1pKMXq5xrosrhBTgmdwzPeA==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.17.0.tgz", + "integrity": "sha512-3EXZSximCzxuVKpIHtyec8Wm2dWZn1fc5tQi34qWfiUgubEVYHjUvr0GOJojqf3mifI6oyKnCdrGxaOI+lWReA==", "dev": true, "requires": { "debug": "^4.1.0", @@ -7336,9 +7249,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "progress": { @@ -7348,9 +7261,9 @@ "dev": true }, "ws": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.3.tgz", - "integrity": "sha512-tbSxiT+qJI223AP4iLfQbkbxkwdFcneYinM2+x46Gx2wgvbaOMO36czfdfVUBRTHvzAMRhDd98sA5d/BuWbQdg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "dev": true, "requires": { "async-limiter": "~1.0.0" @@ -7365,9 +7278,9 @@ "dev": true }, "qs": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.3.tgz", - "integrity": "sha1-HPyyXBCpsrSDBT/zn138kjOQjP4=", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, "querystring": { @@ -7402,20 +7315,20 @@ } }, "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "dev": true }, "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "dev": true, "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, @@ -7639,32 +7552,45 @@ } }, "request": { - "version": "2.74.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", - "integrity": "sha1-dpPKdou7DqXIzgjAhKRe+gW4kqs=", + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "dev": true, "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "bl": "~1.1.2", - "caseless": "~0.11.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", "forever-agent": "~0.6.1", - "form-data": "~1.0.0-rc4", - "har-validator": "~2.0.6", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "node-uuid": "~1.4.7", - "oauth-sign": "~0.8.1", - "qs": "~6.2.0", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "~0.4.1" + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "require-directory": { @@ -7758,9 +7684,9 @@ "dev": true }, "rfdc": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.2.tgz", - "integrity": "sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", + "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==", "dev": true }, "right-align": { @@ -7878,9 +7804,9 @@ } }, "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", "dev": true }, "sha.js": { @@ -8110,15 +8036,6 @@ "kind-of": "^3.2.0" } }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, - "requires": { - "hoek": "2.x.x" - } - }, "socket.io": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", @@ -8444,17 +8361,27 @@ } }, "streamroller": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-0.7.0.tgz", - "integrity": "sha512-WREzfy0r0zUqp3lGO096wRuUp7ho1X6uo/7DJfTlEi0Iv/4gT7YHqXDjKC2ioVGBZtE8QzsQD9nx1nIuoZ57jQ==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.5.tgz", + "integrity": "sha512-iGVaMcyF5PcUY0cPbW3xFQUXnr9O4RZXNBBjhuLZgrjLO4XCLLGfx4T2sGqygSeylUjwgWRsnNbT9aV0Zb8AYw==", "dev": true, "requires": { - "date-format": "^1.2.0", - "debug": "^3.1.0", - "mkdirp": "^0.5.1", - "readable-stream": "^2.3.0" + "async": "^2.6.2", + "date-format": "^2.0.0", + "debug": "^3.2.6", + "fs-extra": "^7.0.1", + "lodash": "^4.17.11" }, "dependencies": { + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, "debug": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", @@ -8465,9 +8392,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -8489,12 +8416,6 @@ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", - "dev": true - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -8741,12 +8662,19 @@ "through2": "^2.0.3" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "dev": true, "requires": { + "psl": "^1.1.24", "punycode": "^1.4.1" } }, @@ -8769,10 +8697,13 @@ "dev": true }, "tunnel-agent": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } }, "tweetnacl": { "version": "0.14.5", @@ -8790,28 +8721,28 @@ } }, "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "~2.1.24" }, "dependencies": { "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.37.0" + "mime-db": "1.40.0" } } } @@ -8944,6 +8875,12 @@ "through2-filter": "^3.0.0" } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -9068,18 +9005,6 @@ "requires": { "lru-cache": "4.1.x", "tmp": "0.0.x" - }, - "dependencies": { - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - } } }, "util": { @@ -9111,6 +9036,12 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + }, "v8flags": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", diff --git a/package.json b/package.json index 1e86a4b1..e0ec1694 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "babel-preset-es2015": "^6.18.0", "babel-preset-es2015-loose": "^8.0.0", "browserify": "^16.2.3", - "codeclimate-test-reporter": "^0.4.0", + "codeclimate-test-reporter": "^0.5.1", "coveralls": "^3.0.2", "expect.js": "^0.3.1", "gulp": "^4.0.0", @@ -54,7 +54,7 @@ "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^2.0.0", "istanbul": "^0.4.0", - "karma": "^4.0.0", + "karma": "^4.1.0", "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.0.0", "karma-expect": "^1.1.0", @@ -62,7 +62,7 @@ "karma-mocha": "^1.3.0", "mocha": "^5.2.0", "natives": "^1.1.6", - "puppeteer": "^1.12.1", + "puppeteer": "^1.17.0", "sinon": "^1.16.1", "through2": "^2.0.0", "vinyl-source-stream": "^1.1.0" From 93f583a3a0cc85c9d969af9057494a39701a87af Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Tue, 11 Jun 2019 08:34:39 +0200 Subject: [PATCH 222/224] More emphasis on v1.0 --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9a03b9a3..1b2136bc 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,11 @@ when run by node.js. Also supports browsers which do not support web workers. - Well tested - ES6 and backwards-compatible -#### Version 1.0 +### Version 1.0 -Check out the [Version 1.0 Progress](https://github.com/andywer/threads.js/issues/100) and feel free to leave feedback! - -New to the library? You might want to wait for v1.0 to set sail, since it fixes a bunch of issues and comes with a completely new API. +Even though it's not finished yet, you might already want to [**use the new version 1.0**](https://github.com/andywer/threads.js/tree/v1) instead of the old implementation, since v1.0 fixes a bunch of issues and comes with a completely new API. v0.x is about to be deprecated. +Check out the v1.0 progress [**here**](https://github.com/andywer/threads.js/issues/100) and leave some feedback! ## Basic usage From f0a2f93e91772bef7b854d52192f77f8590e4ce6 Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 23 Jun 2019 08:12:59 +0200 Subject: [PATCH 223/224] Turn the old `master` branch into deprecated `v0` --- README.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1b2136bc..6700a8f5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # threads.js -[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=master)](https://travis-ci.org/andywer/threads.js) -[![Coverage Status](https://coveralls.io/repos/github/andywer/threads.js/badge.svg?branch=master)](https://coveralls.io/github/andywer/threads.js?branch=master) -[![Code Climate](https://codeclimate.com/github/andywer/threads.js/badges/gpa.svg)](https://codeclimate.com/github/andywer/threads.js) -[![NPM Version](https://img.shields.io/npm/v/threads.svg)](https://www.npmjs.com/package/threads) +[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=v0)](https://travis-ci.org/andywer/threads.js) +[![Coverage Status](https://coveralls.io/repos/github/andywer/threads.js/badge.svg?branch=v0)](https://coveralls.io/github/andywer/threads.js?branch=v0) + +**Old version 0.x of the library. Only use it as a reference if you are still using threads.js v0 and haven't migrated to v1.0 yet. The v1.0 API is vastly different.** Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers. @@ -14,12 +14,6 @@ when run by node.js. Also supports browsers which do not support web workers. - Well tested - ES6 and backwards-compatible -### Version 1.0 - -Even though it's not finished yet, you might already want to [**use the new version 1.0**](https://github.com/andywer/threads.js/tree/v1) instead of the old implementation, since v1.0 fixes a bunch of issues and comes with a completely new API. v0.x is about to be deprecated. - -Check out the v1.0 progress [**here**](https://github.com/andywer/threads.js/issues/100) and leave some feedback! - ## Basic usage Spawn threads to do the time-consuming work and let the parent thread focus on @@ -200,9 +194,9 @@ const pool = new Pool(); const job = pool .run('/path/to/worker') .send({ do : 'something' }); - + job.on('abort', () => { console.log('Job Aborted'); }); - + // somewhere else job.abort(); ``` From be17e51bca40854214faf52a51b7160603a4636f Mon Sep 17 00:00:00 2001 From: Andy Wermke Date: Sun, 23 Jun 2019 11:46:31 +0200 Subject: [PATCH 224/224] Fix top of readme visually --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6700a8f5..12884803 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ -# threads.js -[![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=v0)](https://travis-ci.org/andywer/threads.js) -[![Coverage Status](https://coveralls.io/repos/github/andywer/threads.js/badge.svg?branch=v0)](https://coveralls.io/github/andywer/threads.js?branch=v0) +# threads.js [![Build Status](https://travis-ci.org/andywer/threads.js.svg?branch=v0)](https://travis-ci.org/andywer/threads.js) -**Old version 0.x of the library. Only use it as a reference if you are still using threads.js v0 and haven't migrated to v1.0 yet. The v1.0 API is vastly different.** +**Look up the old v0.12 API here if you are still using threads.js v0.x and haven't migrated to v1.0 yet.** Javascript thread library. Uses web workers when run in browsers and child processes when run by node.js. Also supports browsers which do not support web workers.