diff options
Diffstat (limited to 'build/es/internal/map.js')
-rw-r--r-- | build/es/internal/map.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/build/es/internal/map.js b/build/es/internal/map.js new file mode 100644 index 0000000..5057f49 --- /dev/null +++ b/build/es/internal/map.js @@ -0,0 +1,19 @@ +'use strict'; + +import isArrayLike from 'lodash-es/isArrayLike'; +import noop from 'lodash-es/noop'; +import once from 'lodash-es/once'; + +export default function _asyncMap(eachfn, arr, iterator, callback) { + callback = once(callback || noop); + arr = arr || []; + var results = isArrayLike(arr) ? [] : {}; + eachfn(arr, function (value, index, callback) { + iterator(value, function (err, v) { + results[index] = v; + callback(err); + }); + }, function (err) { + callback(err, results); + }); +} |