Complete the code to pipe the readable stream to the writable stream.
readableStream.[1](writableStream);The pipe method connects a readable stream to a writable stream, allowing data to flow from one to the other.
Complete the code to handle errors on the writable stream when piping.
writableStream.on('[1]', (err) => { console.error('Error:', err); });
The error event is emitted when a stream encounters an error. Listening to it helps handle problems gracefully.
Fix the error in the code to properly pipe streams with error handling.
readableStream.pipe(writableStream).on('[1]', (err) => { console.error('Pipe error:', err); });
When piping streams, the error event should be listened on the returned stream to catch errors during piping.
Fill both blanks to create a pipeline that pipes readableStream to transformStream and then to writableStream.
readableStream.[1](transformStream).[2](writableStream);
The pipe method is used to chain streams together, passing data from one to the next.
Fill all three blanks to create a pipeline using the pipeline utility with error handling.
const { pipeline } = require('stream');
pipeline(
readableStream,
[1],
[2],
[3],
(err) => {
if (err) console.error('Pipeline failed:', err);
else console.log('Pipeline succeeded');
}
);The pipeline function takes streams in order: readable, transforms, writable, and a callback for errors.