Last active
February 9, 2017 21:34
-
-
Save ghiden/e6b45da7d5434c1edc814aca47a7bb12 to your computer and use it in GitHub Desktop.
A utility function to wait all promises to settle
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.all(arr.map(reflect)).then(function(results){ | |
var success = results.filter(x => x.status === "resolved"); | |
}); | |
*/ | |
module.exports = function reflect(promise){ | |
return promise.then(v => ({v:v, status: "resolved"}), e => ({e:e, status: "rejected"})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment