Comparing version 5.8.0 to 5.9.0
@@ -9,3 +9,3 @@ "use strict"; | ||
var process = async function() { | ||
await pickworker(); | ||
await pickworker('push'); | ||
var ret = await thunk.apply(this, arguments); | ||
@@ -16,5 +16,12 @@ freeworker(); | ||
var pickworker = function () { | ||
var unshift = async function() { | ||
await pickworker('unshift'); | ||
var ret = await thunk.apply(this, arguments); | ||
freeworker(); | ||
return ret; | ||
}; | ||
var pickworker = function (way) { | ||
if(!slots) //no available worker, waiting | ||
return new Promise(resolve => workerChain.push(resolve)); | ||
return new Promise(resolve => workerChain[way](resolve)); | ||
@@ -27,3 +34,3 @@ return Promise.resolve(slots--); //worker id | ||
if(workerChain.length) | ||
workerChain.shift()(pickworker()); | ||
workerChain.shift()(pickworker('push')); | ||
else if(slots == workers && process.drain) | ||
@@ -33,4 +40,5 @@ process.drain(); | ||
var out = process; // better candidate than {} | ||
out.push = process; // per compatibility | ||
var out = process; // better candidate than {} | ||
out.push = process; // per compatibility | ||
out.unshift = unshift; // per compatibility | ||
//out.getLength = () => { workerChain.length; }; | ||
@@ -37,0 +45,0 @@ //out.filter = (cb) => { workerChain = workerChain.filter(cb); }; |
{ | ||
"name": "nyks", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "nodejs exupery style", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64676
1665