- 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.readValue() Method
The NodeJS v8.deserializer.readValue() method of class v8.deserializer is used for deserializing the JavaScript value that is written in the internal buffer (using the writeValue() method).
Syntax
Following is the syntax of the NodeJS readValue() method −
v8.deserializer.readValue()
Parameters
This method does not accept any parameters.
Return Value
This method returns the JavaScript value from the internal buffer after deserializing it.
Example
In the following example, firstly, we are trying to write a JavaScript value to the internal buffer using the v8.serializer.writeValue() method. Then we are trying to read and return the value present in the internal buffer using the v8.deserializer.readValue() method.
const v8 = require('v8'); // Defining the serializer object const serializer = new v8.Serializer(); // Writing some value to internal buffer console.log(serializer.writeValue('TutorialsPoint')); // Defining the deserializer object const deserializer = new v8.Deserializer(serializer.releaseBuffer()); // Reading the headers from internal buffer console.log(deserializer.readValue());
Output
true TutorialsPoint
Example
In this example, we are trying to write a header instead of value to the internal buffer. So, the readValue() method will throw an error.
const v8 = require('v8'); // Defining the serializer object const serializer = new v8.Serializer(); // Writing some value to internal buffer serializer.writeHeader('TutorialsPoint'); // Defining the deserializer object const deserializer = new v8.Deserializer(serializer.releaseBuffer()); // Reading the headers from internal buffer console.log(deserializer.readValue());
Error
Following is the output of the above code −
/home/cg/root/63b6984e13ac0/main.js:13 console.log(deserializer.readValue()); ^ Error: Unable to deserialize cloned data. at Object.<anonymous> (/home/cg/root/63b6984e13ac0/main.js:13:26) at Module._compile (internal/modules/cjs/loader.js:702:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12) at Function.Module._load (internal/modules/cjs/loader.js:543:3) at Function.Module.runMain (internal/modules/cjs/loader.js:744:10) at startup (internal/bootstrap/node.js:238:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
To Continue Learning Please Login
Login with Google