crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Node.js ZLIB
Question Posted on 05 Apr 2024Home >> Tutorial >> Node.js Tutorial >> Node.js ZLIB

Node.js ZLIB

Node.js ZLIB


Main functionalities of Node.js ZLIB module is to provide option of compression and decompression (like we do Zip and Unzip). And this is implemented by using Gzip and deflate/inflate.

We can accessed zlib module by using below commands:-

const zlib = require('zlib');


Compressing and decompressing a file can be done by piping the source stream data into a destination stream through zlib stream.


Node.js ZLIB Example: Compress File


To understand this we will take an example of Node.js ZLIB module to compress file "input.txt" into "input.txt.gz".

File: zlib_example1.js


Node.js ZLIB Code
above is the code text file named "input.txt".


Node.js Input File
Now we open Node.js command prompt and run the following below code:-


Node.js decompress command
node zlibexample1.js


once the above .js file is run you will get the compressed file named "input.txt.gz" on the desktop as per the below screen.


Node.js compress file

Node.js ZLIB Example: Decompress File


Now we will do decomress the file by using Node.js ZLIB module and file is "input.txt.gz" into "input2.txt"

File: zlibexample2.js


Node.js decompress code
Now we open Node.js command prompt and run the following below code:-

node zlibexample2.js


Now you will get file once you run above. Now you will see that same code of "input.txt" is available into "input2.txt" file. command

Node.js file compress
0
0



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Parts of Node.js

Install Node.js Linux

Node.js First Example

Node.js Globals

Node.js DNS






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap