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.

Duplex streams

Duplex streams - Node.js Tutorial

From the course: Advanced Node.js

Start my 1-month free trial

Duplex streams

- A duplex stream is a stream that implements both a readable and a writable. These streams allow data to pass through. Readable streams will pipe data into a duplex stream, and the duplex stream can also write that data. So duplex stream represent the middle sections of pipelines. I'm looking at the code that we created in the last lesson where we pipe from out read stream. Which is reading a video, powder-day.mp4, to our write stream, which is creating a copy of that video. What we're gonna go ahead and do is implement a duplex stream here. Now this is inside of your lesson files under chapter two. Chapter two lesson seven, and within the start folder. So in order to do this, we're gonna go ahead and grab the most basic type of duplex stream, which is a pass through. And we can get that from our stream module. And what we can do is create a new pass through stream called report. And when I say they represent the middle sections of a pipe line, that means that we can put them in…

Contents