14 lessons
The Certificate
Piping Streams is a mechanism where an output of one Stream plays the input role for another Stream. In simpler terms, piping connects multiple Streams together. The importance of piping is its ability to break down complex processing into simplified and smaller tasks that result in separate execution. Node.js provides the pipe method for that purpose.
A typical example of a Piping Stream in action is connecting files. i.e. transfering data from file-to-file. In the code-snippet below, assume you have a file under the name dataInput.txt that has data stored inside. With the help of the pipe method we'll be copying that data into an empty dataOutput.txt.
By using the piping method we get dataOutput.txt and dataInput.txt containing the same data.