0
0
Node.jsframework~10 mins

Piping streams together in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to pipe the readable stream to the writable stream.

Node.js
readableStream.[1](writableStream);
Drag options to blanks, or click blank then click option'
Alink
Bpipe
Cconnect
Djoin
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like 'connect' or 'link' which do not exist on streams.
Trying to call pipe on the writable stream instead of the readable stream.
2fill in blank
medium

Complete the code to handle errors on the writable stream when piping.

Node.js
writableStream.on('[1]', (err) => {
  console.error('Error:', err);
});
Drag options to blanks, or click blank then click option'
Aerror
Bclose
Cfinish
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'close' or 'finish' which are not error events.
Not handling errors at all, which can cause crashes.
3fill in blank
hard

Fix the error in the code to properly pipe streams with error handling.

Node.js
readableStream.pipe(writableStream).on('[1]', (err) => {
  console.error('Pipe error:', err);
});
Drag options to blanks, or click blank then click option'
Aerror
Bfinish
Cdata
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Listening to 'finish' or 'end' which are not error events.
Not attaching error handlers to the pipe chain.
4fill in blank
hard

Fill both blanks to create a pipeline that pipes readableStream to transformStream and then to writableStream.

Node.js
readableStream.[1](transformStream).[2](writableStream);
Drag options to blanks, or click blank then click option'
Apipe
Bconnect
Clink
Djoin
Attempts:
3 left
💡 Hint
Common Mistakes
Using different methods like 'connect' or 'link' which do not exist.
Using only one pipe call instead of chaining.
5fill in blank
hard

Fill all three blanks to create a pipeline using the pipeline utility with error handling.

Node.js
const { pipeline } = require('stream');
pipeline(
  readableStream,
  [1],
  [2],
  [3],
  (err) => {
    if (err) console.error('Pipeline failed:', err);
    else console.log('Pipeline succeeded');
  }
);
Drag options to blanks, or click blank then click option'
AtransformStream
BwritableStream
CanotherTransform
DreadableStream
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the writable stream before transform streams.
Repeating the readable stream inside the pipeline.
Not including the writable stream at the end.