The Buffer.readUIntLE() method is an inbuilt application programming interface of class Buffer within the Buffer module which is used to read specified number of byte(s) value from an allocated buffer at a specified offset.
Buffer.readUIntLE( offset, byteLength )
Parameters: This method accept two parameters as mentioned above and described below:
- offset: It specifies the number of bytes to skip before read or simply signify the index in the buffer. The value of offset lies 0 <= offset <= Buffer.length – byteLength. Its default value is 0.
- byteLength: It specifies the number of bytes to be read. The value of byteLength lies 0 < byteLength <= 6.
Return Value: This method returns an integer value that read from buffer in Little Endian format.
Below examples illustrate the use of Buffer.readUIntLE() method in Node.js:
<Buffer 21 09 19 98> 190921 981909 9819
<Buffer 21 09 19 98> 190921 210919 1909 919 19 19
<Buffer 21 09 19 98> 98190921 1909 internal/buffer.js:49 throw new ERR_OUT_OF_RANGE(type || 'offset', ^ RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 1. Received 2 at boundsError (internal/buffer.js:49:9) at readUInt24LE (internal/buffer.js:118:5) at Buffer.readUIntLE (internal/buffer.js:61:12) . . .
Note: The above program will compile and run by using the
node index.js command.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.