blob: 092f76d715da9798c943c110aa3c73799c534d44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import wrapAsync from './wrapAsync';
export default function _asyncMap(eachfn, arr, iteratee, callback) {
arr = arr || [];
var results = [];
var counter = 0;
var _iteratee = wrapAsync(iteratee);
return eachfn(arr, (value, _, iterCb) => {
var index = counter++;
_iteratee(value, (err, v) => {
results[index] = v;
iterCb(err);
});
}, err => {
callback(err, results);
});
}
|