NodeHttpCompression
HTTP response compression backed by node:zlib, shared by the Node.js, Bun, and Deno platforms.
Byte-array bodies are compressed in one shot with the asynchronous node:zlib APIs, preserving an exact Content-Length. Streaming bodies go through node:zlib transform streams that flush each input chunk.
Constants
algorithms
Added in v4.0.0
Source
Signature
declare const algorithms: ReadonlySet<Platform.CompressionAlgorithm>;Constructors
compressTransform
Added in v4.0.0
Source
Creates a node:zlib compression transform stream that flushes each input chunk, for streaming response bodies.
Signature
declare function compressTransform(algorithm: CompressionAlgorithm, options?: any): Duplex;compressTransformWeb
Added in v4.0.0
Source
A Web ReadableStream version of compressTransform, for platforms that stream response bodies as Web streams.
Signature
declare function compressTransformWeb(
algorithm: CompressionAlgorithm,
options?: any,
): (
stream: ReadableStream<Uint8Array<ArrayBufferLike>>,
) => ReadableStream<Uint8Array<ArrayBufferLike>>;Creates a Compression that compresses byte-array bodies in one shot with the asynchronous node:zlib APIs, setting the exact Content-Length of the compressed body. All other bodies are delegated to fallback.
Signature
declare function make(fallback: Compression): Compression;
The compression algorithms supported by the runtime's
node:zlib.zstdrequires Node.js 22.15 or newer.