Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created December 7, 2017 11:29
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 apaleslimghost/8af53e7fac9306959b3769f9ddaf8cbc to your computer and use it in GitHub Desktop.
Save apaleslimghost/8af53e7fac9306959b3769f9ddaf8cbc to your computer and use it in GitHub Desktop.
module.exports = promises => {
const rejected = [];
return Promise.all(
Array.from(
promises,
(promise, i) => promise.catch(err => rejected[i] = err)
)
).then(
() => rejected.filter(e => e).length === promises.length
&& Promise.reject(rejected)
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment