In this video we are going to learn chaining the streams.
Chaining is a mechanism to connect the output of one stream to another stream and create a chain of multiple stream operations.
It is normally used with piping operations.
Lets see the chaining.
So goto the project and inside the index.js file first off all.
Require fs and zlib package.

Var fs = require('fs');
var zlib = require('zlib');

fs.createReadStream(message.txt ')
.pipe(zlib.createGzip())
.pipe(fs.createWriteStream('message.txt.gz'));
console.log(\"File created and Compressed.\");

Here it will create a file message.txt then it will compress this file.
Now lets check.
So go to command prompt and here just run index.js file.


node index.js


You can see file created and compressed.
So lets see, go to the project and you can see here the message.txt.gz file.
Ii I decompress this you can see the message .txt file.
So in this way you can chaining the stream.