Node.js Buffer.readUInt16LE() Method
The Buffer.readUInt16LE() method is an inbuilt application programming interface of class Buffer within Buffer module which is used to read an unsigned 16-bit integer from buffer at the specified offset with specified little endian format.
Buffer.readUInt16LE( offset )
Parameters: This method accepts single parameter offset which denotes the number of bytes to skipped before starting to read from buffer. The offset can be in range 0 <= offset <= buf.length – 2. The default value of offset is 0.
Return value: It returns an integer from the specified offset in little endian format.
Below examples illustrate the use of Buffer.readUInt16LE() Method in Node.js:
700 406 101
1424 2556 RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out ofrange. It must be >= 0 and <= 6. Received 10 at boundsError (internal/buffer.js:49:9) at Buffer.readUInt16BE (internal/buffer.js:215:5) at /home/runner/index.js:14:17 ......
The above example shows the error because its parameters are not in the valid range.
Note: The above program will compile and run by using the
node index.js command.