Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
codefined
8y ago
0 comments
Share
let accumulator = 0 for (let item of array) { const value = await item // your code here }
Is identical, doesn't use 'cool' reduce features but is much easier to read in my opinion.
0 comments
default
newest
oldest
todd3834
8y ago
Wouldn’t this code only execute 1 promise at a time? I thought Promise.all allowed promises to be resolved in parallel
theprotocol
8y ago
Indeed. You most likely should do `await Promise.all` and then do the reduction.
dvlsg
8y ago
If item is already a promise, and not a function returning a promise, they would be "executing" in parallel.
codefined
OP
8y ago
Sorry, in the sense of being identical to the original code in the linked post (reduce), not the comment.
j
/
k
navigate · click thread line to collapse