Skip to content

Instantly share code, notes, and snippets.

@idmontie
Created March 16, 2018 22:08
Show Gist options
  • Save idmontie/a143e3a29151151b7b700df9bb6cdc1b to your computer and use it in GitHub Desktop.
Save idmontie/a143e3a29151151b7b700df9bb6cdc1b to your computer and use it in GitHub Desktop.
Like Promise.all, but it doesn't fail if one of the promises fails.
function settled(promises) {
const alwaysFulfilled = promises.map((p) => {
return p.then((value) => {
return { state: 'fulfilled', value: value };
}, (reason) => {
return { state: 'rejected', reason: reason };
});
});
return Promise.all(alwaysFulfilled);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment