fastparallel
Advanced tools
Comparing version 1.6.0 to 1.6.1
{ | ||
"name": "fastparallel", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Zero-overhead asynchronous parallel/each/map function call", | ||
@@ -5,0 +5,0 @@ "main": "parallel.js", |
@@ -97,3 +97,3 @@ var xtend = require('xtend') | ||
this.release = function (err, result) { | ||
that._err = err | ||
that._err = that._err || err | ||
that._results[i] = result | ||
@@ -100,0 +100,0 @@ if (++i >= that._count) { // handles an empty list |
35
test.js
@@ -70,3 +70,3 @@ var test = require('tape') | ||
instance(obj, [somethingErr, something], 42, function done (err, results) { | ||
t.error(err) | ||
t.ok(err) | ||
t.equal(count, 2, 'all functions must have completed') | ||
@@ -94,2 +94,35 @@ }) | ||
test('fowards errs (bis)', function (t) { | ||
t.plan(3) | ||
var instance = parallel({ | ||
released: released | ||
}) | ||
var count = 0 | ||
var obj = {} | ||
instance(obj, [something, somethingErr], 42, function done (err, results) { | ||
t.ok(err) | ||
t.equal(count, 2, 'all functions must have completed') | ||
}) | ||
function something (arg, cb) { | ||
setImmediate(function () { | ||
count++ | ||
cb(null, count) | ||
}) | ||
} | ||
function somethingErr (arg, cb) { | ||
setImmediate(function () { | ||
count++ | ||
cb(new Error('this is an err!')) | ||
}) | ||
} | ||
function released () { | ||
t.pass() | ||
} | ||
}) | ||
test('does not forward errors or result with results:false flag', function (t) { | ||
@@ -96,0 +129,0 @@ t.plan(8) |
15975
431