summaryrefslogtreecommitdiff
path: root/lib/internal/map.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/map.js')
-rw-r--r--lib/internal/map.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/internal/map.js b/lib/internal/map.js
index 45c3eae..b587f59 100644
--- a/lib/internal/map.js
+++ b/lib/internal/map.js
@@ -1,15 +1,23 @@
import isArrayLike from 'lodash/isArrayLike';
import getIterator from './getIterator';
import noop from 'lodash/noop';
+import okeys from 'lodash/keys';
+import indexOf from 'lodash/_baseIndexOf';
import once from './once';
export default function _asyncMap(eachfn, arr, iteratee, callback) {
callback = once(callback || noop);
arr = arr || [];
- var results = isArrayLike(arr) || getIterator(arr) ? [] : {};
+ var results = [];
+ var keys;
+ if (!isArrayLike(arr) && !getIterator(arr)) {
+ keys = okeys(arr);
+ }
+
eachfn(arr, function (value, index, callback) {
iteratee(value, function (err, v) {
- results[index] = v;
+ var idx = keys ? indexOf(keys, index, 0) : index;
+ results[idx] = v;
callback(err);
});
}, function (err) {