Skip to content

Instantly share code, notes, and snippets.

@scarf005
Created February 27, 2023 13:36
Show Gist options
  • Save scarf005/2a22c5a172e19b02cd23a4235e9805ff to your computer and use it in GitHub Desktop.
Save scarf005/2a22c5a172e19b02cd23a4235e9805ff to your computer and use it in GitHub Desktop.
extract only successful values out of Promise.allSettled
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