The zlib.inflate() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data.
Syntax:
javascript
Output:
javascript
Output:
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.
// 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'));
});
});
GeeksExample 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'));
});
});
4e696468692053696e6768Reference: https://nodejs.org/api/zlib.html#zlib_zlib_inflate_buffer_options_callback