Created
September 7, 2020 08:02
-
-
Save jastisriradheshyam/ac9c9b6ada1477bbf85f32e1e9c82214 to your computer and use it in GitHub Desktop.
allSettled polyfill
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
Promise.allSettled = function (promises) { | |
const mappedPromises = promises.map(promise => ( | |
promise | |
.then(value => ({ status: 'fulfilled', value })) | |
.catch(reason => ({ status: 'rejected', reason })) | |
)); | |
return Promise.all(mappedPromises); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment