fastparallel
Advanced tools
Comparing version 1.5.1 to 1.5.2
{ | ||
"name": "fastparallel", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Zero-overhead asynchronous parallel/each/map function call", | ||
@@ -5,0 +5,0 @@ "main": "parallel.js", |
@@ -52,2 +52,6 @@ var xtend = require('xtend') | ||
} | ||
if (holder._count === 0) { | ||
holder.release() | ||
} | ||
} | ||
@@ -73,3 +77,3 @@ } | ||
if (that._count === 0) { | ||
if (that._count <= 0) { // handles an empty list | ||
that._callback.call(that._callThat) | ||
@@ -96,3 +100,3 @@ that._callback = nop | ||
that._results[i] = result | ||
if (++i === that._count) { | ||
if (++i >= that._count) { // handles an empty list | ||
that._callback.call(that._callThat, that._err, that._results) | ||
@@ -99,0 +103,0 @@ that._callback = nop |
30
test.js
@@ -213,1 +213,31 @@ var test = require('tape') | ||
}) | ||
test('call the result callback when the each array is empty', function (t) { | ||
t.plan(1) | ||
var instance = parallel() | ||
var obj = {} | ||
instance(obj, something, [], function done () { | ||
t.pass('the result function has been called') | ||
}) | ||
function something (arg, cb) { | ||
t.error('this should never be called') | ||
} | ||
}) | ||
test('call the result callback when the each array is empty with no results', function (t) { | ||
t.plan(1) | ||
var instance = parallel({ results: false }) | ||
var obj = {} | ||
instance(obj, something, [], function done () { | ||
t.pass('the result function has been called') | ||
}) | ||
function something (arg, cb) { | ||
t.error('this should never be called') | ||
} | ||
}) |
14364
397