Open In App

Node.js v8.Serializer.writeHeader() Method

Last Updated : 28 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The v8.Serializer.writeHeader() method is an inbuilt application programming interface of the v8.Serializer module, is used to write out a header, that contains the serialization format version.

Syntax:

v8.Serializer.writeHeader();

Parameters: This method does not have any parameters.

Return Value: This method does not return anything but writes a header to the internal buffer.

Below examples illustrate the use of v8.Serializer.writeHeader() method in Node.js.

Example 1: Filename: index.js




// Accessing v8 module
const v8 = require('v8');
const serializer = new v8.Serializer();
  
// Calling v8.serializer.writeHeader() 
console.log(serializer.releaseBuffer());
console.log(serializer.writeHeader());
console.log(serializer.releaseBuffer());


Run index.js file using the following command:

node index.js

Output:

<Buffer >
undefined
<Buffer ff 0d>

Example 2: Filename: index.js




// Accessing v8 module
const v8 = require('v8');
const serializer = new v8.Serializer();
  
// Calling v8.serializer.writeHeader() 
console.log(serializer.writeHeader());


Run index.js file using the following command:

node index.js

Output:

undefined

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads