Recall & Review
beginner
What is a Transform stream in Node.js?
A Transform stream is a type of stream that can read data, modify or process it, and then output the transformed data. It acts as both a readable and writable stream.
Click to reveal answer
intermediate
Which method must you implement when creating a custom Transform stream?
You must implement the _transform(chunk, encoding, callback) method. This method processes each chunk of data and calls the callback when done.
Click to reveal answer
intermediate
How do Transform streams differ from Duplex streams?
Transform streams are a special kind of Duplex stream where the output is computed from the input. Duplex streams can read and write independently without transforming data.
Click to reveal answer
beginner
What is the purpose of the callback function in the _transform method?
The callback signals that the current chunk has been processed. It can pass an error to indicate failure. The transformed data should be pushed using this.push() before calling the callback.
Click to reveal answer
beginner
Give a simple real-life analogy for a Transform stream.
Imagine a juice maker: it takes fruits (input), processes them (transforms), and outputs juice (transformed data). The juice maker is like a Transform stream.
Click to reveal answer
What does a Transform stream do in Node.js?
✗ Incorrect
Transform streams both read and write data, modifying it as it passes through.
Which method is essential to override in a custom Transform stream?
✗ Incorrect
The _transform() method handles processing each chunk of data.
What arguments does the _transform method receive?
✗ Incorrect
The _transform method receives the chunk of data, its encoding, and a callback to signal completion.
How is a Transform stream related to a Duplex stream?
✗ Incorrect
Transform streams extend Duplex streams by transforming data as it passes through.
What happens if you don't call the callback in _transform?
✗ Incorrect
Not calling the callback blocks the stream from moving to the next chunk.
Explain how a Transform stream works in Node.js and why it is useful.
Think about how data flows through a machine that changes it.
You got /5 concepts.
Describe the role of the _transform method and the callback function inside it.
Focus on how each piece of data is handled step-by-step.
You got /4 concepts.