The Buffer.writeInt32BE() method is an inbuilt application programming interface of class Buffer within Buffer module which is used to write integer value to buffer at the specified offset with the big-endian format, integer value should be a valid signed 32-bit integer. Error is thrown if the value is outside the range of signed 32-bit integer.Integer value is interpreted and written as a two’s complement signed integer.
Buffer.writeInt32BE( value, offset )
Parameters: This method accept two parameters as mentioned above and described below:
value: This parameter holds a 32-bit signed integer that need to be written to the buffer.
offset: This parameter holds an integer value i.e. the number of bytes to skip before starting to write into the buffer. The value of offset lies between 0 to buf.length – 4. It is an optional parameter and its default value is 0.
Return Value: This method returns an integer value i.e. the sum of offset plus the number of bytes written.
Below examples illustrate the use of buf.writeInt32BE() method in Node.js:
<Buffer 7b ca f8 92>
<Buffer 7b ca f9 83 7f ff ff ff>
Example 3: This example will display an error message because the offset is greater than the limit i.e. the offset value does not lies within 0 to buf.length – 4.
internal/buffer.js:72 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 <= 4. Received 5 . . .
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs console.timeLog() Method
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Cowsay in Nodejs using Requests library
- Nodejs | Web Crawling using Cheerio
- Web-Socket in NodeJS
- Signup Form Using Nodejs and MongoDB
- Dockerizing a simple Nodejs app
- Nodejs | DNS
- Encrypting Data in NodeJS
- Difference between NodeJS and AngularJS
- Nodejs | Jimp
- Nodejs – Connect Mysql with Node app
- Nodejs | DNS | setServers()
- NodeJS | Building simple REST API in express
- NodeJs - Handling invalid routes
- Nodejs | authentication using Passportjs and passport-local-mongoose
- Nodejs | GM charcoal() Function
- Nodejs | GM blur() Function
- Nodejs | GM sharpen() Function
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.