Node.js zlib.brotliDecompress() Method Last Updated : 12 Oct, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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, 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.brotliDecompress() method in Node.js: Example 1: javascript // Node.js program to demonstrate the // brotliDecompress() method // Including zlib module const zlib = require("zlib"); // Declaring input and assigning // it a value string var input = "Computer Science"; // Calling brotliCompress method zlib.brotliCompress(input, (err, buffer) => { // Calling brotliDecompress zlib.brotliDecompress(buffer, (err, buffer) => { console.log(buffer.toString('base64')); }); }); Output: Q29tcHV0ZXIgU2NpZW5jZQ== Example 2: javascript // Node.js program to demonstrate the // brotliDecompress() method // Including zlib module const zlib = require("zlib"); // Declaring input and assigning // it a value string var input = "Computer Science"; // Calling brotliCompress method zlib.brotliCompress(input, (err, buffer) => { // Calling brotliDecompress zlib.brotliDecompress(buffer, (err, buffer) => { console.log(buffer.toString('bas64')); }); }); Output: buffer.js:631 throw new ERR_UNKNOWN_ENCODING(encoding); ^ TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: bas64 at stringSlice (buffer.js:631:9) at Buffer.toString (buffer.js:667:10) at BrotliDecompress.zlib.brotliDecompress [as cb] (/home/runner/BeautifulMiserlySourcecode/index.js:18:28) at BrotliDecompress.zlibBufferOnEnd (zlib.js:133:10) at BrotliDecompress.emit (events.js:203:15) at BrotliDecompress.EventEmitter.emit (domain.js:448:20) at endReadableNT (_stream_readable.js:1143:12) at process._tickCallback (internal/process/next_tick.js:63:19)? Here, an error occurs while encoding so, an error is thrown. Reference: https://nodejs.org/api/zlib.html#zlib_zlib_brotlidecompress_buffer_options_callback Comment More infoAdvertise with us N nidhi1352singh Follow Improve Article Tags : Web Technologies Node.js Node.js-Zlib-module Similar Reads 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: javascript // Node.js program to demonstrate // 4 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 2 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 t 1 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. Retur 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 2 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. R 1 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 1 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. 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. 1 min read 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 Buff 2 min read Like