Pipe Works · Level 6 of 6

for await reads one at a time

Reading a stream with for await...of inside an async function.

const { Readable } = require('node:stream');async function main() {  for await (const chunk of Readable.from(['one', 'two'])) {    console.log(chunk);  }  console.log('done');}main();console.log('started');

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…
  4. 4…