Node.js Buffer.kMaxLength Property
The Buffer.kMaxLength property is an inbuilt application programming interface of class Buffer within buffer module which is used to set and get the maximum length allowed for single buffer instance.
Syntax:
const Buffer.kMaxLength
Parameters: This property works as a getter and setter so it takes integer value as a parameter sometimes.
Return Value: This property return the maximum length allowed for single buffer instance.
Example 1: Filename: index.js
Javascript
const arrbuff = new ArrayBuffer(16);
const buffer = Buffer.from(arrbuff);
buffer.kMaxLength = 23;
const value = buffer.kMaxLength;
console.log( "kMaxLength is: " + value);
|
Output:
kMaxLength is: 23
Example 2: Filename: index.js
If kMaxLength is not initialized
Javascript
const arrbuff = new ArrayBuffer(16);
const buffer = Buffer.from(arrbuff);
const value = buffer.kMaxLength;
console.log( "kMaxLength is: " + value);
|
Output:
kMaxLength is: undefined
Run index.js file using the following command:
node index.js
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/buffer.html#buffer_buffer_kmaxlength
Last Updated :
08 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...