Even with async/await, raw promises are still key to writing optimal concurrent javascript
Daniel Brain
58330

Hey Daniel and thank you for an interesting article!

This may be a newbie question but why are you not leveraging the promise from the function itself? So, instead of writing:

let promise = Promise.resolve();

for (let item of collection) {
promise = promise.then(() => fn(item))
.then(result => results.push(result));
}

You could skip the part where you create a new resolved Promise and do:

 for (let item of collection) {
promise = fn(item).then(result => results.push(result));
}
A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.