-
-
Save davidbarral/d0d4da70fa9e6f615595d01f54276e0b 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
if (!Promise.allSettled) { | |
Promise.allSettled = promises => | |
Promise.all( | |
promises.map((promise, i) => | |
promise | |
.then(value => ({ | |
status: "fulfilled", | |
value, | |
})) | |
.catch(reason => ({ | |
status: "rejected", | |
reason, | |
})) | |
) | |
); | |
} | |
Promise.allSettled(promises).then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
p
in the first line should be capitalized