zlib
Zlib
Stability: 2 - Stable
The zlib
module provides compression functionality implemented using Gzip and Deflate/Inflate. It can be accessed using:
const zlib = require('zlib');
Compressing or decompressing a stream (such as a file) can be accomplished by piping the source stream data through a zlib
stream into a destination stream:
const gzip = zlib.createGzip(); const fs = require('fs'); const inp = fs.createReadStream('input.txt'); const out = fs.createWriteStream('input.txt.gz'); inp.pipe(gzip).pipe(out);
It is also possible to compress or decompress data in a single step:
const input = '.................................'; zlib.def