Skip to main content
Node.js Output Prediction Hard +35 XP

Readable Stream

How is data read from a readable stream?

Node.jsRead-only
stream.on('data', chunk => process.stdout.write(chunk));
stream.on('end', () => console.log('Done'));

What is the output?

Show answer and explanation

Answer: Chunks emitted in 'data' events, 'end' when complete

Node.js streams emit 'data' events for each chunk. The 'end' event fires when there's no more data.

Hint: Streams are event-based and process data in chunks.

What this challenge tests

Output Prediction in Node.js: streams, events.

Related challenges