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
The compression algorithms supported by the runtime's node:zlib. zstd
requires Node.js 22.15 or newer.
Signature
declare const algorithms: ReadonlySet<Platform.CompressionAlgorithm>Constructors
compressTransform
Creates a node:zlib compression transform stream that flushes each input
chunk, for streaming response bodies.
Signature
declare function compressTransform(algorithm: CompressionAlgorithm, options?: CompressionOptions): DuplexcompressTransformWeb
A Web ReadableStream version of compressTransform, for platforms that
stream response bodies as Web streams.
Signature
declare function compressTransformWeb(algorithm: CompressionAlgorithm, options?: CompressionOptions): (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