- 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.readRawBytes() Method
The NodeJs v8.deserializer.readRawBytes() method of class v8.deserializer is used to read raw bytes from the deserializer's internal buffer. This method basically returns the internal buffer without deserializing it.
Syntax
Following is the syntax of the NodeJS v8.deserializer.readRawBytes() method −
v8.deserializer.readRawBytes(length)
Parameters
This method accepts only one parameter.
length − This parameter specifies the length of the buffer to be read from the deserializer's internal buffer.
Return Value
This method read the raw bytes from the deserializer's internal buffer.
If length parameter is specified, it will return the length of the buffer that was passed to this method.
Example
In the example below, we are trying to write raw bytes to the serializer's internal buffer using v8.serializer.writeRawBytes() method. Then we are trying to read the raw buffer data from deserializer's internal buffer using v8.deserializer.readRawBytes() method.
const v8 = require('v8'); const serializer = new v8.Serializer(); serializer.writeRawBytes(v8.serialize(32435)); let buffer = serializer.releaseBuffer(); const deserializer = new v8.Deserializer(buffer); console.log(deserializer.readRawBytes());
Output
Following is the output of the above program −
<Buffer ff 0d 49 e6 fa 03>
Example
In the following example, we are passing a length as a parameter to the readRawBytes() method.
const v8 = require('v8'); const serializer = new v8.Serializer(); serializer.writeRawBytes(v8.serialize(32435)); let buffer = serializer.releaseBuffer(); console.log(buffer); const deserializer = new v8.Deserializer(buffer); console.log(deserializer.readRawBytes(2));
Output
As we can see in the output below, the readRawBytes() method returned only 2 raw bytes from the deserializer's internal buffer because 2 is passed as length.
<Buffer ff 0d 49 e6 fa 03> <Buffer ff 0d>
To Continue Learning Please Login
Login with Google