Loading topic
for...of does with an object. This chapter reviews that model so the async version in the next chapter reads as a small extension.2 min readPromise and async/await work, and that you remember the sync iteration protocol from the previous chapter: Symbol.iterator, next(), and { value, done } result objects. Here you will see how JavaScript extends that protocol to values that arrive over time3 min readasync/await work, that you can write a basic for...of loop, and that you have read the previous chapter on the async iteration protocol. The protocol defines what an async iterable is. The for await...of loop is the usual way to read one.3 min readasync/await, the async iteration protocol from the previous chapter (a next() that returns a Promise of { value, done }), and how for await...of consumes an async iterable. Here you will write the producer side using async generator functions.2 min readasync/await, try/catch, and the for await...of loop and async generators from the previous chapters. It covers where errors come from during async iteration, how they reach your loop, and how to keep a loop running when a single item fails.2 min readfor await...of consumes an async iterable and how to write an async function*. It also assumes you are comfortable with try/finally.3 min readfor await...of loop, and async generators from earlier chapters. You should also be comfortable with Promises and setTimeout.3 min readSymbol.asyncIterator is, and how for await...of consumes an async iterable. Those topics were covered in earlier chapters. Here you will see what happens when you give for await...of something that is not async iterabl3 min readfor await...of consumes async iterables, how it handles plain arrays of promises, and how try/catch catches errors raised during iteration. You should also be comfortable with Promise.all.2 min readfor await...of, the early-exit behavior covered in the previous chapter (break calls return()), and how to run ES modules in Node.js 18 or later. Every example uses top-level await, so save each one as a .mjs file.2 min readasync function* and consume one with for await...of. It also assumes you know how return() and finally behave when a loop exits early. You will learn how yield* lets one async generator hand control to another iterable, and what it3 min readfor await...of consumes async iterables, how async function* produces them, how yield* delegates, and how return() and finally run when a loop exits early. Here you combine those pieces into pipelines. A pipeline is a chain of small stages. Each st2 min readfor await...of, and how early exit calls return(). Those topics are covered in earlier chapters. You also need Node.js 22 or later, or a current browser, because Array.fromAsync is a fairly recent addition to the language.2 min read