From the course: Advanced Node.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Transform streams

Transform streams - Node.js Tutorial

From the course: Advanced Node.js

Start my 1-month free trial

Transform streams

- [Instructor] In the last lesson, I mentioned transform streams. Transform streams are a special type of duplex stream. Instead of simply passing the data to the read in to the write in, transform streams change the data. Transform streams are the center pipe pieces that can be used to transform data from readable streams before they are sent to writable streams. So I'm in just a blank index.js file, this file is found inside of your start folder, under chapter two lesson eight, and I'm going to go ahead and just create a new transform stream by pulling out our transform type. From our stream module, and what we're going to go ahead and do, is create a new class called replace text. And this is going to be a transform stream, so we're going to extend transform type. Transform streams have different methods, instead of write we are actually going to use the transform method. Now, it looks similar to the write method in that it gets a chunk in the encoding, of that chunk and a callback…

Contents