Buffer in nodejs

Keshav Gautam
May 22, 2021

Buffer objects are used to represent a fixed-length sequence of bytes.

Pure JavaScript is Unicode friendly, but it is not so for binary data. While dealing with TCP streams or the file system, it’s necessary to handle octet streams. Node provides Buffer class which provides instances to store raw data similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap.

Buffer class is a global class that can be accessed in an application without importing the buffer module.

var buf = new Buffer(10);var buf = new Buffer([10, 20, 30, 40, 50]);

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Keshav Gautam
Keshav Gautam

No responses yet

Write a response