[go: up one dir, main page]

Open In App

Node.js V8 Complete Reference

Last Updated : 22 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The v8 module exposes APIs that are specific to the version of V8 built into the Node.js binary.

Example:

Javascript




// Accessing v8 module
const v8 = require('v8');
 
// Calling v8.getHeapStatistics()
console.log(v8.getHeapStatistics());


Output:

{ total_heap_size: 6537216,
 total_heap_size_executable: 1048576,
 total_physical_size: 6537216,
 total_available_size: 1520717240,
 used_heap_size: 4199600,
 heap_size_limit: 1526909922,
 malloced_memory: 8192,
 peak_malloced_memory: 406408,
 does_zap_garbage: 0 }

The Complete list of V8 are listed below:

V8 Module APIs

V8 Module APIs

Description

cachedDataVersionTag() Get the version tag derived from the v8 version.
getHeapSpaceStatistics() Get statistics about heap space derived from the v8 version.
getHeapStatistics() Get statistics about heap derived from the v8 version.

Serialization API

Serialization API

Description

v8.serialize() Serialize any type of data into a buffer using default serializer.
v8.deserialize() Deserialize a buffered data into JS value using default deserializer.

Class: v8.Serializer

Class: v8.Serializer Methods

Description

writeHeader() Write out a header, that contains the serialization format version.
writeValue() Write the serialized data of JS value to the internal buffer.
releaseBuffer() Get content of the internal buffer.
writeUint32() Write the raw 32-bit integer value to the internal buffer..
writeUint64() Write a raw 64-bit integer value to the internal buffer by splitting into high and low 32-bit integers.
writeDouble() Write a JS number value to the internal buffer. For use inside of custom serializer._writeHostObject().
writeRawBytes() Write a raw buffer data to the internal buffer.

Class: v8.Deserializer

Class: v8.Deserializer Methods

Description

readHeader() Read the header and validate it, to ensure that contains a valid serialization format version.
readValue() Read the JS value from serialized data as present in a buffer.
readUint32()  Read a raw 32-bit unsigned integer value from the buffer. 
readUint64() Read a raw 64-bit unsigned integer value from the buffer as an array of 32-bit integers, higher and lower 32-bits separated.
readRawBytes() Read a raw buffer data from deserializer’s internal buffer of the given length.

Previous Article
Next Article

Similar Reads

