Skip to content

decompress

decompress(data, options?): Promise<Uint8Array<ArrayBuffer>>

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

Decompress data, in options.format or the format that detection finds in it.

The decoders are strict: data that ends before the end of the compressed stream, empty data included, fails with ERR_COMPRS_TRUNCATED, and data after its end with ERR_COMPRS_CORRUPT_DATA. zstd and lz4 data may hold several frames, and gzip data several members, which are decompressed one after the other. Without a format, data whose format detection does not find, empty data included, fails with ERR_COMPRS_UNKNOWN_FORMAT, as DecompressOptions.format describes.

The data and the bytes of a dictionary are copied when decompress() is called, so changing them afterwards does not change the result, and the call keeps using a Dictionary that is closed afterwards. In Node.js, the data is decompressed on a thread of the libuv pool. The browser build decompresses it on the calling thread, which it blocks, before decompress() returns.

An AbortOptions.signal withdraws the call.

Input

DecompressOptions<Format> & AbortOptions

Promise<Uint8Array<ArrayBuffer>>

A Promise of the decompressed data, which rejects on every error, invalid arguments included, with an ErrorCode as code, or with the reason of the signal once it aborts. decompress() itself never throws.