Transform stream
A Duplex stream that changes data as it passes through, such as a compressor, a cipher or a packet parser.
In more detail
A custom one implements _transform(chunk, encoding, callback) to push results and call the callback, and optionally _flush(callback) to emit anything left over when the input ends. It respects backpressure on both sides automatically.
Related terms
- Duplex stream — A Node.js stream that is both readable and writable, with the two sides independent, such as a TCP socket.
- framing — The rule that marks where one message or record ends and the next begins in a stream of bytes.
- object mode — A stream setting that lets chunks be any JavaScript value, such as parsed records, instead of only strings and Buffers.
Taught in
- Native Compression: node:zlib & Streaming Codecs — Node.js Internals & Backend Services
- Transform Streams: Custom Packet Decoding & Codecs — Node.js Internals & Backend Services