Skip to content

Instantly share code, notes, and snippets.

@slikts
Last active June 2, 2018 10:45
Show Gist options
  • Save slikts/6029477fe2c3215b9bc49510f30a434a to your computer and use it in GitHub Desktop.
Save slikts/6029477fe2c3215b9bc49510f30a434a to your computer and use it in GitHub Desktop.
Promise.settle()
const settle = ps =>
Promise.all(
ps.map(async p => {
let [value, error, ok] = [null, null, false];
try {
value = await p;
ok = true;
} catch (e) {
error = e;
}
return { value, error, ok };
}),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment