feat(utils/asyncMap): collection can be a promise
This commit is contained in:
parent
dd5c32f889
commit
084650e8ba
@ -28,6 +28,7 @@ import {
|
||||
all as pAll,
|
||||
defer,
|
||||
fromCallback,
|
||||
isPromise,
|
||||
promisify,
|
||||
reflect as pReflect
|
||||
} from 'promise-toolbox'
|
||||
@ -41,6 +42,10 @@ import {
|
||||
// Similar to map() + Promise.all() but wait for all promises to
|
||||
// settle before rejecting (with the first error)
|
||||
export const asyncMap = (collection, iteratee) => {
|
||||
if (isPromise(collection)) {
|
||||
return collection.then(collection => asyncMap(collection, iteratee))
|
||||
}
|
||||
|
||||
let errorContainer
|
||||
const onError = error => {
|
||||
if (errorContainer === undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user