The Wayback Machine - https://web.archive.org/web/20241004161356/https://www.geeksforgeeks.org/node-js-zlib-complete-reference/
Open In App

Node.js Zlib Complete Reference

Last Updated : 28 Jul, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The zlib module provides compression functionality implemented using Gzip, Deflate/Inflate, and Brotli.

The Complete Reference of Zlib are listed below:

Methods

Description

zlib.constants It is used to yields an object listing Zlib-related constants.
zlib.createBrotliCompress() It is used to create BrotliCompress object.
zlib.createBrotliDecompress() It is used to create a new BrotliDecompress object.
zlib.createUnzip() It is used to create a new Unzip object.
zlib.createDeflateRaw() It is used to create a new DeflateRaw object.
zlib.createGunzip() It is used to create a new Gunzip object.
zlib.createInflateRaw() It is used to create a new InflateRaw object.
zlib.createDeflate() It is used to create a new Deflate object.
zlib.createInflate() It is used to create a new Inflate object.
zlib.gzip() It is used to compress a chunk of data.

Class: zlib.ZlibBase

Methods

Description

zlib.bytesWritten It is used to specify the number of bytes written to the engine before the bytes are processed.
zlib.close() It is used to close the underlying handle.
zlib.flush() It can compel zlib to return as much output as achievable at present.

Convenience Methods

Methods

Description

zlib.brotliCompress() It is used to compresses a chunk of data.
zlib.brotliCompressSync() It is used to compress a chunk of data with BrotliCompress.
zlib.brotliDecompress() It is used to decompresses a chunk of data with BrotliCompress.
zlib.brotliDecompressSync() is used to decompress a chunk of data with BrotliDecompress.
zlib.deflate() It is used to compress a chunk of data.
zlib.deflateSync() It is used to compress a chunk of data with Deflate.
zlib.deflateRaw() It is used to compress a chunk of data.
zlib.deflateRawSync() It is used to compress a chunk of data with DeflateRaw.
zlib.gunzip() It is used to decompress a chunk of data.
zlib.gunzipSync() It is used to decompress a chunk of data with Gunzip.
zlib.createGzip() It is used to create a new Gzip object.
zlib.gzipSync() It is used to compress a chunk of data with Gzip.
zlib.inflate() It is used to decompress a chunk of data.
zlib.inflateSync() It is used to decompress a chunk of data with Inflate.
zlib.inflateRaw() It is used to decompress a chunk of data.
zlib.inflateRawSync() It is used to decompress a chunk of data with InflateRaw.
zlib.unzip() It is used to decompress a chunk of data.
zlib.unzipSync() It is used to decompress a chunk of data with Unzip.

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
Node.js zlib.createGunzip() Method
The zlib.createGunzip() method is an inbuilt application programming interface of the Zlib module which is used to create a new Gunzip object. Syntax: zlib.createGunzip( options ) Parameters: This method accepts single parameter options which is an optional parameter that holds the zlib options. Return Value: It returns a new Gunzip object. The bel
1 min read
Node.js zlib.createGzip() Method
The zlib.createGzip() method is an inbuilt application programming interface of the Zlib module which is used to create a new Gzip object. Syntax: zlib.createGzip( options ) Parameters: This method accepts single parameter options which is optional parameter that holds the zlib options. Return Value: It returns a new Gzip object. Below examples ill
2 min read
Node.js zlib.unzip() Method
The zlib.unzip() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data. Syntax: zlib.unzip( 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 stri
2 min read
Node.js zlib.gunzip() Method
The zlib.gunzip() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data. Syntax: zlib.gunzip( 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 st
2 min read
Node.js zlib.inflateRaw() Method
The zlib.inflateRaw() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data. Syntax: zlib.inflateRaw( 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
2 min read
Node.js zlib.deflateRaw() Method
The zlib.deflateRaw() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data. Syntax: zlib.deflateRaw( 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,
1 min read
Node.js zlib.inflate() Method
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
2 min read
Node.js zlib.flush() Method
The flush() method is called on a compression stream so that it can compel zlib to return as much output as achievable at present. This output may be returned at the cost of corrupt compression quality but it can be useful when data is required to be accessible as early as possible. Syntax: zlib.flush() Parameters: This method does not accept any p
2 min read
Node.js zlib.constants Property
The zlib.constants property is used to yields an object listing Zlib-related constants. Syntax: zlib.constants Return Value: It returns all the Zlib-related constants. Below examples illustrate the use of zlib.constants property in Node.js: Example 1: // Node.js program to demonstrate // zlib.constants property // Including zlib module const zlib =
4 min read
Node.js zlib.bytesWritten Property
The zlib.bytesWritten property is an application programming interface of the zlib module which is used to specify the number of bytes written to the engine before the bytes are processed (compressed or decompressed, as proper for the derived class). Syntax: zlib.bytesWritten Return Value: It returns the number of bytes written to the engine. The b
2 min read
Node.js zlib.gunzipSync() Method
The zlib.gunzipSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with Gunzip. Syntax: zlib.gunzipSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer, TypedArray,
1 min read
Node.js zlib.gzipSync() Method
The zlib.gzipSync() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data with Gzip. Syntax: zlib.gzipSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer, TypedArray, DataVie
2 min read
Node.js zlib.brotliDecompressSync() Method
The zlib.brotliDecompressSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with BrotliDecompress. Syntax: zlib.brotliDecompressSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buff
1 min read
Node.js zlib.deflateRawSync() Method
The zlib.deflateRawSync() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data with DeflateRaw. Syntax: zlib.deflateRawSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer, T
1 min read
Node.js zlib.inflateRawSync() Method
The zlib.inflateRawSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with InflateRaw. Syntax: zlib.inflateRawSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer,
2 min read
Node.js zlib.inflateSync() Method
The zlib.inflateSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with Inflate. Syntax: zlib.inflateSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer, TypedArr
1 min read
Node.js zlib.deflateSync() Method
The zlib.deflateSync() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data with Deflate. Syntax: zlib.deflateSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: This parameter holds the buffer of type Buffer, TypedArray
2 min read
Node.js zlib.close() Method
The zlib.close() method is an inbuilt application programming interface of the Zlib module which is used to close the underlying handle. Syntax: zlib.close( callback ) Parameters: This method accepts single parameter callback which holds the callback function. Below examples illustrate the use of zlib.close() method in Node.js: Example 1: // Node.j
1 min read
Node.js zlib.deflate() Method
The zlib.deflate() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data. Syntax: zlib.deflate( buffer, options, callback ) Parameters: This method accept three parameters as mentioned above and described below: buffer: It can be of type Buffer, TypedArray, DataView, ArrayBuffer, and str
2 min read
Node.js zlib.unzipSync() Method
The zlib.unzipSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with Unzip. Syntax: zlib.unzipSync( buffer, options ) Parameters: This method accepts two parameters as mentioned above and described below: buffer: It can be of type Buffer, TypedArray, DataView, ArrayBuffer, a
1 min read