Answer
Use a for-await-of loop, which automatically awaits each next() call and unwraps the resolved value, pausing the loop until each item is ready.
async function run() {
for await (const chunk of asyncIterable) {
console.log(chunk);
}
}Real-world example Streaming and logging each chunk of a fetch() response body as it arrives.