Created
March 16, 2018 22:08
-
-
Save idmontie/a143e3a29151151b7b700df9bb6cdc1b to your computer and use it in GitHub Desktop.
Like Promise.all, but it doesn't fail if one of the promises fails.
This file contains 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
function settled(promises) { | |
const alwaysFulfilled = promises.map((p) => { | |
return p.then((value) => { | |
return { state: 'fulfilled', value: value }; | |
}, (reason) => { | |
return { state: 'rejected', reason: reason }; | |
}); | |
}); | |
return Promise.all(alwaysFulfilled); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment