"await.ops" – less typing, more promise-handling (#note)

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 JavaS…


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

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!


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2021-12-18T23:00:00+00:00) "await.ops" – less typing, more promise-handling (#note). Retrieved from https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/

MLA
" » "await.ops" – less typing, more promise-handling (#note)." Stefan Judis | Sciencx - Saturday December 18, 2021, https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/
HARVARD
Stefan Judis | Sciencx Saturday December 18, 2021 » "await.ops" – less typing, more promise-handling (#note)., viewed ,<https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/>
VANCOUVER
Stefan Judis | Sciencx - » "await.ops" – less typing, more promise-handling (#note). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/
CHICAGO
" » "await.ops" – less typing, more promise-handling (#note)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/
IEEE
" » "await.ops" – less typing, more promise-handling (#note)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/. [Accessed: ]
rf:citation
» "await.ops" – less typing, more promise-handling (#note) | Stefan Judis | Sciencx | https://www.scien.cx/2021/12/18/await-ops-less-typing-more-promise-handling-note/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.