Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Node.js Zlib Module

❮ Built-in Modules


Example

Compress a file (demofile.txt) into a gzip file (mygzipfile.txt.gz):

var zlib = require('zlib');
var fs = require('fs');

var gzip = zlib.createGzip();
var r = fs.createReadStream('./demofile.txt');
var w = fs.createWriteStream('./mygzipfile.txt.gz');
r.pipe(gzip).pipe(w);

Definition and Usage

The Zlib module provides a way of zip and unzip files.


Syntax

The syntax for including the Zlib module in your application:

var zlib = require('zlib');

Zlib Properties and Methods

Method Description
constants Returns an object containing Zlib constants
createDeflate() Creates a Deflate object
createDeflateRaw() Creates a DeflateRaw object
createGunzip() Creates a Gunzip object
createGzip() Creates a Gzip object
createInflate() Creates a Inflate object
createInflateRaw() Creates a InflateRaw object
createUnzip() Creates a Unzip object
deflate() Compress a string or buffer, using Deflate
deflateSync() Compress a string or buffer, syncronously, using Deflate
deflateRaw() Compress a string or buffer, using DeflateRaw
deflateRawSync() Compress a string or buffer, syncronously, using DeflateRaw
gunzip() Compress a string or buffer, using Gunzip
gunzipSync() Compress a string or buffer, syncronously, using Gunzip
gzip() Compress a string or buffer, using Gzip
gzipSync() Compress a string or buffer, syncronously, using Gzip
inflate() Decompress a string or buffer, using Inflate
inflateSync() Decompress a string or buffer, syncronously, using Inflate
inflateRaw() Decompress a string or buffer, using InflateRaw
inflateRawSync() Decompress a string or buffer, syncronously, using InflateRaw
unzip() Decompress a string or buffer, using Unzip
unzipSync() Decompress a string or buffer, syncronously, using Unzip

❮ Built-in Modules

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.