blob: 959138d1a71c361efded962dc44c7308112fdff2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
'use strict';
import isArrayLike from 'lodash/isArrayLike';
import getIterator from './getIterator';
import noop from 'lodash/noop';
import once from './once';
export default function _asyncMap(eachfn, arr, iteratee, callback) {
callback = once(callback || noop);
arr = arr || [];
var results = isArrayLike(arr) || getIterator(arr) ? [] : {};
eachfn(arr, function (value, index, callback) {
iteratee(value, function (err, v) {
results[index] = v;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
|