Created
October 11, 2017 14:17
-
-
Save vatson/f7aac8089a69b04ab2041975fe6d2192 to your computer and use it in GitHub Desktop.
allsettled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const allSettled = (promises) => { | |
return Promise.all( | |
promises.map( | |
(promise) => { | |
const res = (value) => { | |
return { state: 'resolved', value: value } | |
} | |
const rej = (reason) => { | |
return { state: 'rejected', reason: reason } | |
} | |
return promise.then(res, rej) | |
}) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment