async iteration

Looping over values that arrive over time with for await (const x of source), waiting for each one before the next turn of the loop.

In more detail

Readable streams, fs.watch and many other APIs are async iterables. Because the loop only asks for the next item when the body finishes, a slow body naturally slows the source, and breaking out of the loop cleans the source up.

Related terms

Taught in

References