0% found this document useful (0 votes)
70 views

Node Js Streams

There are four types of streams in Node.js: readable, writable, duplex, and transform. Streams allow data to be processed incrementally instead of all at once, avoiding memory issues. Data can be read from and written to streams, and streams can be piped together or chained to connect multiple stream operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

Node Js Streams

There are four types of streams in Node.js: readable, writable, duplex, and transform. Streams allow data to be processed incrementally instead of all at once, avoiding memory issues. Data can be read from and written to streams, and streams can be piped together or chained to connect multiple stream operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Node.

js - Streams

bharatsewani1993
What are Streams?
Streams are collections of data — just like
arrays or strings. The difference is that
streams might not be available all at once,

and they don’t have to fit in memory.

bharatsewani1993
there are four types of streams:
Readable − Stream which is used for read
operation.

Writable − Stream which is used for write


operation.

Duplex − Stream which can be used for both read


and write operation.

Transform − A type of duplex stream where the


output is computed based on input.

bharatsewani1993
Reading from a Stream:

bharatsewani1993
Reading from a Stream example:

bharatsewani1993
Writing to a Stream:

bharatsewani1993
Writing to a Stream output:

bharatsewani1993
Piping the Streams:
Piping is a mechanism where we provide the
output of one stream as the input to another

stream. It is normally used to get data from one


stream and to pass the output of that stream to
another stream. There is no limit on piping
operations.

bharatsewani1993
Piping the Streams example:

bharatsewani1993
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.

bharatsewani1993
Chaining the Streams example:

bharatsewani1993
Like

Save

Share

bharatsewani1993

You might also like