assert: * (SEMVER-MAJOR) allow printf-style messages as assertion error (Ruben Bridgewater) https://github.com/nodejs/node/pull/58849 build: * (SEMVER-MAJOR) bump GCC requirement to 13.2 (Michaël Zasso) https://github.com/nodejs/node/pull/62555 * (SEMVER-MAJOR) enable Temporal by default (Richard Lau) https://github.com/nodejs/node/pull/61806 * (SEMVER-MAJOR) enable V8_VERIFY_WRITE_BARRIERS in debug build (Joyee Cheung) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) reset embedder string to "-node.0" (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) target Power 9 for AIX/IBM i (Richard Lau) https://github.com/nodejs/node/pull/62296 * (SEMVER-MAJOR) drop support for Python 3.9 (Mike McCready) https://github.com/nodejs/node/pull/61177 * (SEMVER-MAJOR) enable maglev for Linux on s390x (Richard Lau) https://github.com/nodejs/node/pull/60863 * (SEMVER-MAJOR) reset embedder string to "-node.0" (Michaël Zasso) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) reset embedder string to "-node.0" (Michaël Zasso) https://github.com/nodejs/node/pull/60111 build,test: * (CVE-2026-21717) (SEMVER-MAJOR) test array index hash collision (Joyee Cheung) https://github.com/nodejs/node/pull/61898 build,win: * (SEMVER-MAJOR) fix Temporal build (StefanStojanovic) https://github.com/nodejs/node/pull/61806 crypto: * (SEMVER-MAJOR) unify asymmetric key import through KeyObjectHandle::Init (Filip Skokan) https://github.com/nodejs/node/pull/62499 * (SEMVER-MAJOR) runtime-deprecate DEP0203 and DEP0204 (Filip Skokan) https://github.com/nodejs/node/pull/62453 * (SEMVER-MAJOR) decorate async crypto job errors with OpenSSL error details (Filip Skokan) https://github.com/nodejs/node/pull/62348 * (SEMVER-MAJOR) default ML-KEM and ML-DSA pkcs8 export to seed-only format (Filip Skokan) https://github.com/nodejs/node/pull/62178 * (SEMVER-MAJOR) move DEP0182 to End-of-Life (Tobias Nießen) https://github.com/nodejs/node/pull/61084 * (SEMVER-MAJOR) fix DOMException name for non-extractable key error (Filip Skokan) https://github.com/nodejs/node/pull/60830 deps: * (SEMVER-MAJOR) V8: cherry-pick 0f024d4e66e0 (ishabi) https://github.com/nodejs/node/pull/62408 * (SEMVER-MAJOR) fix V8 race condition for AIX (Abdirahim Musse) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick cd2c216e7658 (LuYahan) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: backport 088b7112e7ab (Igor Sheludko) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick 00f6e834029f (Joyee Cheung) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: backport bef0d9c1bc90 (Joyee Cheung) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick cf1bce40a5ef (Richard Lau) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick daf4656ba85e (Milad Fa) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick d83f479604c8 (Joyee Cheung) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick edeb0a4fa181 (Joyee Cheung) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick aa0b288f87cc (Richard Lau) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) patch V8 to fix Windows build (StefanStojanovic) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) V8: cherry-pick highway@989a498fdf3 (Richard Lau) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) support madvise(3C) across ALL illumos revisions (Dan McDonald) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) patch V8 for illumos (Dan McDonald) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) remove problematic comment from v8-internal (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) define V8_PRESERVE_MOST as no-op on Windows (Stefan Stojanovic) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) patch V8 to avoid duplicated zlib symbol (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update V8 to 14.6.202.33 (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update undici to 8.0.2 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/62384 * (SEMVER-MAJOR) V8: backport 151d0a44a1b2 (Abdirahim Musse) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) V8: cherry-pick 47800791b35c (Jakob Kummerow) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) patch V8 for illumos (Dan McDonald) https://github.com/nodejs/node/pull/59805 * (SEMVER-MAJOR) use std::map in MSVC STL for EphemeronRememberedSet (Joyee Cheung) https://github.com/nodejs/node/pull/58070 * (SEMVER-MAJOR) remove problematic comment from v8-internal (Michaël Zasso) https://github.com/nodejs/node/pull/58070 * (SEMVER-MAJOR) patch V8 to avoid duplicated zlib symbol (Michaël Zasso) https://github.com/nodejs/node/pull/54077 * (SEMVER-MAJOR) update V8 to 14.3.127.12 (Michaël Zasso) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) V8: cherry-pick ff34ae20c8e3 (Chengzhong Wu) https://github.com/nodejs/node/pull/60111 * (SEMVER-MAJOR) V8: backport fed47445bbdd (Abdirahim Musse) https://github.com/nodejs/node/pull/60111 * (SEMVER-MAJOR) patch V8 for illumos (Dan McDonald) https://github.com/nodejs/node/pull/59805 * (SEMVER-MAJOR) use std::map in MSVC STL for EphemeronRememberedSet (Joyee Cheung) https://github.com/nodejs/node/pull/58070 * (SEMVER-MAJOR) remove problematic comment from v8-internal (Michaël Zasso) https://github.com/nodejs/node/pull/58070 * (SEMVER-MAJOR) patch V8 to avoid duplicated zlib symbol (Michaël Zasso) https://github.com/nodejs/node/pull/54077 * (SEMVER-MAJOR) update V8 to 14.2.231.9 (Michaël Zasso) https://github.com/nodejs/node/pull/60111 diagnostics_channel: * (SEMVER-MAJOR) ensure tracePromise consistency with non-Promises (René) https://github.com/nodejs/node/pull/61766 doc: * (SEMVER-MAJOR) remove extensionless CJS exception for type:module packages (Matteo Collina) https://github.com/nodejs/node/pull/62176 * (SEMVER-MAJOR) update supported Windows SDK version to 11 (Mike McCready) https://github.com/nodejs/node/pull/61973 * (SEMVER-MAJOR) drop p8 and z13 support (Milad Fa) https://github.com/nodejs/node/pull/61005 http: * (SEMVER-MAJOR) move writeHeader to end-of-life (Sebastian Beltran) https://github.com/nodejs/node/pull/60635 * (SEMVER-MAJOR) fix handling of HTTP upgrades with bodies (Tim Perry) https://github.com/nodejs/node/pull/60016 lib: * (SEMVER-MAJOR) return undefined for localStorage without file (Matteo Collina) https://github.com/nodejs/node/pull/61333 lib,src: * (SEMVER-MAJOR) implement QuotaExceededError as DOMException-derived interface (Filip Skokan) https://github.com/nodejs/node/pull/62293 module: * (SEMVER-MAJOR) runtime-deprecate module.register() (Geoffrey Booth) https://github.com/nodejs/node/pull/62401 * (SEMVER-MAJOR) remove --experimental-transform-types (Marco Ippolito) https://github.com/nodejs/node/pull/61803 src: * (SEMVER-MAJOR) replace uses of deprecated v8::External APIs (gahaas) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) stop using `v8::PropertyCallbackInfo<T>::This()` (Igor Sheludko) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) avoid deprecated Wasm API (Clemens Backes) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) avoid deprecated `FixedArray::Get` (Clemens Backes) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update NODE_MODULE_VERSION to 147 (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) remove deprecated and unused isolate fields (Michaël Zasso) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) update NODE_MODULE_VERSION to 144 (Michaël Zasso) https://github.com/nodejs/node/pull/60488 * (SEMVER-MAJOR) include `node_api_types.h` instead of `node_api.h` in `node.h` (Anna Henningsen) https://github.com/nodejs/node/pull/60496 * (SEMVER-MAJOR) update NODE_MODULE_VERSION to 142 (Michaël Zasso) https://github.com/nodejs/node/pull/60111 stream: * (SEMVER-MAJOR) promote DEP0201 to runtime deprecation (René) https://github.com/nodejs/node/pull/62173 * (SEMVER-MAJOR) move _stream_* to end-of-life (Sebastian Beltran) https://github.com/nodejs/node/pull/60657 * (SEMVER-MAJOR) readable read one buffer at a time (Robert Nagy) https://github.com/nodejs/node/pull/60441 * (SEMVER-MAJOR) preserve AsyncLocalStorage on finished only when needed (avcribl) https://github.com/nodejs/node/pull/59873 test: * (SEMVER-MAJOR) skip wasm allocation tests in workers (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update wpt Wasm jsapi expectations (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) support presence of Temporal global (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) add type tags to uses of v8::External (gahaas) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) fix test-linux-perf-logger for V8 14.3 (Michaël Zasso) https://github.com/nodejs/node/pull/60488 tools: * (SEMVER-MAJOR) remove v8_initializers_slow workaround from v8.gyp (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) add Rust args to `tools/make-v8.sh` (Richard Lau) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update V8 gypfiles for 14.6 (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update V8 gypfiles for 14.5 (Michaël Zasso) https://github.com/nodejs/node/pull/61898 * (SEMVER-MAJOR) update V8 gypfiles for 14.4 (Michaël Zasso) https://github.com/nodejs/node/pull/61898 util: * (SEMVER-MAJOR) mark proxied objects as such when inspecting them (Ruben Bridgewater) https://github.com/nodejs/node/pull/61029 * (SEMVER-MAJOR) reduce TextEncoder.encodeInto function size (Yagiz Nizipli) https://github.com/nodejs/node/pull/60339 PR-URL: https://github.com/nodejs/node/pull/62526
8.9 KiB
Iterable Compression
Stability: 1 - Experimental
The node:zlib/iter module provides compression and decompression transforms
for use with the node:stream/iter iterable streams API.
This module is available only when the --experimental-stream-iter CLI flag
is enabled.
Each algorithm has both an async variant (stateful async generator, for use
with pull() and pipeTo()) and a sync variant (stateful sync
generator, for use with pullSync() and pipeToSync()).
The async transforms run compression on the libuv threadpool, overlapping I/O with JavaScript execution. The sync transforms run compression directly on the main thread.
Note: The defaults for these transforms are tuned for streaming throughput, and differ from the defaults in
node:zlib. In particular, gzip/deflate default to level 4 (not 6) and memLevel 9 (not 8), and Brotli defaults to quality 6 (not 11). These choices match common HTTP server configurations and provide significantly faster compression with only a small reduction in compression ratio. All defaults can be overridden via options.
import { from, pull, bytes, text } from 'node:stream/iter';
import { compressGzip, decompressGzip } from 'node:zlib/iter';
// Async round-trip
const compressed = await bytes(pull(from('hello'), compressGzip()));
const original = await text(pull(from(compressed), decompressGzip()));
console.log(original); // 'hello'
const { from, pull, bytes, text } = require('node:stream/iter');
const { compressGzip, decompressGzip } = require('node:zlib/iter');
async function run() {
const compressed = await bytes(pull(from('hello'), compressGzip()));
const original = await text(pull(from(compressed), decompressGzip()));
console.log(original); // 'hello'
}
run().catch(console.error);
import { fromSync, pullSync, textSync } from 'node:stream/iter';
import { compressGzipSync, decompressGzipSync } from 'node:zlib/iter';
// Sync round-trip
const compressed = pullSync(fromSync('hello'), compressGzipSync());
const original = textSync(pullSync(compressed, decompressGzipSync()));
console.log(original); // 'hello'
const { fromSync, pullSync, textSync } = require('node:stream/iter');
const { compressGzipSync, decompressGzipSync } = require('node:zlib/iter');
const compressed = pullSync(fromSync('hello'), compressGzipSync());
const original = textSync(pullSync(compressed, decompressGzipSync()));
console.log(original); // 'hello'
compressBrotli([options])
compressBrotliSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).params{Object} Key-value object where keys and values arezlib.constantsentries. The most important compressor parameters are:BROTLI_PARAM_MODE--BROTLI_MODE_GENERIC(default),BROTLI_MODE_TEXT, orBROTLI_MODE_FONT.BROTLI_PARAM_QUALITY-- ranges fromBROTLI_MIN_QUALITYtoBROTLI_MAX_QUALITY. Default:6(notBROTLI_DEFAULT_QUALITYwhich is 11). Quality 6 is appropriate for streaming; quality 11 is intended for offline/build-time compression.BROTLI_PARAM_SIZE_HINT-- expected input size. Default:0(unknown).BROTLI_PARAM_LGWIN-- window size (log2). Default:20(1 MB). The Brotli library default is 22 (4 MB); the reduced default saves memory without significant compression impact for streaming workloads.BROTLI_PARAM_LGBLOCK-- input block size (log2). See the Brotli compressor options in the zlib documentation for the full list.
dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a Brotli compression transform. Output is compatible with
zlib.brotliDecompress() and decompressBrotli()/decompressBrotliSync().
compressDeflate([options])
compressDeflateSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).level{number} Compression level (0-9). Default:4.windowBits{number} Default:Z_DEFAULT_WINDOWBITS(15).memLevel{number} Default:9.strategy{number} Default:Z_DEFAULT_STRATEGY.dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a deflate compression transform. Output is compatible with
zlib.inflate() and decompressDeflate()/decompressDeflateSync().
compressGzip([options])
compressGzipSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).level{number} Compression level (0-9). Default:4.windowBits{number} Default:Z_DEFAULT_WINDOWBITS(15).memLevel{number} Default:9.strategy{number} Default:Z_DEFAULT_STRATEGY.dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a gzip compression transform. Output is compatible with zlib.gunzip()
and decompressGzip()/decompressGzipSync().
compressZstd([options])
compressZstdSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).params{Object} Key-value object where keys and values arezlib.constantsentries. The most important compressor parameters are:ZSTD_c_compressionLevel-- Default:ZSTD_CLEVEL_DEFAULT(3).ZSTD_c_checksumFlag-- generate a checksum. Default:0.ZSTD_c_strategy-- compression strategy. Values includeZSTD_fast,ZSTD_dfast,ZSTD_greedy,ZSTD_lazy,ZSTD_lazy2,ZSTD_btlazy2,ZSTD_btopt,ZSTD_btultra,ZSTD_btultra2. See the Zstd compressor options in the zlib documentation for the full list.
pledgedSrcSize{number} Expected uncompressed size (optional hint).dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a Zstandard compression transform. Output is compatible with
zlib.zstdDecompress() and decompressZstd()/decompressZstdSync().
decompressBrotli([options])
decompressBrotliSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).params{Object} Key-value object where keys and values arezlib.constantsentries. Available decompressor parameters:BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION-- boolean flag affecting internal memory allocation.BROTLI_DECODER_PARAM_LARGE_WINDOW-- boolean flag enabling "Large Window Brotli" mode (not compatible with RFC 7932). See the Brotli decompressor options in the zlib documentation for details.
dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a Brotli decompression transform.
decompressDeflate([options])
decompressDeflateSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).windowBits{number} Default:Z_DEFAULT_WINDOWBITS(15).dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a deflate decompression transform.
decompressGzip([options])
decompressGzipSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).windowBits{number} Default:Z_DEFAULT_WINDOWBITS(15).dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a gzip decompression transform.
decompressZstd([options])
decompressZstdSync([options])
options{Object}chunkSize{number} Output buffer size. Default:65536(64 KB).params{Object} Key-value object where keys and values arezlib.constantsentries. Available decompressor parameters:ZSTD_d_windowLogMax-- maximum window size (log2) the decompressor will allocate. Limits memory usage against malicious input. See the Zstd decompressor options in the zlib documentation for details.
dictionary{Buffer|TypedArray|DataView}
- Returns: {Object} A stateful transform.
Create a Zstandard decompression transform.