
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js V8 Serializer writeUInt32 Method
The v8.serializer.writeUint32() method is used for writing a raw 32-bit unsigned integer. This function is mainly used inside the custom serializer._writeHostObject().
Syntax
v8.serializer.writeUint32(value)
Parameters
- value − This parameter takes input for the 32-bit integer that will be written inside the internal buffer.
The function does not return anything, instead it writes the passed value to the internal buffer.
Example 1
Create a file with the name "writeUint32.js" and copy the following code snippet. After creating the file, use the command "node writeUint32.js" to run this code.
// v8.deserialize() Demo Example // Importing the v8 module const v8 = require('v8'); // Initializing the v8 Serializer object const serializer = new v8.Serializer(); // Adding 32-bit integer to internal buffer. // This will return undefined since it only adds to buffer console.log(serializer.writeUint32(7869)); // Releasing and printing the internal buffer console.log(serializer.releaseBuffer());
Output
C:\home
ode>> node writeUint32.js undefined <Buffer bd 3d>
Example 2
Let’s have a look at one more example
// v8.serializer.writeUint32() Demo Example // Importing v8 module const v8 = require('v8'); const serializer = new v8.Serializer(); // Calling v8.serializer.writeUint32() console.log(serializer.releaseBuffer()); // Writing the same 32-bit integer twice serializer.writeUint32(7869); serializer.writeUint32(7869); // Adding the above value to internal buffer console.log(serializer.releaseBuffer()); // Writing the same 32-bit integer again serializer.writeUint32(7869); // console.log(serializer.releaseBuffer()); console.log("Reading the same value after adding to buffer"); // Calling v8.deserializer.readUint32() const deserializer = new v8.Deserializer(serializer.releaseBuffer()); // Deserializing the internal buffer console.log(deserializer.readUint32());
Output
C:\home
ode>> node writeUint32.js <Buffer > <Buffer bd 3d bd 3d> Reading the same value after adding to buffer 7869
Advertisements