Skip to content

Instantly share code, notes, and snippets.

@jastisriradheshyam
Created September 7, 2020 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jastisriradheshyam/ac9c9b6ada1477bbf85f32e1e9c82214 to your computer and use it in GitHub Desktop.
Save jastisriradheshyam/ac9c9b6ada1477bbf85f32e1e9c82214 to your computer and use it in GitHub Desktop.
allSettled polyfill
Promise.allSettled = function (promises) {
const mappedPromises = promises.map(promise => (
promise
.then(value => ({ status: 'fulfilled', value }))
.catch(reason => ({ status: 'rejected', reason }))
));
return Promise.all(mappedPromises);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment