Skip to content

tyrus:compress types ​

Types must be imported by name

CompressError, CompressFormat, CompressOptions, and DecompressOptions must be imported explicitly whenever their fields, members, or object literals are used.

CompressFormat ​

MemberFormat
GzipGzip, RFC 1952.
Deflatezlib, RFC 1950.
DeflateRawRaw Deflate, RFC 1951.
BrotliBrotli, RFC 7932.

See the formats for levels and detection.

CompressOptions ​

FieldTypeDefault
leveli32?6

DecompressOptions ​

FieldTypeDefault
formatCompressFormat?detected from the data
maxOutputBytesu64?256 MiB for decompress, 4 GiB for decompressionStream
maxRatiou32?200

See decompress and decompressionStream for what each option does.

CompressError ​

CompressError is the recoverable error of every operation, delivered as the Err of the Result each function resolves with.

FieldTypeDescription
codestringStable identifier, such as ERR_COMPRESS_RATIO_LIMIT. See the error codes.
messagestringHuman-readable description.
tyrus
import { CompressError, decompress } from "tyrus:compress";

const main = async (): Promise<void> => {
    match (await decompress([1, 2, 3])) {
        Ok(original) => { print(original.length); }
        Err(error) => {
            const failure: CompressError = error;
            printError(failure.code); // ERR_COMPRESS_UNKNOWN_FORMAT
            printError(failure.message); // the format cannot be detected from the data; pass `format` in the options
        }
    }
};