pipe() javascript function (node.js)


How does javascript's PIPE() (node.js) work? I see it a lot in gulp and I would like to know how the function works directly in javascript.


The pipe function you saw in gulp actually comes from node.js.

The pipe function is part of the node.js Stream API. Many things in Node.js are Streams, like HTTP connection, opening files, among others. Stream can be translated as current or stream , that is, communication between nodes is gradually, like a thin stream. For example YouTube, we see videos being downloaded little by little. That's called Video Streaming, it's where the server sends bytes of the file little by little, allowing you to watch the video. The same is done with any type of file, it is better to work with the server in streaming because it avoids millions of users processing the same file, and the server can be smarter by sending the file little by little (in the form of downloading files). node.js streams better than many platforms.

In this case the pipe transforms something readable to writeable , that is, it transforms a readable stream to a writeable stream when collecting data.

Scroll to Top