/** * zlibmt: multi-threaded zlib, the block-parallel layout of zmat and jdai. * * A zlibmt stream is an ordinary zlib stream (any zlib reads it): the payload is deflated in * independent blocks (payload/16, from 256 KiB to 4 MiB, so the stream depends on the payload * alone, not on the number of threads), each but the last ended by a full flush (the empty stored * block 00 00 FF FF), joined after one zlib header, with the Adler-32 of the whole payload. * Encoding deflates the blocks in parallel; decoding inflates the stretches between such marks in * parallel, from any zlib stream, and keeps the result only when the lengths and the Adler-32 * agree (otherwise it inflates the stream as a whole), so every stream decodes correctly. * * Threads: Node's zlib thread pool (UV_THREADPOOL_SIZE, default 4) in Node.js; Web Workers * running this same script in browsers; else one thread (pako), still asynchronous. * * Copyright (c) 2019-2026 Qianqian Fang . BSD 3-clause license. */ /** Node's zlib module when running in Node.js (faster than pako), else null. */ export declare function nodeZlibModule(): any; /** The Adler-32 of bytes (from a, default 1). */ export declare function adler32(b: Uint8Array, a?: number): number; /** The Adler-32 of a followed by b, from their sums and b's length (zlib's adler32_combine). */ export declare function adler32Combine(a1: number, a2: number, len2: number): number; export interface Task { op: 'inflate' | 'gunzip' | 'deflate' | 'gzip' | 'deflateRaw' | 'inflateRaw'; data: Uint8Array; level?: number; /** deflateRaw: the last block (ends the stream) */ last?: boolean; /** inflateRaw: the expected output size, when known */ size?: number; /** also return the Adler-32 of the output (or, for deflateRaw, of the input) */ sum?: boolean; } export interface Done { out: Uint8Array; sum?: number; } /** Runs a task on this thread (Node's zlib when present, else pako). */ export declare function execute(t: Task): Done; export interface Runner { threads: number; /** the runner computes Adler-32 sums on its threads (else the caller does, here) */ sums: boolean; run(t: Task): Promise; } /** Stops the Web Workers jda started (they are kept for later calls). */ export declare function closeWorkers(): void; export interface ThreadOptions { /** the most threads to use (default: the processors; in Node.js, at most UV_THREADPOOL_SIZE) */ threads?: number; /** browsers: the URL of jdata.js (or jdata.mjs, with workerModule) for the workers (default: * this script's own URL; needed when jda is bundled) */ workerURL?: string; workerModule?: boolean; } export declare function runner(o: ThreadOptions): Runner; /** The zlibmt block size for a payload of n bytes: n/16, from 256 KiB to 4 MiB (as jdai). */ export declare function zlibmtBlockSize(n: number): number; /** A zlib stream of bytes in zlibmt blocks, deflated on the runner's threads. */ export declare function zlibmtEncode(b: Uint8Array, level: number, R: Runner): Promise; /** The same stream, deflated here (for encode() with zlibmt: true). */ export declare function zlibmtEncodeSync(b: Uint8Array, level: number): Uint8Array; /** The bytes of a zlib stream, inflated in parallel between full-flush marks where it can be. */ export declare function zlibmtDecode(z: Uint8Array, size: number | undefined, R: Runner): Promise; /** A zlib stream of bytes in zlibmt blocks, deflated on threads (any zlib inflates it). */ export declare function deflate(bytes: Uint8Array, opts?: ThreadOptions & { level?: number; }): Promise; /** The bytes of a zlib stream, inflated on threads where its blocks allow (size: the expected * size, when known). */ export declare function inflate(bytes: Uint8Array, opts?: ThreadOptions & { size?: number; }): Promise;