News for hackers. Stuff that matters.
Re:Unravelling `Async for` Loops by fregante on Wednesday September 15, 2021 @06:15AM (#28537336)
`for await` is for async iterables, which is different. The loop body will still block the loop. Compare it to the all/map example I wrote.
Re:Unravelling `Async for` Loops by eurasiantiger on Wednesday September 15, 2021 @03:10PM (#28543078)
True, it is sequential and not parallel. I think this syntax with an async generator could be made to do what you seek.
Re:Unravelling `Async for` Loops by fregante on Thursday September 16, 2021 @02:51PM (#28555648)
Async iterables are async generators. They call .next() on the iterable, that returns a promise, the promise resolves with either a new item to loop with, or with `done`, which will stop the loop.