/** * Parallel, multi-core compression — the one lever no single-threaded codec can * match. * * `fflate`, `pako`, and even the runtime-native `Bun.gzipSync` / `zlib` all * compress a buffer on **one** thread. ZipKit splits the input into independent * blocks, compresses them concurrently across the whole {@link sharedPool} * worker pool, and frames the result in a tiny self-describing container. On an * N-core machine large inputs compress and decompress close to N× faster — so * ZipKit beats native throughput on big data, the way `pigz` beats `gzip`. * * Each block is a complete, standard stream of the chosen codec; only the outer * container (magic `ZKP1`) is ZipKit-specific, so {@link decompressParallel} * reverses it. Per-block independence costs a sliver of ratio at small block * sizes — negligible at the default ≥256 KB blocks. * * @example * ```ts * import { compressParallel, decompressParallel } from '@myrialabs/zipkit'; * const packed = await compressParallel(bigBuffer, 'zstd', { level: 19 }); * const original = await decompressParallel(packed); * ``` */ import type { Codec, CompressOptions, DecompressOptions } from '../types.js'; import { WorkerPool } from '../workers/index.js'; /** Options for {@link compressParallel}. */ export interface ParallelCompressOptions extends CompressOptions { /** * Bytes per block. Larger blocks compress slightly denser; smaller blocks * parallelize better. Defaults to an adaptive size (≥256 KB, ~4 blocks per * core) that keeps every worker busy with negligible ratio loss. */ blockSize?: number; /** Worker pool to run on. Defaults to the process-wide {@link sharedPool}. */ pool?: WorkerPool; } /** Options for {@link decompressParallel}. */ export interface ParallelDecompressOptions extends DecompressOptions { /** Worker pool to run on. Defaults to the process-wide {@link sharedPool}. */ pool?: WorkerPool; } /** * Compress `data` in parallel across the worker pool, returning a self-describing * container that {@link decompressParallel} reverses. Falls back to a single * block (and inline execution) where workers aren't available, so it never * breaks — it simply stops being parallel. */ export declare function compressParallel(data: Uint8Array, codec: Codec, opts?: ParallelCompressOptions): Promise; /** True if `data` looks like a {@link compressParallel} container. */ export declare function isParallelContainer(data: Uint8Array): boolean; /** * Reverse {@link compressParallel}: decompress every block concurrently across * the pool and concatenate. The codec is read from the container header. */ export declare function decompressParallel(data: Uint8Array, opts?: ParallelDecompressOptions): Promise; //# sourceMappingURL=index.d.ts.map