Compression
zlib.createGunzip()
Creates a gzip decompression transform. Streaming is not an output-size guarantee; count decoded bytes before writing them onward. Tested on Node.js 22.16.0. Example output (one line per entry): ["4"].
Formal Syntax & Structure
nodejs syntaxnodejs
zlib.createGunzip([options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| options | object | Stream and decompression options. |
Return Value
Gunzip
Decompression transform.
Working Example
Example Snippetnodejs
import { createGunzip, gzipSync } from 'node:zlib';import { Readable, Writable } from 'node:stream';import { pipeline } from 'node:stream/promises';let bytes = 0;await pipeline(Readable.from([gzipSync('book')]), createGunzip(), new Writable({ write(c, e, cb) { bytes += c.length; cb(bytes > 64 ? new Error('limit') : undefined); } }));console.log(bytes);