Skip to content

decompress

decompress(data, maxOutputSize?): Buffer

Defined in: index.d.ts:1352

Decompress data by auto-detecting the compression format.

Detects the format like detectFormat and decompresses using the appropriate algorithm.

maxOutputSize limits the decompressed size in bytes, like the maxOutputSize of createDecompressStream. It defaults to 256 MB for all formats. It is only a limit: a large value reserves no memory up front. For zstd input, it also bounds the window of a frame, as the capacity of zstdDecompressWithCapacity does.

Supported formats: zstd, gzip, brotli, lz4. Raw deflate is not supported (no magic bytes to distinguish it). Data detected as brotli that does not decode as brotli throws the same error as data of unknown format, since brotli detection is heuristic.

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

number | null

Buffer