Skip to content
Related Articles

Related Articles

Node.js v8.Deserializer.readUint64() Method
  • Last Updated : 22 Jul, 2020

The v8.Deserializer.readUint64() method is an inbuilt application programming interface of the v8.Deserializer module which is used to read a raw 64-bit unsigned integer value from the buffer as an array of 32-bit integers, higher and lower 32-bits separated. For use inside of custom Deserializer._readHostObject().

Syntax:

v8.Deserializer.readUint64();

Parameters: This method does not accept any parameters.

Return Value: This method reads raw 64-bit unsigned integer value from the buffer as an array of two 32-bits integer, higher and lower 32-bits separated, and returns it.

Below examples illustrate the use of v8.Deserializer.readUint64() method in Node.js:



Example 1: Filename: index.js

filter_none

edit
close

play_arrow

link
brightness_4
code

// Accessing v8 module
const v8 = require('v8');
const serializer = new v8.Serializer();
  
// Calling v8.serializer.writeUint64() 
serializer.writeUint64(6783, 348072);
  
// Calling v8.deserializer.readUint64() 
const deserializer = new v8.Deserializer(
            serializer.releaseBuffer());
              
console.log(deserializer.readUint64());

chevron_right


Run index.js file using the following command:

node index.js

Output:

[ 6783, 348072 ]

Example 2: Filename: index.js

filter_none

edit
close

play_arrow

link
brightness_4
code

// Accessing v8 module
const v8 = require('v8');
const serializer = new v8.Serializer();
  
// Calling v8.serializer.writeUint64() 
serializer.writeUint64(29698, 34752);
buff = serializer.releaseBuffer();
console.log("buffer data is:");
console.log(buff);
  
  
// Calling v8.deserializer.readUint64() 
const deserializer = new v8.Deserializer(buff);
data = deserializer.readUint64();
console.log("higher 32-bits=%d and lower "
        + "32-bits=%d ", data[0], data[1]);

chevron_right


Run index.js file using the following command:

node index.js

Output:

buffer data is:
<Buffer c0 8f 82 80 a0 80 1d>
higher 32-bits=29698 and lower 32-bits=34752

Reference: https://nodejs.org/api/v8.html#v8_deserializer_readuint64

My Personal Notes arrow_drop_up
Recommended Articles
Page :