- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
NodeJS v8.deserializer.readUint64() Method
The NodeJS v8.deserializer.readUint64() method of class v8.deserializer is used to read a raw 64-bit unsigned integer and return it as an array with its higher and lower values as follows: [hi, lo].
Unit64 is a 64-bit unsigned integer that has a minimum value of 0 and a maximum value of 18,446,744,073,709,551,615 (2^64)-1 (inclusive).
We write a raw 64-bit integer value to the internal buffer (using writeUnit64() method) by separating them into high and low 32-bit integers. So, while reading (using readUnit64() method) both the hi and lo will contain the 32-bit unsigned integer. If the no value is written as lo, the readWrite() method will read and return it as 0.
Syntax
Following is the syntax of the NodeJS v8.deserializer.readUint64() method −
v8.deserializer.readUint64()
Parameters
This method does not accept any parameters.
Return Value
This method read a raw 64-bit unsigned integer and return it in form of an array [hi, lo] with two 32-bit unsigned integer entries.
Example
In the following example, we are trying to write a raw 64-bit unsigned integer to the internal buffer using serializer.writeUnit64() method. Then we are trying to read and return the deserialized 64-bit unsigned integer present in the internal buffer using deserializer.readUint64() method.
const v8 = require('v8'); // Initializing the serializer object const serializer = new v8.Serializer(); // Writing a 64-bit integer value to the internal buffer serializer.writeUint64(3412, 87578); // Initializing the deserializer object const deserializer = new v8.Deserializer(serializer.releaseBuffer()); console.log(deserializer.readUint64());
Output
[ 3412, 87578 ]
Example
In the example, we are writing a raw 64-bit unsigned integer to the internal buffer using serializer.writeUint64() method and returning the serialized internal buffer using serializer.releaseBuffer().
Then we are reading and returning the deserialized 64-bit present in the internal buffer using deserializer.readUint64() method.
const v8 = require('v8'); // Initializing the serializer object const serializer = new v8.Serializer(); let buffer; // Writing a 64-bit integer value to the internal buffer writeUint64 = (lo, hi) => { serializer.writeUint64(lo, hi) buffer = serializer.releaseBuffer() console.log(buffer) readUint64(buffer) console.log("----------------------------------") } readUint64 = (buffer) => { const deserializer = new v8.Deserializer(buffer); console.log(deserializer.readUint64(buffer)); } writeUint64(45875, 09878) writeUint64(42134, 2431)
Output
<Buffer 96 cd 80 80 b0 e6 2c> [ 45875, 9878 ] ---------------------------------- <Buffer ff 92 80 80 e0 92 29> [ 42134, 2431 ] ----------------------------------
Example
If no value is passed as lo parameter, the readUnit64() method will read and return it as 0.
const v8 = require('v8'); // Initializing the serializer object const serializer = new v8.Serializer(); let buffer; // Writing a 64-bit integer value to the internal buffer writeUint64 = (lo, hi) => { serializer.writeUint64(lo, hi) buffer = serializer.releaseBuffer() console.log(buffer) readUint64(buffer) console.log("----------------------------------") } readUint64 = (buffer) => { const deserializer = new v8.Deserializer(buffer); console.log(deserializer.readUint64(buffer)); } writeUint64(1456) writeUint64(0998)
Output
<Buffer 80 80 80 80 80 b6 01> [ 1456, 0 ] ---------------------------------- <Buffer 80 80 80 80 e0 7c> [ 998, 0 ] ----------------------------------
To Continue Learning Please Login
Login with Google