Skip to content

Instantly share code, notes, and snippets.

@ghiden
Last active February 9, 2017 21:34
Show Gist options
  • Save ghiden/e6b45da7d5434c1edc814aca47a7bb12 to your computer and use it in GitHub Desktop.
Save ghiden/e6b45da7d5434c1edc814aca47a7bb12 to your computer and use it in GitHub Desktop.
A utility function to wait all promises to settle
/*
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