Open In App

Node.js zlib.createInflateRaw() Method

Last Updated : 03 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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 object.

The below examples illustrate the use of zlib.createInflateRaw() method in Node.js: 

Example 1: 

javascript




// Node.js program to demonstrate the   
// createInflateRaw() method
 
// Including zlib module
const zlib = require('zlib');
 
// Calling deflateRaw function to compress data
zlib.deflateRaw('Decompressed..', function (err, data) {
    if (err) {
        return console.log('err', err);
    }
 
    // Calling createInflateRaw method
    // to decompress the data again
    const gunzip = zlib.createInflateRaw();
    gunzip.write(data);
    gunzip.on('data', function (data) {
        console.log(data.toString());
    });
});


Output:

Decompressed..

Example 2: 

javascript




// Node.js program to demonstrate the   
// createInflateRaw() method
 
// Including zlib module
const zlib = require('zlib');
 
// Calling deflateRaw function to compress data
zlib.deflateRaw('Decompressed..', function (err, data) {
    if (err) {
        return console.log('err', err);
    }
 
    // Calling createInflateRaw method
    // to decompress the data again
    const gunzip = zlib.createInflateRaw();
    gunzip.write(data);
    gunzip.on('data', function (data) {
        console.log(data.toString('base64'));
    });
});


Output:

RGVjb21wcmVzc2VkLi4=

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



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

Similar Reads