Published at
Updated at
Reading time
1min

How often do you map over an array to "promisify it" to then use it with Promise.all? I do that all the time! It took me until now to realize that using Promise.all annoys me.

There should be a quicker way baked into JavaScript to handle sets of promises! Today, I learned that the "await.ops" proposal aims to make us type less Promise. code by providing methods such as await.all and await.race. That's exciting!

// before – So! Much! Typing!
await Promise.all(users.map(async x => fetchProfile(x.id)))

// after – much better!
await.all users.map(async x => fetchProfile(x.id))

Let's hope the proposal makes it through the ECMAscript process (it's on stage 1 right now), because await.all will be one of my favorite JavaScript additions!

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles