Skip to content

Instantly share code, notes, and snippets.

@rubystream
Last active May 30, 2018 19:32
Show Gist options
  • Save rubystream/202176bcf2e2679196fbbf701375c464 to your computer and use it in GitHub Desktop.
Save rubystream/202176bcf2e2679196fbbf701375c464 to your computer and use it in GitHub Desktop.
Promise.all reduce
Promise.all(objectsToProcess.reduce((sum, item) => {
if (item && item.shouldProcess) {
sum.push(asyncFunction(item));
}
return sum;
}, []))
.then(values => { console.log(values); })
.catch(reason => { console.log(reason); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment