The Node.js Zlib module is utilized to give compression and decompression (compress and unfasten) functionalities. It is implemented utilizing Gzip and empty/swell.
The zlib module can be gotten to using:
Compressing and decompressing a record should be possible by channeling the source stream information into a goal stream through zlib stream.
Node.js ZLIB Example: Compress File
Let's see a basic case of Node.js ZLIB module to compress a document "input.txt" into "input.txt.gz".
We have a text file named "input.txt" on the desktop.
You can see that it will simple a compressed file named "input.txt.gz" on the desktop.
Node.js ZLIB Example: Decompress File
Let's see a simple example of Node.js ZLIB module to decompress a file "input.txt.gz" into "input2.txt".
Now you will see that same code of "input.txt" is available into "input2.txt" file.