Last active
June 13, 2017 20:53
-
-
Save petele/231ff8e6e9994872d282b8f61a231ab8 to your computer and use it in GitHub Desktop.
Promise.every
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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