Node.js String Decoder Complete Reference
The string Decoder module provides an API for decoding Buffer objects into strings. Example: C/C++ Code // Node.js program to demonstrate the // stringDecoder.write() Method // Import the string_decoder module // and get the StringDecoder class // using object destructuring const { StringDecoder } = require("string_decoder"); // Create a
1 min read
Node.js HTTP Module Complete Reference
To make HTTP requests in Node.js, there is a built-in module HTTP in Node.js to transfer data over the HTTP. To use the HTTP server in the node, we need to require the HTTP module. The HTTP module creates an HTTP server that listens to server ports and gives a response back to the client. Example: C/C++ Code // Node.js program to demonstrate the //
4 min read
Node.js Buffer Complete Reference
Buffers are instances of the Buffer class in Node.js. Buffers are designed to handle binary raw data. Buffers allocate raw memory outside the V8 heap. Buffer class is a global class so it can be used without importing the Buffer module in an application. Example: C/C++ Code <script> // Node.js program to demonstrate the // Buffer.allocUnsafeS
8 min read
Node.js Crypto Complete Reference
Node.js crypto module handles cryptographic functionality. Cryptography is an important aspect when we deal with network security. ‘Crypto’ means secret or hidden. Cryptography is the science of secret writing with the intention of keeping the data secret. Example: C/C++ Code <script> // Node.js program to demonstrate the // cipher.final() me
5 min read
Node.js Assert Complete Reference
Assert module in Node.js provides a bunch of facilities that are useful for the assertion of the function. The assert module provides a set of assertion functions for verifying invariants. If the condition is true it will output nothing else an assertion error is given by the console. Example: C/C++ Code // Requiring the module const assert = requi
2 min read
Node.js OS Complete Reference
Node.js OS module provides information about the computer operating system. Below example illustrate the os.version() method in Node.js: Example: C/C++ Code // Import the os module const os = require("os"); let osVersion = os.version(); console.log("OS Version:", osVersion); Output: OS Version: Windows 10 Enterprise The Complete
2 min read
Node.js Globals Complete Reference
Node.js Global Objects are the objects that are available in all modules. Global Objects are built-in objects that are part of the JavaScript and can be used directly in the application without importing any particular module. Example: It repeats the execution of the callback after every t time in milliseconds passed as a parameter. C/C++ Code // E
2 min read
Node.js Path Module Complete Reference
The Path Module in Node.js provides the utilities for working with file and directory paths. Example: C/C++ Code // Import the path module const path = require('path'); // CASE 1 // If "dir", "root" and "base" are all given, // "root" is ignored. let path1 = path.format({ root: "C:\\ignored\\root",
2 min read
Node.js Stream Complete Reference
Node.js streams are a type of data-handling method and are used to read or write input into output sequentially. Streams are used to handle reading/writing files or exchanging information efficiently. Example: C/C++ Code // Node.js program to demonstrate the // writable.write() method // Including stream module const stream = require('stream'); //
3 min read
Node.js Query String Complete Reference
Node.js query String module is used as utilities for parsing and formatting URL query strings. It can be used to convert query string into JSON object and vice-versa. Example: C/C++ Code // Import the querystring module const querystring = require("querystring"); // Specify the URL query string // to be parsed let urlQuery = "usernam
1 min read
Node.js HTTP2 Complete Reference
HTTP2 module is used to provide an implementation of the HTTP2 protocol. It reduces overheads by compressing the server request headers. Example: C/C++ Code // Node.js program to demonstrate the // close event method const http2 = require('http2'); const fs = require('fs'); // Private key and public certificate for access const options = { key: fs.
6 min read
Node.js UDP/DataGram Complete Reference
Node.js UDP/DataGram module provides an implementation of UDP datagram sockets. Example: C/C++ Code // Importing dgram module const dgram = require('dgram'); // Creating and initializing client // and server socket const client = dgram.createSocket("udp4"); const server = dgram.createSocket("udp4"); // Catching the message event
2 min read
Node.js URL Complete Reference
The ‘url’ module provides utilities for URL resolution and parsing. The getters and setters implement the properties of URL objects on the class prototype, and the URL class is available on the global object. Example: C/C++ Code // Create a test URLSearchParams object const searchpar = new URLSearchParams("keya=vala&keyb=valb"); // Di
4 min read
Node.js Utility Complete Reference
The Util module in node.js provides access to various utility functions. There are various utility modules available in the node.js module library. The modules are extremely useful in developing node based web applications. The Complete list of utility are listed below: Util Description Utility ModuleIt provides access to various utility functions.
4 min read
Node.js Timers Complete Reference
Node.js Timers module in Node.js contains various functions that allow us to execute a block of code or a function after a set period of time. The Timers module is global, we do not need to use require() to import it. Example: C/C++ Code // Node.js program to demonstrate the // Immediate Class methods // Setting Immediate by setImmediate Method con
2 min read
Node.js TLS/SSL Complete Reference
The tls module provides an implementation of the Transport Layer Security (TLS) and Secure Socket Layer (SSL) protocols that are built on top of OpenSSL. Example: C/C++ Code // Node.js program to demonstrate the // tls.getCiphers() method const tls = require('tls'), fs = require('fs'), // Port and host address for server PORT = 1337, HOST = '127.0.
3 min read
Node.js VM Complete Reference
The VM module enables compiling and running code within V8 Virtual Machine contexts. Example: C/C++ Code // Node.js program to demonstrate the // script.runInContext() method // Including util and vm module const util = require('util'); const vm = require('vm'); // Constructing context const contextobj = { name: 'Nidhi', articles: 60 }; // Construc
2 min read
Node.js Zlib Complete Reference
The zlib module provides compression functionality implemented using Gzip, Deflate/Inflate, and Brotli. The Complete Reference of Zlib are listed below: Methods Description zlib.constantsIt is used to yields an object listing Zlib-related constants. zlib.createBrotliCompress()It is used to create BrotliCompress object. zlib.createBrotliDecompress()
2 min read
Node.js Process Complete Reference
A process object is a global object that gives information about and controls the node.js process. As it is global, it can be used in the project without importing it from any module. Table of Content Understanding Node.js ProcessesEvents and Event-driven ArchitectureExecution Models and Asynchronous ProgrammingUnderstanding Node.js ProcessesSingle
5 min read
Node.js File System Complete Reference
Node.js File System module is used to handle file operations like creating, reading, deleting, etc. Node.js provides an inbuilt module called FS (File System). Node.js gives the functionality of file I/O by providing wrappers around the standard POSIX functions. All file system operations can have synchronous and asynchronous forms depending on use
15+ min read
Node.js Questions Complete Reference
Most people are confused and understand it’s a framework or a programming language. We often use Node.js for building back-end services like APIs like Web App or Mobile App. It’s used in production by large companies such as Paypal, Uber, Netflix, Walmart, and so on. You need to remember that NodeJS is not a framework, and it’s not a programming la
13 min read
Node.js Console Complete Reference
The console module in Node.js provides a set of functions to output information to the terminal or command line, helping with debugging and logging. It is a built-in utility that is essential for monitoring and troubleshooting Node.js applications. It is a global object that provides a simple debugging console similar to JavaScript to display diffe
4 min read
Node.js DNS Complete Reference
Node.js DNS is a node module used to do name resolution facility which is provided by the operating system as well as used to do an actual DNS lookup. Example: [GFGTABS] JavaScript <script> // Node.js program to demonstrate the // dns.resolve() method // Accessing dns module const dns = require('dns'); // Set the rrtype for dns.resolv
3 min read
PHP Calendar Functions Complete Reference
The calendar extension contains a series of functions to represent the calendar date into a different format. The standard date is based on Julian Day Count. The date count starting from January 1st, 4713 B.C. is known as Julian Day Count. First, the date is converted into Julian Day Count and then converted into a calendar system. Example: The pro
2 min read
Blaze UI Objects Complete Reference
Blaze UI is a free & open-source (MIT Licence) Framework with a lightweight UI Toolkit that provides a great structure for building websites quickly with a scalable and maintainable foundation Blaze UI Objects List: Blaze UI Containers Blaze UI Container sizesBlaze UI Containers NestingBlaze UI Containers Vertical AlignmentBlaze UI Container Re
1 min read
CSS Selectors Complete Reference
CSS selectors are used to select HTML elements based on their element name, id, class, attribute, and many more. Example: Below the HTML/CSS code shows the functionality of ::after selector. C/C++ Code <!DOCTYPE html> <html> <head> <style> p::after { content: " - Remember this"; background-color: blue; } </style
4 min read
jQuery Mobile Pagecontainer Widget Complete Reference
jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. The Pagecontainer Widget is used to manage the collection of pages in jQuery Mobile. jQuery Mobile Pagecontainer Widget Options jQuery Mobile Pagecontainer classes OptionjQuery Mobile Pagecontainer defaults Optionj
1 min read
Foundation CSS Utilities Complete Reference
Foundation CSS has different types of utility like Prototyping Utilities Sizing is used to give width and height to an element. There is a various utility that helps to make it easy for us. Complete list Foundation CSS Utility are listed below: Foundation CSS Prototyping Utilities Foundation CSS Prototyping Utilities Enable Prototype ModeFoundation
2 min read
TensorFlow.js Browser Complete Reference
TensorFlow.js is an open-source JavaScript library designed by Google to develop Machine Learning models and deep learning neural networks. TensorFlow.js Browser Functions: TensorFlow.js tf.browser.fromPixels() FunctionTensorFlow.js tf.browser.fromPixelsAsync() FunctionTensorFlow.js tf.browser.toPixels() Function
1 min read
jQuery Mobile Loader Widget Complete Reference
jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. Loader Widget is used to display the loading dialog when jQuery Mobile pulls in content via Ajax. jQuery Mobile Loader Widget Options jQuery Mobile Loader classes OptionjQuery Mobile Loader defaults OptionjQuery Mo
1 min read
three90RightbarBannerImg