Skip to content

DecompressionStream

Defined in: next/api.d.ts:553

A ponyfill of DecompressionStream of the Compression Streams standard: it decompresses the chunks written to its DecompressionStream.writable side into the chunks read from its DecompressionStream.readable side, in any Format, or in the format that it detects, with the options of decompress. Pipe data through it with pipeThrough(). It neither replaces nor uses the global DecompressionStream.

The chunks are read and written as for CompressionStream, and the stream decodes as strictly as decompress does: data that ends before the end of the compressed stream, empty data included, errors the stream with ERR_COMPRS_TRUNCATED once the writable side closes, data after its end with ERR_COMPRS_CORRUPT_DATA, and output beyond maxOutputSize with ERR_COMPRS_SIZE_LIMIT.

With 'auto', the stream holds the start of its input until it detects the format, which takes at most 64 KiB, and then decodes as in that format, from the start. It detects the formats that decompress detects, but a zstd or lz4 frame only if its magic number comes in the first 64 KiB, after any skippable frames, and it knows brotli data only once its start decodes to more bytes than it holds, or once the input ends. Input that it does not recognize errors the stream with ERR_COMPRS_UNKNOWN_FORMAT. With a Dictionary, 'auto' stands for the format of the dictionary.

In Node.js, expensive chunks are decompressed on the libuv thread pool, as for CompressionStream.

new DecompressionStream(format, options?): DecompressionStream

Defined in: next/api.d.ts:563

Create a stream that decompresses in format, or in the format that it detects with 'auto', with options, which are checked here, as decompressSync checks them.

Format | "auto"

DecompressionStreamOptions

DecompressionStream

An error with an ErrorCode as code, such as ERR_COMPRS_INVALID_ARG for an unknown format or an invalid option.

get [toStringTag](): string

Defined in: next/api.d.ts:568

string


get readable(): ReadableStream<Uint8Array<ArrayBuffer>>

Defined in: next/api.d.ts:565

The side to read the decompressed data from.

ReadableStream<Uint8Array<ArrayBuffer>>


get writable(): WritableStream<Input>

Defined in: next/api.d.ts:567

The side to write the data to decompress to.

WritableStream<Input>