run-parallel
Advanced tools
Comparing version 1.1.2 to 1.1.3
28
index.js
@@ -1,6 +0,5 @@ | ||
var dezalgo = require('dezalgo') | ||
module.exports = function (tasks, cb) { | ||
if (cb) cb = dezalgo(cb) | ||
var results, pending, keys | ||
var isSync = true | ||
if (Array.isArray(tasks)) { | ||
@@ -15,18 +14,25 @@ results = [] | ||
function done (i, err, result) { | ||
results[i] = result | ||
if (--pending === 0 || err) { | ||
function done (err, results) { | ||
function end () { | ||
if (cb) cb(err, results) | ||
cb = null | ||
} | ||
if (isSync) process.nextTick(end) | ||
else end() | ||
} | ||
function each (i, err, result) { | ||
results[i] = result | ||
if (--pending === 0 || err) { | ||
done(err, results) | ||
} | ||
} | ||
if (!pending) { | ||
// empty | ||
if (cb) cb(null, results) | ||
cb = null | ||
done(null, results) | ||
} else if (keys) { | ||
// object | ||
keys.forEach(function (key) { | ||
tasks[key](done.bind(undefined, key)) | ||
tasks[key](each.bind(undefined, key)) | ||
}) | ||
@@ -36,5 +42,7 @@ } else { | ||
tasks.forEach(function (task, i) { | ||
task(done.bind(undefined, i)) | ||
task(each.bind(undefined, i)) | ||
}) | ||
} | ||
isSync = false | ||
} |
{ | ||
"name": "run-parallel", | ||
"description": "Run an array of functions in parallel", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"author": { | ||
@@ -13,5 +13,3 @@ "name": "Feross Aboukhadijeh", | ||
}, | ||
"dependencies": { | ||
"dezalgo": "^1.0.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -18,0 +16,0 @@ "standard": "^4.3.2", |
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
12672
0
262
- Removeddezalgo@^1.0.1
- Removedasap@2.0.6(transitive)
- Removeddezalgo@1.0.4(transitive)
- Removedwrappy@1.0.2(transitive)