summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/async.js3
-rwxr-xr-xtest/test-async.js1
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/async.js b/lib/async.js
index 9c2b6af..208e602 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -353,7 +353,8 @@
function _asyncMap(eachfn, arr, iterator, callback) {
callback = _once(callback || noop);
- var results = [];
+ arr = arr || [];
+ var results = _isArrayLike(arr) ? [] : {};
eachfn(arr, function (value, index, callback) {
iterator(value, function (err, v) {
results[index] = v;
diff --git a/test/test-async.js b/test/test-async.js
index dc7d949..23aa2b9 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -1810,6 +1810,7 @@ exports['map'] = {
callback(null, val * 2);
}, function (err, result) {
if (err) throw err;
+ test.equals(Object.prototype.toString.call(result), '[object Object]');
test.same(result, {a: 2, b: 4, c: 6});
test.done();
});