0% found this document useful (0 votes)
14 views2 pages

Nodejs Buffer & Stream

Streams in Node.js are information flows used for efficient data transmission, breaking data into smaller pieces. There are four types of streams: Writable, Readable, Duplex, and Transform, with Readable streams further categorized into flowing and non-flowing types. Buffers temporarily store binary data in memory, allowing streams to manage data flow when processing speed varies.

Uploaded by

aharonno2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Nodejs Buffer & Stream

Streams in Node.js are information flows used for efficient data transmission, breaking data into smaller pieces. There are four types of streams: Writable, Readable, Duplex, and Transform, with Readable streams further categorized into flowing and non-flowing types. Buffers temporarily store binary data in memory, allowing streams to manage data flow when processing speed varies.

Uploaded by

aharonno2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Stream in node js: They are information flows that are used in the transmission of binary

data. They are also a way to handle network communications or any kind of back-and-forth data
exchange efficiently, by breaking information down into smaller pieces.

Here are some important features of Streams:


● Streams work sequentially.
● The information is transmitted through “chunks” (pieces).
● Streams rely on buffers to manage content.

4 types of Streams in Node js:


● Writable: Streams in which we can write data.
● Readable: Streams receiving input data.
● Duplex: Streams that are both read and written.
● Transform: Streams that can modify or transform data as it is written and read.

Node.js streams extend the EventEmitter class. We can


listen to events like data and end in streams.

There are two types of readable stream:


1. Flowing stream:
A types of readable stream that continuously emits
data as it’s become available, without the need for
explicit calls to read data.
2. Non-flowing stream:
A type of readable stream that is in paused mode,
this is more controlled stream than flowing stream.
This will let you have more control like when and
how much data you want to consume.

Buffer in node js: A buffer is a space in memory (usually RAM) that temporarily stores
binary data.
A buffer is a temporary memory that a stream takes to hold some data until it is consumed.

When a stream processor accepts data faster more than it can digest, sends the data to buffer.

Here are some important features of Buffers:


● Buffers are stored in a sequence of integers(binary bits)
● Once created they cannot be resized.

If we try to push some data into the stream, the data is pushed into the stream buffer. So a
buffer is a temporary memory that a stream takes to hold some data until it is consumed.

https://javascript.plainenglish.io/streams-and-buffers-in-nodejs-30ff53edd50f
https://www.naukri.com/code360/library/streams-and-buffer-in-node-js
https://medium.com/globant/node-js-buffer-vs-stream-e2c23df543c1
https://tolustar.com/buffers-and-streams-explained-in-nodejs/
https://medium.com/globant/node-js-buffer-vs-stream-e2c23df543c1

You might also like