Skip to content

Instantly share code, notes, and snippets.

@petele
Last active June 13, 2017 20:53
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 petele/231ff8e6e9994872d282b8f61a231ab8 to your computer and use it in GitHub Desktop.
Save petele/231ff8e6e9994872d282b8f61a231ab8 to your computer and use it in GitHub Desktop.
Promise.every
Promise.resolveAll = function petepete(promises) {
function reflect(promise) {
if (Promise.resolve(promise) !== promise) {
return promise;
}
return promise.then((v) => {return v;}).catch((e) => {return e;});
}
return Promise.all(promises.map(reflect));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment