Pipe Works · Level 1 of 6

Chunks, not the whole thing

A readable stream with three chunks, a data listener and an end listener.

const { Readable } = require('node:stream');const r = Readable.from(['a', 'b', 'c']);r.on('data', (chunk) => console.log('chunk ' + chunk));r.on('end', () => console.log('end'));console.log('reading starts');

1. Predict the output

Tap the lines in the order you think they print.

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