diff options
Diffstat (limited to 'dist/async.js')
-rw-r--r-- | dist/async.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/dist/async.js b/dist/async.js index a0652f3..f3cfb80 100644 --- a/dist/async.js +++ b/dist/async.js @@ -224,22 +224,22 @@ async.forEachOf = async.eachOf = function (object, iterator, callback) { callback = _once(callback || noop); - - var nextKey = _keyIterator(obj); - var key, running = 0; - while ((key = nextKey()) != null) { - running += 1; - iterator(object[key], key, only_once(done)); - } - if (!running) { - callback (null); + object = object || []; + var size = _isArrayLike(object) ? object.length : _keys(object).length; + var completed = 0; + if (!size) { + return callback(null); } + _each(object, function (value, key) { + iterator(object[key], key, only_once(done)); + }); function done(err) { if (err) { callback(err); } else { - if (--running) { + completed += 1; + if (completed >= size) { callback(null); } } |