detectFormat
detectFormat(
data):CompressionFormat
Defined in: index.d.ts:1452
Detect the compression format of the given data.
Returns "zstd", "gzip", "brotli", or "lz4".
Returns "unknown" if the format cannot be determined.
zstd, gzip and LZ4 are recognized by their magic numbers, LZ4 legacy
frames (lz4 -l) included. Skippable frames at the start of the data,
which zstd and LZ4 share, are skipped: the frame after them decides.
Brotli has no magic number, so it is detected heuristically: up to the
first 64 KiB of the data are decoded, and the data is reported as
"brotli" if they decode without error and either hold a whole brotli
stream that ends with the data, decode to more bytes than they hold, or
fill the 64 KiB. The start of a brotli stream of data that does not
compress is thus reported as "unknown" until it is 64 KiB long, and
about 5% of random data of 64 KiB or more is reported as "brotli".
Raw deflate has no magic number and is not detected.
Parameters
Section titled “Parameters”Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>