Function pipe() javascript (Node.js)

Asked

Viewed 3,685 times

4

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

1 answer

6


The function pipe What you saw in Gulp actually comes from Node.js.

The function pipe is part of the Node.js API Stream. Many things in Node.js are Streams, such as HTTP connection, opening files, and more. Stream can be translated as chain or stream, that is, the communication between the nodes are gradually, like a thin stream. For example Youtube, we see the videos being downloaded gradually. This is called Video Streaming, where the server sends bytes of the file slowly, 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 prevents millions of users to process the same file, and the server can be smarter by slowly sending the file (in the form of File Download). Node.js does better streaming than many platforms.

In case the pipe turns something readable for writeable, i.e., it transforms a readable stream to a recording stream when collecting data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.