diff --git a/HISTORY.md b/HISTORY.md index 90146786..72765911 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ https://github.com/josdejong/workerpool - Fixed #5 error when loading via AMD or bundling using Webpack. + ## 2016-05-22, version 1.2.0 - Implemented serializing errors with stacktrace. Thanks @mujx. diff --git a/dist/worker.js b/dist/worker.js index b247f4a5..2fe6bf33 100644 --- a/dist/worker.js +++ b/dist/worker.js @@ -1,127 +1,248 @@ -/** - * worker must be started as a child process or a web worker. - * It listens for RPC messages from the parent process. - */ - -var serializerr = require('serializerr') - -// create a worker API for sending and receiving messages which works both on -// node.js and in the browser -var worker = {}; -if (typeof self !== 'undefined' && typeof postMessage === 'function' && typeof addEventListener === 'function') { - // worker in the browser - worker.on = function (event, callback) { - addEventListener(event, function (message) { - callback(message.data); - }) - }; - worker.send = function (message) { - postMessage(message); - }; -} -else if (typeof process !== 'undefined') { - // node.js - worker.on = process.on.bind(process); - worker.send = process.send.bind(process); -} -else { - throw new Error('Script must be executed as a worker'); -} - -/** - * Test whether a value is a Promise via duck typing. - * @param {*} value - * @returns {boolean} Returns true when given value is an object - * having functions `then` and `catch`. - */ -function isPromise(value) { - return value && (typeof value.then === 'function') && (typeof value.catch === 'function'); -} - -// functions available externally -worker.methods = {}; - -/** - * Execute a function with provided arguments - * @param {String} fn Stringified function - * @param {Array} [args] Function arguments - * @returns {*} - */ -worker.methods.run = function run(fn, args) { - var f = eval('(' + fn + ')'); - return f.apply(f, args); -}; - -/** - * Get a list with methods available on this worker - * @return {String[]} methods - */ -worker.methods.methods = function methods() { - return Object.keys(worker.methods); -}; - -worker.on('message', function (request) { - try { - var method = worker.methods[request.method]; - - if (method) { - // execute the function - var result = method.apply(method, request.params); - - if (isPromise(result)) { - // promise returned, resolve this and then return - result - .then(function (result) { - worker.send({ - id: request.id, - result: result, - error: null - }); - }) - .catch(function (err) { - worker.send({ - id: request.id, - result: null, - error: serializerr(err) - }); - }); - } - else { - // immediate result - worker.send({ - id: request.id, - result: result, - error: null - }); - } - } - else { - throw new Error('Unknown method "' + request.method + '"'); - } - } - catch (err) { - worker.send({ - id: request.id, - result: null, - error: serializerr(err) - }); - } -}); - -/** - * Register methods to the worker - * @param {Object} methods - */ -worker.register = function (methods) { - if (methods) { - for (var name in methods) { - if (methods.hasOwnProperty(name)) { - worker.methods[name] = methods[name]; - } - } - } -}; - -if (typeof exports !== 'undefined') { - exports.add = worker.register; -} +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * worker must be started as a child process or a web worker. + * It listens for RPC messages from the parent process. + */ + + var serializerr = __webpack_require__(1); + + // create a worker API for sending and receiving messages which works both on + // node.js and in the browser + var worker = {}; + if (typeof self !== 'undefined' && typeof postMessage === 'function' && typeof addEventListener === 'function') { + // worker in the browser + worker.on = function (event, callback) { + addEventListener(event, function (message) { + callback(message.data); + }) + }; + worker.send = function (message) { + postMessage(message); + }; + } + else if (typeof process !== 'undefined') { + // node.js + worker.on = process.on.bind(process); + worker.send = process.send.bind(process); + } + else { + throw new Error('Script must be executed as a worker'); + } + + /** + * Test whether a value is a Promise via duck typing. + * @param {*} value + * @returns {boolean} Returns true when given value is an object + * having functions `then` and `catch`. + */ + function isPromise(value) { + return value && (typeof value.then === 'function') && (typeof value.catch === 'function'); + } + + // functions available externally + worker.methods = {}; + + /** + * Execute a function with provided arguments + * @param {String} fn Stringified function + * @param {Array} [args] Function arguments + * @returns {*} + */ + worker.methods.run = function run(fn, args) { + var f = eval('(' + fn + ')'); + return f.apply(f, args); + }; + + /** + * Get a list with methods available on this worker + * @return {String[]} methods + */ + worker.methods.methods = function methods() { + return Object.keys(worker.methods); + }; + + worker.on('message', function (request) { + try { + var method = worker.methods[request.method]; + + if (method) { + // execute the function + var result = method.apply(method, request.params); + + if (isPromise(result)) { + // promise returned, resolve this and then return + result + .then(function (result) { + worker.send({ + id: request.id, + result: result, + error: null + }); + }) + .catch(function (err) { + worker.send({ + id: request.id, + result: null, + error: serializerr(err) + }); + }); + } + else { + // immediate result + worker.send({ + id: request.id, + result: result, + error: null + }); + } + } + else { + throw new Error('Unknown method "' + request.method + '"'); + } + } + catch (err) { + worker.send({ + id: request.id, + result: null, + error: serializerr(err) + }); + } + }); + + /** + * Register methods to the worker + * @param {Object} methods + */ + worker.register = function (methods) { + if (methods) { + for (var name in methods) { + if (methods.hasOwnProperty(name)) { + worker.methods[name] = methods[name]; + } + } + } + }; + + if (true) { + exports.add = worker.register; + } + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _protochain = __webpack_require__(2); + + var _protochain2 = _interopRequireDefault(_protochain); + + function serializerr() { + var obj = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var chain = (0, _protochain2['default'])(obj).filter(function (obj) { + return obj !== Object.prototype; + }); + return [obj].concat(chain).map(function (item) { + return Object.getOwnPropertyNames(item); + }).reduce(function (result, names) { + names.forEach(function (name) { + return result[name] = obj[name]; + }); + return result; + }, {}); + } + + module.exports = serializerr; + serializerr.serializerr = serializerr; + exports['default'] = serializerr; + module.exports = exports['default']; + + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + + module.exports = protochain; + + function protochain(obj) { + var result = []; + var target = getPrototypeOf(obj); + while (target) { + result.push(target); + target = getPrototypeOf(target); + } + + return result; + } + + function getPrototypeOf(obj) { + if (obj == null) { + return obj; + }if (isPrimitive(obj)) obj = Object(obj); + return Object.getPrototypeOf(obj); + } + + function isPrimitive(item) { + return item === null || typeof item !== "object" && typeof item !== "function"; + } + + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/dist/workerpool.js b/dist/workerpool.js index a5b70787..8f113b80 100644 --- a/dist/workerpool.js +++ b/dist/workerpool.js @@ -4,11 +4,11 @@ * * Offload tasks to a pool of workers on node.js and in the browser. * - * @version 1.2.0 - * @date 2016-05-22 + * @version 1.2.1 + * @date 2016-06-25 * * @license - * Copyright (C) 2014 Jos de Jong + * Copyright (C) 2014-2016 Jos de Jong * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -25,14 +25,14 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("child_process"), require("os")); + module.exports = factory(); else if(typeof define === 'function' && define.amd) - define(["child_process", "os"], factory); + define([], factory); else if(typeof exports === 'object') - exports["workerpool"] = factory(require("child_process"), require("os")); + exports["workerpool"] = factory(); else - root["workerpool"] = factory(root["child_process"], root["os"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__) { + root["workerpool"] = factory(); +})(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -102,7 +102,7 @@ return /******/ (function(modules) { // webpackBootstrap // worker is already loaded by requiring worker // use embedded worker.js - var blob = new Blob([__webpack_require__(5)], {type: 'text/javascript'}); + var blob = new Blob([__webpack_require__(6)], {type: 'text/javascript'}); var url = window.URL.createObjectURL(blob); importScripts(url); } @@ -129,6 +129,9 @@ return /******/ (function(modules) { // webpackBootstrap var Promise = __webpack_require__(2), WorkerHandler = __webpack_require__(3); + // used to prevent webpack from resolving requires on node libs + var node = {require: __webpack_require__(5)}; + /** * A pool to manage workers * @param {String} [script] Optional worker script @@ -153,7 +156,8 @@ return /******/ (function(modules) { // webpackBootstrap } else { var environment = __webpack_require__(4); - var numCPUs = (environment == 'browser') ? 4 : __webpack_require__(7).cpus().length; + // call node.require to prevent os to be required when loading with AMD + var numCPUs = (environment == 'browser') ? 4 : node.require('os').cpus().length; this.maxWorkers = Math.max(numCPUs - 1, 1); } @@ -679,6 +683,9 @@ return /******/ (function(modules) { // webpackBootstrap // determine environment var environment = __webpack_require__(4); + // used to prevent webpack from resolving requires on node libs + var node = {require: __webpack_require__(5)}; + // get the default worker script function getDefaultWorker() { if (environment == 'browser') { @@ -691,7 +698,7 @@ return /******/ (function(modules) { // webpackBootstrap } // use embedded worker.js - var blob = new Blob([__webpack_require__(5)], {type: 'text/javascript'}); + var blob = new Blob([__webpack_require__(6)], {type: 'text/javascript'}); return window.URL.createObjectURL(blob); } else { @@ -747,7 +754,8 @@ return /******/ (function(modules) { // webpackBootstrap } else { // on node.js, create a child process - this.worker = __webpack_require__(6).fork(this.script); + // call node.require to prevent child_process to be required when loading with AMD + this.worker = node.require('child_process').fork(this.script); } var me = this; @@ -925,6 +933,40 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, /* 5 */ +/***/ function(module, exports, __webpack_require__) { + + var map = { + "./Pool": 1, + "./Pool.js": 1, + "./Promise": 2, + "./Promise.js": 2, + "./WorkerHandler": 3, + "./WorkerHandler.js": 3, + "./environment": 4, + "./environment.js": 4, + "./generated/embeddedWorker": 6, + "./generated/embeddedWorker.js": 6, + "./header": 7, + "./header.js": 7, + "./worker": 8, + "./worker.js": 8 + }; + function webpackContext(req) { + return __webpack_require__(webpackContextResolve(req)); + }; + function webpackContextResolve(req) { + return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }()); + }; + webpackContext.keys = function webpackContextKeys() { + return Object.keys(map); + }; + webpackContext.resolve = webpackContextResolve; + module.exports = webpackContext; + webpackContext.id = 5; + + +/***/ }, +/* 6 */ /***/ function(module, exports) { /** @@ -932,20 +974,38 @@ return /******/ (function(modules) { // webpackBootstrap * This file is automatically generated, * changes made in this file will be overwritten. */ - module.exports = "function isPromise(r){return r&&\"function\"==typeof r.then&&\"function\"==typeof r[\"catch\"]}var serializerr=require(\"serializerr\"),worker={};if(\"undefined\"!=typeof self&&\"function\"==typeof postMessage&&\"function\"==typeof addEventListener)worker.on=function(r,e){addEventListener(r,function(r){e(r.data)})},worker.send=function(r){postMessage(r)};else{if(\"undefined\"==typeof process)throw new Error(\"Script must be executed as a worker\");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval(\"(\"+fn+\")\");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on(\"message\",function(r){try{var e=worker.methods[r.method];if(!e)throw new Error('Unknown method \"'+r.method+'\"');var o=e.apply(e,r.params);isPromise(o)?o.then(function(e){worker.send({id:r.id,result:e,error:null})})[\"catch\"](function(e){worker.send({id:r.id,result:null,error:serializerr(e)})}):worker.send({id:r.id,result:o,error:null})}catch(n){worker.send({id:r.id,result:null,error:serializerr(n)})}}),worker.register=function(r){if(r)for(var e in r)r.hasOwnProperty(e)&&(worker.methods[e]=r[e])},\"undefined\"!=typeof exports&&(exports.add=worker.register);"; - + module.exports = "!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p=\"\",r(0)}([function(module,exports,__webpack_require__){function isPromise(e){return e&&\"function\"==typeof e.then&&\"function\"==typeof e[\"catch\"]}var serializerr=__webpack_require__(1),worker={};if(\"undefined\"!=typeof self&&\"function\"==typeof postMessage&&\"function\"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if(\"undefined\"==typeof process)throw new Error(\"Script must be executed as a worker\");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval(\"(\"+fn+\")\");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on(\"message\",function(e){try{var r=worker.methods[e.method];if(!r)throw new Error('Unknown method \"'+e.method+'\"');var t=r.apply(r,e.params);isPromise(t)?t.then(function(r){worker.send({id:e.id,result:r,error:null})})[\"catch\"](function(r){worker.send({id:e.id,result:null,error:serializerr(r)})}):worker.send({id:e.id,result:t,error:null})}catch(n){worker.send({id:e.id,result:null,error:serializerr(n)})}}),worker.register=function(e){if(e)for(var r in e)e.hasOwnProperty(r)&&(worker.methods[r]=e[r])},exports.add=worker.register},function(e,r,t){\"use strict\";function n(e){return e&&e.__esModule?e:{\"default\":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=(0,u[\"default\"])(e).filter(function(e){return e!==Object.prototype});return[e].concat(r).map(function(e){return Object.getOwnPropertyNames(e)}).reduce(function(r,t){return t.forEach(function(t){return r[t]=e[t]}),r},{})}Object.defineProperty(r,\"__esModule\",{value:!0});var s=t(2),u=n(s);e.exports=o,o.serializerr=o,r[\"default\"]=o,e.exports=r[\"default\"]},function(e,r){\"use strict\";function t(e){for(var r=[],t=n(e);t;)r.push(t),t=n(t);return r}function n(e){return null==e?e:(o(e)&&(e=Object(e)),Object.getPrototypeOf(e))}function o(e){return null===e||\"object\"!=typeof e&&\"function\"!=typeof e}e.exports=t}]);"; -/***/ }, -/* 6 */ -/***/ function(module, exports) { - - module.exports = require("child_process"); /***/ }, /* 7 */ /***/ function(module, exports) { - module.exports = require("os"); + /** + * workerpool.js + * https://github.com/josdejong/workerpool + * + * Offload tasks to a pool of workers on node.js and in the browser. + * + * @version @@version + * @date @@date + * + * @license + * Copyright (C) 2014-2016 Jos de Jong + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + /***/ }, /* 8 */ @@ -956,7 +1016,7 @@ return /******/ (function(modules) { // webpackBootstrap * It listens for RPC messages from the parent process. */ - var serializerr = __webpack_require__(9) + var serializerr = __webpack_require__(9); // create a worker API for sending and receiving messages which works both on // node.js and in the browser diff --git a/dist/workerpool.map b/dist/workerpool.map index 93395ca8..fd454d21 100644 --- a/dist/workerpool.map +++ b/dist/workerpool.map @@ -1 +1 @@ -{"version":3,"sources":["./dist/workerpool.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_6__","__WEBPACK_EXTERNAL_MODULE_7__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","window","pool","script","options","Pool","worker","methods","environment","blob","Blob","type","url","URL","createObjectURL","importScripts","add","Promise","isNumber","maxWorkers","isInteger","TypeError","numCPUs","cpus","length","Math","max","workers","tasks","value","round","WorkerHandler","prototype","exec","method","params","Array","isArray","resolver","defer","push","_next","promise","String","proxy","arguments","Error","then","forEach","slice","_getWorker","me","task","shift","pending","terminated","_removeWorker","i","ii","busy","terminate","index","indexOf","splice","clear","force","handler","parent","SyntaxError","_onSuccess","_onFail","resolved","rejected","_process","onSuccess","onFail","resolve","reject","s","_then","f","_resolve","result","fn","_reject","error","cancel","CancellationError","timeout","delay","timer","setTimeout","TimeoutError","always","clearTimeout","callback","res","message","stack","all","promises","remaining","results","constructor","name","getDefaultWorker","__dirname","objectToError","obj","temp","props","Object","keys","onError","processing","hasOwnProperty","Worker","on","event","addEventListener","data","send","postMessage","fork","response","terminating","lastId","request","kill","isPromise","serializerr","self","process","bind","run","args","eval","apply","err","register","_interopRequireDefault","__esModule","default","undefined","chain","_protochain2","filter","concat","map","item","getOwnPropertyNames","reduce","names","defineProperty","_protochain","protochain","target","getPrototypeOf","isPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAyBA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,iBAAkBA,QAAQ,OAClC,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,gBAAiB,MAAOJ,GACN,gBAAZC,SACdA,QAAoB,WAAID,EAAQG,QAAQ,iBAAkBA,QAAQ,OAElEJ,EAAiB,WAAIC,EAAQD,EAAoB,cAAGA,EAAS,KAC5DO,KAAM,SAASC,8BAA+BC,+BACjD,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUV,OAGnC,IAAIC,GAASU,EAAiBD,IAC7BV,WACAY,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASS,GAG/DR,EAAOY,QAAS,EAGTZ,EAAOD,QAvBf,GAAIW,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASR,EAAQD,EAASS,GAEI,mBAAXS,OAOxBlB,GAAQmB,KAAO,SAAcC,EAAQC,GACnC,GAAIC,GAAOb,EAAoB,EAE/B,OAAO,IAAIa,GAAKF,EAAQC,IAO1BrB,EAAQuB,OAAS,QAASA,GAAOC,GAC/B,GAAIC,GAAchB,EAAoB,EACtC,IAAmB,WAAfgB,EAA0B,CAI5B,GAAIC,GAAO,GAAIC,OAAMlB,EAAoB,KAAMmB,KAAM,oBACjDC,EAAMX,OAAO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AwBA,UAAU,GAE3EmG,GAAQ,EAAIC,EAAa,YAAYrC,GAAKsC,OAAO,SAAUtC,GAC7D,MAAOA,KAAQG,OAAO/E,WAExB,QAAQ4E,GAAKuC,OAAOH,GAAOI,IAAI,SAAUC,GACvC,MAAOtC,QAAOuC,oBAAoBD,KACjCE,OAAO,SAAUrE,EAAQsE,GAI1B,MAHAA,GAAMxG,QAAQ,SAAUwD,GACtB,MAAOtB,GAAOsB,GAAQI,EAAIJ,KAErBtB,OAtBX6B,OAAO0C,eAAe1K,EAAS,cAC7B8C,OAAO,GAKT,IAAI6H,GAAclK,EAAoB,IAElCyJ,EAAeL,EAAuBc,EAkB1C1K,GAAOD,QAAUmJ,EACjBA,EAAYA,YAAcA,EAC1BnJ,EAAQ,WAAamJ,EACrBlJ,EAAOD,QAAUA,EAAQ,YAMpB,SAASC,EAAQD,GAEtB,YAIA,SAAS4K,GAAW/C,GAGlB,IAFA,GAAI1B,MACA0E,EAASC,EAAejD,GACrBgD,GACL1E,EAAO1C,KAAKoH,GACZA,EAASC,EAAeD,EAG1B,OAAO1E,GAGT,QAAS2E,GAAejD,GACtB,MAAW,OAAPA,EACKA,GACJkD,EAAYlD,KAAMA,EAAMG,OAAOH,IAC7BG,OAAO8C,eAAejD,IAG/B,QAASkD,GAAYT,GACnB,MAAgB,QAATA,GAAiC,gBAATA,IAAqC,kBAATA,GArB7DrK,EAAOD,QAAU4K","file":"workerpool.map"} \ No newline at end of file +{"version":3,"sources":["./dist/workerpool.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","window","pool","script","options","Pool","worker","methods","environment","blob","Blob","type","url","URL","createObjectURL","importScripts","add","Promise","isNumber","maxWorkers","isInteger","TypeError","numCPUs","node","require","cpus","length","Math","max","workers","tasks","value","round","WorkerHandler","prototype","exec","method","params","Array","isArray","resolver","defer","push","_next","promise","String","proxy","arguments","Error","then","forEach","slice","_getWorker","me","task","shift","pending","terminated","_removeWorker","i","ii","busy","terminate","index","indexOf","splice","clear","force","handler","parent","SyntaxError","_onSuccess","_onFail","resolved","rejected","_process","onSuccess","onFail","resolve","reject","s","_then","f","_resolve","result","fn","_reject","error","cancel","CancellationError","timeout","delay","timer","setTimeout","TimeoutError","always","clearTimeout","callback","res","message","stack","all","promises","remaining","results","constructor","name","getDefaultWorker","__dirname","objectToError","obj","temp","props","Object","keys","onError","processing","hasOwnProperty","Worker","on","event","addEventListener","data","send","postMessage","fork","response","terminating","lastId","request","kill","webpackContext","req","webpackContextResolve","map","./Pool","./Pool.js","./Promise","./Promise.js","./WorkerHandler","./WorkerHandler.js","./environment","./environment.js","./generated/embeddedWorker","./generated/embeddedWorker.js","./header","./header.js","./worker","./worker.js","isPromise","serializerr","self","process","bind","run","args","eval","apply","err","register","_interopRequireDefault","__esModule","default","undefined","chain","_protochain2","filter","concat","item","getOwnPropertyNames","reduce","names","defineProperty","_protochain","protochain","target","getPrototypeOf","isPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAyBA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,IACQ,kBAAXG,SAAyBA,OAAOC,IAC9CD,UAAWH,GACe,gBAAZC,SACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,KACpBK,KAAM,WACT,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUP,OAGnC,IAAIC,GAASO,EAAiBD,IAC7BP,WACAS,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOS,QAAS,EAGTT,EAAOD,QAvBf,GAAIQ,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASL,EAAQD,EAASM,GAEI,mBAA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1L,GAAOD,QAAUoK,EACjBA,EAAYA,YAAcA,EAC1BpK,EAAQ,WAAaoK,EACrBnK,EAAOD,QAAUA,EAAQ,YAMpB,SAASC,EAAQD,GAEtB,YAIA,SAAS4L,GAAWhE,GAGlB,IAFA,GAAI1B,MACA2F,EAASC,EAAelE,GACrBiE,GACL3F,EAAO1C,KAAKqI,GACZA,EAASC,EAAeD,EAG1B,OAAO3F,GAGT,QAAS4F,GAAelE,GACtB,MAAW,OAAPA,EACKA,GACJmE,EAAYnE,KAAMA,EAAMG,OAAOH,IAC7BG,OAAO+D,eAAelE,IAG/B,QAASmE,GAAYT,GACnB,MAAgB,QAATA,GAAiC,gBAATA,IAAqC,kBAATA,GArB7DrL,EAAOD,QAAU4L","file":"workerpool.map"} \ No newline at end of file diff --git a/dist/workerpool.min.js b/dist/workerpool.min.js index 808ad00b..70792bb2 100644 --- a/dist/workerpool.min.js +++ b/dist/workerpool.min.js @@ -4,11 +4,11 @@ * * Offload tasks to a pool of workers on node.js and in the browser. * - * @version 1.2.0 - * @date 2016-05-22 + * @version 1.2.1 + * @date 2016-06-25 * * @license - * Copyright (C) 2014 Jos de Jong + * Copyright (C) 2014-2016 Jos de Jong * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -22,6 +22,5 @@ * License for the specific language governing permissions and limitations under * the License. */ -!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("child_process"),require("os")):"function"==typeof define&&define.amd?define(["child_process","os"],e):"object"==typeof exports?exports.workerpool=e(require("child_process"),require("os")):r.workerpool=e(r.child_process,r.os)}(this,function(__WEBPACK_EXTERNAL_MODULE_6__,__WEBPACK_EXTERNAL_MODULE_7__){return function(r){function e(o){if(t[o])return t[o].exports;var n=t[o]={exports:{},id:o,loaded:!1};return r[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var t={};return e.m=r,e.c=t,e.p="",e(0)}([function(r,e,t){"undefined"!=typeof window;e.pool=function(r,e){var o=t(1);return new o(r,e)},e.worker=function o(r){var e=t(4);if("browser"==e){var n=new Blob([t(5)],{type:"text/javascript"}),i=window.URL.createObjectURL(n);importScripts(i)}else var o=t(8);o.add(r)},e.Promise=t(2)},function(r,e,t){function o(r,e){if("string"==typeof r?this.script=r||null:(this.script=null,e=r),e&&"maxWorkers"in e){if(!n(e.maxWorkers)||!i(e.maxWorkers)||e.maxWorkers<1)throw new TypeError("Option maxWorkers must be a positive integer number");this.maxWorkers=e.maxWorkers}else{var o=t(4),s="browser"==o?4:t(7).cpus().length;this.maxWorkers=Math.max(s-1,1)}this.workers=[],this.tasks=[]}function n(r){return"number"==typeof r}function i(r){return Math.round(r)==r}var s=t(2),c=t(3);o.prototype.exec=function(r,e){if(e&&!Array.isArray(e))throw new TypeError('Array expected as argument "params"');if("string"==typeof r){var t=s.defer();return this.tasks.push({method:r,params:e,resolver:t}),this._next(),t.promise}if("function"==typeof r)return this.exec("run",[String(r),e]);throw new TypeError('Function or string expected as argument "method"')},o.prototype.proxy=function(){if(arguments.length>0)throw new Error("No arguments expected");var r=this;return this.exec("methods").then(function(e){var t={};return e.forEach(function(e){t[e]=function(){return r.exec(e,Array.prototype.slice.call(arguments))}}),t})},o.prototype._next=function(){if(this.tasks.length>0){var r=this._getWorker();if(r){var e=this,t=this.tasks.shift();t.resolver.promise.pending&&r.exec(t.method,t.params,t.resolver).then(function(){e._next()})["catch"](function(){r.terminated&&e._removeWorker(r),e._next()})}}},o.prototype._getWorker=function(){for(var r=0,e=this.workers.length;e>r;r++){var t=this.workers[r];if(!t.busy())return t}return this.workers.length0},i.prototype.terminate=function(r){if(r){for(var e in this.processing)this.processing.hasOwnProperty(e)&&this.processing[e].resolver.reject(new Error("Worker terminated"));this.processing={}}if(this.busy())this.terminating=!0;else{if(this.worker){if("function"==typeof this.worker.kill)this.worker.kill();else{if("function"!=typeof this.worker.terminate)throw new Error("Failed to terminate worker");this.worker.terminate()}this.worker=null}this.terminating=!1,this.terminated=!0}},r.exports=i},function(r,e){r.exports="undefined"!=typeof window?"browser":"node"},function(r,e){r.exports='function isPromise(r){return r&&"function"==typeof r.then&&"function"==typeof r["catch"]}var serializerr=require("serializerr"),worker={};if("undefined"!=typeof self&&"function"==typeof postMessage&&"function"==typeof addEventListener)worker.on=function(r,e){addEventListener(r,function(r){e(r.data)})},worker.send=function(r){postMessage(r)};else{if("undefined"==typeof process)throw new Error("Script must be executed as a worker");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval("("+fn+")");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on("message",function(r){try{var e=worker.methods[r.method];if(!e)throw new Error(\'Unknown method "\'+r.method+\'"\');var o=e.apply(e,r.params);isPromise(o)?o.then(function(e){worker.send({id:r.id,result:e,error:null})})["catch"](function(e){worker.send({id:r.id,result:null,error:serializerr(e)})}):worker.send({id:r.id,result:o,error:null})}catch(n){worker.send({id:r.id,result:null,error:serializerr(n)})}}),worker.register=function(r){if(r)for(var e in r)r.hasOwnProperty(e)&&(worker.methods[e]=r[e])},"undefined"!=typeof exports&&(exports.add=worker.register);'},function(r,e){r.exports=require("child_process")},function(r,e){r.exports=require("os")},function(module,exports,__webpack_require__){function isPromise(r){return r&&"function"==typeof r.then&&"function"==typeof r["catch"]}var serializerr=__webpack_require__(9),worker={};if("undefined"!=typeof self&&"function"==typeof postMessage&&"function"==typeof addEventListener)worker.on=function(r,e){addEventListener(r,function(r){e(r.data)})},worker.send=function(r){postMessage(r)};else{if("undefined"==typeof process)throw new Error("Script must be executed as a worker");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval("("+fn+")");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on("message",function(r){try{var e=worker.methods[r.method];if(!e)throw new Error('Unknown method "'+r.method+'"');var t=e.apply(e,r.params);isPromise(t)?t.then(function(e){worker.send({id:r.id,result:e,error:null})})["catch"](function(e){worker.send({id:r.id,result:null,error:serializerr(e)})}):worker.send({id:r.id,result:t,error:null})}catch(o){worker.send({id:r.id,result:null,error:serializerr(o)})}}),worker.register=function(r){if(r)for(var e in r)r.hasOwnProperty(e)&&(worker.methods[e]=r[e])},exports.add=worker.register},function(r,e,t){"use strict";function o(r){return r&&r.__esModule?r:{"default":r}}function n(){var r=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=(0,s["default"])(r).filter(function(r){return r!==Object.prototype});return[r].concat(e).map(function(r){return Object.getOwnPropertyNames(r)}).reduce(function(e,t){return t.forEach(function(t){return e[t]=r[t]}),e},{})}Object.defineProperty(e,"__esModule",{value:!0});var i=t(10),s=o(i);r.exports=n,n.serializerr=n,e["default"]=n,r.exports=e["default"]},function(r,e){"use strict";function t(r){for(var e=[],t=o(r);t;)e.push(t),t=o(t);return e}function o(r){return null==r?r:(n(r)&&(r=Object(r)),Object.getPrototypeOf(r))}function n(r){return null===r||"object"!=typeof r&&"function"!=typeof r}r.exports=t}])}); -//# sourceMappingURL=workerpool.map +!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.workerpool=r():e.workerpool=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"undefined"!=typeof window;r.pool=function(e,r){var n=t(1);return new n(e,r)},r.worker=function n(e){var r=t(4);if("browser"==r){var o=new Blob([t(6)],{type:"text/javascript"}),i=window.URL.createObjectURL(o);importScripts(i)}else var n=t(8);n.add(e)},r.Promise=t(2)},function(e,r,t){function n(e,r){if("string"==typeof e?this.script=e||null:(this.script=null,r=e),r&&"maxWorkers"in r){if(!o(r.maxWorkers)||!i(r.maxWorkers)||r.maxWorkers<1)throw new TypeError("Option maxWorkers must be a positive integer number");this.maxWorkers=r.maxWorkers}else{var n=t(4),s="browser"==n?4:c.require("os").cpus().length;this.maxWorkers=Math.max(s-1,1)}this.workers=[],this.tasks=[]}function o(e){return"number"==typeof e}function i(e){return Math.round(e)==e}var s=t(2),u=t(3),c={require:t(5)};n.prototype.exec=function(e,r){if(r&&!Array.isArray(r))throw new TypeError('Array expected as argument "params"');if("string"==typeof e){var t=s.defer();return this.tasks.push({method:e,params:r,resolver:t}),this._next(),t.promise}if("function"==typeof e)return this.exec("run",[String(e),r]);throw new TypeError('Function or string expected as argument "method"')},n.prototype.proxy=function(){if(arguments.length>0)throw new Error("No arguments expected");var e=this;return this.exec("methods").then(function(r){var t={};return r.forEach(function(r){t[r]=function(){return e.exec(r,Array.prototype.slice.call(arguments))}}),t})},n.prototype._next=function(){if(this.tasks.length>0){var e=this._getWorker();if(e){var r=this,t=this.tasks.shift();t.resolver.promise.pending&&e.exec(t.method,t.params,t.resolver).then(function(){r._next()})["catch"](function(){e.terminated&&r._removeWorker(e),r._next()})}}},n.prototype._getWorker=function(){for(var e=0,r=this.workers.length;r>e;e++){var t=this.workers[e];if(!t.busy())return t}return this.workers.length0},i.prototype.terminate=function(e){if(e){for(var r in this.processing)this.processing.hasOwnProperty(r)&&this.processing[r].resolver.reject(new Error("Worker terminated"));this.processing={}}if(this.busy())this.terminating=!0;else{if(this.worker){if("function"==typeof this.worker.kill)this.worker.kill();else{if("function"!=typeof this.worker.terminate)throw new Error("Failed to terminate worker");this.worker.terminate()}this.worker=null}this.terminating=!1,this.terminated=!0}},e.exports=i},function(e,r){e.exports="undefined"!=typeof window?"browser":"node"},function(e,r,t){function n(e){return t(o(e))}function o(e){return i[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var i={"./Pool":1,"./Pool.js":1,"./Promise":2,"./Promise.js":2,"./WorkerHandler":3,"./WorkerHandler.js":3,"./environment":4,"./environment.js":4,"./generated/embeddedWorker":6,"./generated/embeddedWorker.js":6,"./header":7,"./header.js":7,"./worker":8,"./worker.js":8};n.keys=function(){return Object.keys(i)},n.resolve=o,e.exports=n,n.id=5},function(e,r){e.exports='!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(module,exports,__webpack_require__){function isPromise(e){return e&&"function"==typeof e.then&&"function"==typeof e["catch"]}var serializerr=__webpack_require__(1),worker={};if("undefined"!=typeof self&&"function"==typeof postMessage&&"function"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if("undefined"==typeof process)throw new Error("Script must be executed as a worker");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval("("+fn+")");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on("message",function(e){try{var r=worker.methods[e.method];if(!r)throw new Error(\'Unknown method "\'+e.method+\'"\');var t=r.apply(r,e.params);isPromise(t)?t.then(function(r){worker.send({id:e.id,result:r,error:null})})["catch"](function(r){worker.send({id:e.id,result:null,error:serializerr(r)})}):worker.send({id:e.id,result:t,error:null})}catch(n){worker.send({id:e.id,result:null,error:serializerr(n)})}}),worker.register=function(e){if(e)for(var r in e)e.hasOwnProperty(r)&&(worker.methods[r]=e[r])},exports.add=worker.register},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=(0,u["default"])(e).filter(function(e){return e!==Object.prototype});return[e].concat(r).map(function(e){return Object.getOwnPropertyNames(e)}).reduce(function(r,t){return t.forEach(function(t){return r[t]=e[t]}),r},{})}Object.defineProperty(r,"__esModule",{value:!0});var s=t(2),u=n(s);e.exports=o,o.serializerr=o,r["default"]=o,e.exports=r["default"]},function(e,r){"use strict";function t(e){for(var r=[],t=n(e);t;)r.push(t),t=n(t);return r}function n(e){return null==e?e:(o(e)&&(e=Object(e)),Object.getPrototypeOf(e))}function o(e){return null===e||"object"!=typeof e&&"function"!=typeof e}e.exports=t}]);'},function(e,r){},function(module,exports,__webpack_require__){function isPromise(e){return e&&"function"==typeof e.then&&"function"==typeof e["catch"]}var serializerr=__webpack_require__(9),worker={};if("undefined"!=typeof self&&"function"==typeof postMessage&&"function"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if("undefined"==typeof process)throw new Error("Script must be executed as a worker");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval("("+fn+")");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on("message",function(e){try{var r=worker.methods[e.method];if(!r)throw new Error('Unknown method "'+e.method+'"');var t=r.apply(r,e.params);isPromise(t)?t.then(function(r){worker.send({id:e.id,result:r,error:null})})["catch"](function(r){worker.send({id:e.id,result:null,error:serializerr(r)})}):worker.send({id:e.id,result:t,error:null})}catch(n){worker.send({id:e.id,result:null,error:serializerr(n)})}}),worker.register=function(e){if(e)for(var r in e)e.hasOwnProperty(r)&&(worker.methods[r]=e[r])},exports.add=worker.register},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=(0,s["default"])(e).filter(function(e){return e!==Object.prototype});return[e].concat(r).map(function(e){return Object.getOwnPropertyNames(e)}).reduce(function(r,t){return t.forEach(function(t){return r[t]=e[t]}),r},{})}Object.defineProperty(r,"__esModule",{value:!0});var i=t(10),s=n(i);e.exports=o,o.serializerr=o,r["default"]=o,e.exports=r["default"]},function(e,r){"use strict";function t(e){for(var r=[],t=n(e);t;)r.push(t),t=n(t);return r}function n(e){return null==e?e:(o(e)&&(e=Object(e)),Object.getPrototypeOf(e))}function o(e){return null===e||"object"!=typeof e&&"function"!=typeof e}e.exports=t}])}); //# sourceMappingURL=workerpool.map \ No newline at end of file diff --git a/lib/generated/embeddedWorker.js b/lib/generated/embeddedWorker.js index b72f2d25..4e81d219 100644 --- a/lib/generated/embeddedWorker.js +++ b/lib/generated/embeddedWorker.js @@ -3,4 +3,4 @@ * This file is automatically generated, * changes made in this file will be overwritten. */ -module.exports = "function isPromise(r){return r&&\"function\"==typeof r.then&&\"function\"==typeof r[\"catch\"]}var serializerr=require(\"serializerr\"),worker={};if(\"undefined\"!=typeof self&&\"function\"==typeof postMessage&&\"function\"==typeof addEventListener)worker.on=function(r,e){addEventListener(r,function(r){e(r.data)})},worker.send=function(r){postMessage(r)};else{if(\"undefined\"==typeof process)throw new Error(\"Script must be executed as a worker\");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval(\"(\"+fn+\")\");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on(\"message\",function(r){try{var e=worker.methods[r.method];if(!e)throw new Error('Unknown method \"'+r.method+'\"');var o=e.apply(e,r.params);isPromise(o)?o.then(function(e){worker.send({id:r.id,result:e,error:null})})[\"catch\"](function(e){worker.send({id:r.id,result:null,error:serializerr(e)})}):worker.send({id:r.id,result:o,error:null})}catch(n){worker.send({id:r.id,result:null,error:serializerr(n)})}}),worker.register=function(r){if(r)for(var e in r)r.hasOwnProperty(e)&&(worker.methods[e]=r[e])},\"undefined\"!=typeof exports&&(exports.add=worker.register);"; +module.exports = "!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p=\"\",r(0)}([function(module,exports,__webpack_require__){function isPromise(e){return e&&\"function\"==typeof e.then&&\"function\"==typeof e[\"catch\"]}var serializerr=__webpack_require__(1),worker={};if(\"undefined\"!=typeof self&&\"function\"==typeof postMessage&&\"function\"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if(\"undefined\"==typeof process)throw new Error(\"Script must be executed as a worker\");worker.on=process.on.bind(process),worker.send=process.send.bind(process)}worker.methods={},worker.methods.run=function run(fn,args){var f=eval(\"(\"+fn+\")\");return f.apply(f,args)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.on(\"message\",function(e){try{var r=worker.methods[e.method];if(!r)throw new Error('Unknown method \"'+e.method+'\"');var t=r.apply(r,e.params);isPromise(t)?t.then(function(r){worker.send({id:e.id,result:r,error:null})})[\"catch\"](function(r){worker.send({id:e.id,result:null,error:serializerr(r)})}):worker.send({id:e.id,result:t,error:null})}catch(n){worker.send({id:e.id,result:null,error:serializerr(n)})}}),worker.register=function(e){if(e)for(var r in e)e.hasOwnProperty(r)&&(worker.methods[r]=e[r])},exports.add=worker.register},function(e,r,t){\"use strict\";function n(e){return e&&e.__esModule?e:{\"default\":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=(0,u[\"default\"])(e).filter(function(e){return e!==Object.prototype});return[e].concat(r).map(function(e){return Object.getOwnPropertyNames(e)}).reduce(function(r,t){return t.forEach(function(t){return r[t]=e[t]}),r},{})}Object.defineProperty(r,\"__esModule\",{value:!0});var s=t(2),u=n(s);e.exports=o,o.serializerr=o,r[\"default\"]=o,e.exports=r[\"default\"]},function(e,r){\"use strict\";function t(e){for(var r=[],t=n(e);t;)r.push(t),t=n(t);return r}function n(e){return null==e?e:(o(e)&&(e=Object(e)),Object.getPrototypeOf(e))}function o(e){return null===e||\"object\"!=typeof e&&\"function\"!=typeof e}e.exports=t}]);"; diff --git a/package.json b/package.json index 11cb7641..78704e44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "workerpool", - "version": "1.2.0", + "version": "1.2.1", "description": "Offload tasks to a pool of workers on node.js and in the browser", "homepage": "https://github.com/josdejong/workerpool", "author": "Jos de Jong (https://github.com/josdejong)", @@ -23,7 +23,6 @@ "coverage": "istanbul cover _mocha -- test; echo \"\nCoverage report is available at ./coverage/lcov-report/index.html\"" }, "dependencies": { - "promise": "^5.0.0", "serializerr": "^1.0.2" }, "devDependencies": {