Skip to content

Instantly share code, notes, and snippets.

@vatson
Created October 11, 2017 14:17
Show Gist options
  • Save vatson/f7aac8089a69b04ab2041975fe6d2192 to your computer and use it in GitHub Desktop.
Save vatson/f7aac8089a69b04ab2041975fe6d2192 to your computer and use it in GitHub Desktop.
allsettled
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