An async iterable exposes a [Symbol.asyncIterator]() method that returns an iterator whose next() returns a promise resolving to { value, done }. This language-defined contract lets consumers request values incrementally. section 10.5
const iterable = {
[Symbol.asyncIterator]() {
let i = 0;
return {
next() {
if (i >= 5) return Promise.resolve({ value: undefined, done: true });
return Promise.resolve({ value: i++, done: false });
}
};
}
};This minimal iterator makes the protocol concrete: each next() call produces a promised iteration result. section 10.5
A for-await-of loop calls next(), awaits its promise, then runs the loop body before requesting another value. That makes iteration consumer-paced: no next() call means no new value is requested. The protocol has no built-in buffer or way to ask a producer to work ahead, so I/O-heavy production can leave the consumer waiting on each round trip. section 10.5 section 10.5.2
A Readable stream bridge
Node.js Readable streams support for-await-of, but their internal buffers remain push-driven; the syntax does not turn the stream into a pure pull source. Web Streams, by contrast, use pull-based reading in this account. section 10.5.3
