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.
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs | DNS
- Web-Socket in NodeJS
- Nodejs | Jimp
- Nodejs | DNS | setServers()
- Difference between NodeJS and AngularJS
- Encrypting Data in NodeJS
- Dockerizing a simple Nodejs app
- Nodejs | Web Crawling using Cheerio
- Nodejs | GM blur() Function
- Nodejs | GM charcoal() Function
- Nodejs | GM sharpen() Function
- Nodejs – Connect Mysql with Node app
- Cowsay in Nodejs using Requests library
- NodeJs - Handling invalid routes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.