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

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



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the     
// createInflateRaw() method
  
// Including zlib module
var 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
  var gunzip = zlib.createInflateRaw();
  gunzip.write(data);
  gunzip.on('data', function (data)
   {
      console.log(data.toString());
  });
});

chevron_right


Output:

Decompressed..

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the     
// createInflateRaw() method
  
// Including zlib module
var 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
  var gunzip = zlib.createInflateRaw();
  gunzip.write(data);
  gunzip.on('data', function (data)
   {
      console.log(data.toString('base64'));
  });
});

chevron_right


Output:

RGVjb21wcmVzc2VkLi4=

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




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.