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