Open In App

Node.js zlib.inflate() Method

Last Updated : 12 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The zlib.inflate() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data.

Syntax:

zlib.inflate( buffer, options, callback )

Parameters: This method accepts three parameters as mentioned above and described below:

  • buffer: It can be of type Buffer, TypedArray, DataView, ArrayBuffer, and string.
  • options: It is an optional parameter that holds the zlib options.
  • callback: It holds the callback function.

Return Value: It returns the chunk of data after decompression.

Below examples illustrate the use of zlib.inflate() method in Node.js:

Example 1:




// Node.js program to demonstrate the     
// inflate() method
   
// Including zlib module
const zlib = require("zlib");
   
// Declaring input and assigning
// it a value string
var input = "Geeks";
   
// Calling deflate method
zlib.deflate(input, (err, buffer) => {
   
  // Calling inflate method
  zlib.inflate(buffer, (err, buffer) => {
    console.log(buffer.toString('utf8'));
  });
});


Output:

Geeks

Example 2:




// Node.js program to demonstrate the     
// inflate() method
   
// Including zlib module
const zlib = require("zlib");
   
// Declare input and assign
// it a value string
var input = "Nidhi Singh";
   
// Calling deflate method
zlib.deflate(input, (err, buffer) => {
   
  // Calling inflate method
  zlib.inflate(buffer, (err, buffer) => {
    console.log(buffer.toString('hex'));
  });
});


Output:

4e696468692053696e6768

Reference: https://nodejs.org/api/zlib.html#zlib_zlib_inflate_buffer_options_callback



Previous Article
Next Article

Similar Reads

Node.js zlib.gzip() Method
The zlib.gzip() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data. Syntax: zlib.gzip( buffer, options, callback ) Parameters: This method accepts three parameters as mentioned above and described below: buffer: It can be of type Buffer, TypedArray, DataView, ArrayBuffer, and string.o
2 min read
Node.js zlib.brotliCompress() Method
The zlib.brotliCompress() method is an inbuilt application programming interface of the Zlib module which is used to compresses a chunk of data. Syntax: zlib.brotliCompress( buffer, options, callback ) Parameters: This method accepts three parameters as mentioned above and described below: buffer: It can be of type Buffer, TypedArray, DataView, Arr
1 min read
Node.js zlib.brotliDecompress() Method
The zlib.brotliDecompress() method is an inbuilt application programming interface of the Zlib module which is used to decompresses a chunk of data with BrotliCompress. Syntax: zlib.brotliDecompress( buffer, options, callback ) Parameters: This method accepts three parameters as mentioned above and described below: buffer: It can be of type Buffer,
2 min read
Node.js zlib.createDeflateRaw() Method
The zlib.createDeflateRaw() method is an inbuilt application programming interface of the Zlib module which is used to create a new DeflateRaw object. Syntax: zlib.createDeflateRaw( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new DeflateRaw
2 min read
Node.js zlib.createDeflate() Method
The zlib.createDeflate() method is an inbuilt application programming interface of the Zlib module which is used to create a new Deflate object. Syntax: zlib.createDeflate( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new Deflate object. Bel
2 min read
Node.js zlib.createUnzip() Method
The zlib.createUnzip() method is an inbuilt application programming interface of the Zlib module which is used to create a new Unzip object. Syntax: zlib.createUnzip( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new Unzip object. The below e
2 min read
Node.js zlib.createInflateRaw() Method
The zlib.createInflateRaw() method is an inbuilt application programming interface of the Zlib module which is used to create a new InflateRaw object. Syntax: zlib.createInflateRaw( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new InflateRaw
1 min read
Node.js zlib.createBrotliCompress() Method
The zlib.createBrotliCompress() method is an inbuilt application programming interface of the Zlib module which is used to create BrotliCompress object. Syntax: zlib.createBrotliCompress( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new Brot
2 min read
Node.js zlib.createInflate() Method
The zlib.createInflate() method is an inbuilt application programming interface of the Zlib module which is used to create a new Inflate object. Syntax: zlib.createInflate( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new Inflate object. The
1 min read
Node.js zlib.createBrotliDecompress() Method
The zlib.createBrotliDecompress() method is an inbuilt application programming interface of the Zlib module which is used to create a new BrotliDecompress object. Syntax: zlib.createBrotliDecompress( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It return
1 min read