Hacker News new | ask | show | jobs
by jimmydief 1734 days ago
A little more verbose than your example but https://github.com/tc39/proposal-async-do-expressions would help with this.
1 comments

Thanks! I think it wouldn’t await the whole loop though

  for (const item of iterable)
    async do {
      await item()
    }
This would be equivalent to

  Promise.all(arr.map(async item => {
    await item()
  })
Notice the lack of await before Promise.all