Created
February 27, 2023 13:36
-
-
Save scarf005/2a22c5a172e19b02cd23a4235e9805ff to your computer and use it in GitHub Desktop.
extract only successful values out of Promise.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
function successes<T>(xs: PromiseSettledResult<T>[]): T[] { | |
return xs | |
.filter((x): x is PromiseFulfilledResult<T> => x.status === "fulfilled") | |
.map((x) => x.value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment