/** * @file Brotli compression / decompression — in-memory, file-to-file, and * raw-stream variants. Default quality is 11 for maximum compression at the * cost of speed, on the assumption these are one-shot CLI calls. Override * via `options.level` for hot paths. await * compressBrotli(JSON.stringify(payload)) await * compressBrotliFile('input.json', 'input.json.br') * readable.pipe(createBrotliCompressor()).pipe(writable) */ import type { Buffer } from 'node:buffer'; import type { BrotliOptions } from 'node:zlib'; import type { CompressFileOptions, CompressOptions } from './types.js'; export declare const BROTLI_EXTS: ReadonlySet; export interface ResolvedBrotliOptions extends BrotliOptions { params: NonNullable; } /** * Compress a string or Buffer with brotli. Strings are encoded as UTF-8 before * compression — pass an explicit Buffer if you have non-UTF-8 input. */ export declare function compressBrotli(input: string | Buffer, options?: CompressOptions | undefined): Promise; /** * Stream-compress a file with brotli. Two call shapes: * * CompressBrotliFile(src, dest, options?) Writes compressed output to `dest`. * Source is left intact. * * CompressBrotliFile(src, { inPlace: true, ...options }) Writes to `.br` * and deletes `src` after the write succeeds. Returns the new path. * * Returns the destination path in both shapes — same string the caller passed * in or the computed `.br` path for inPlace. */ export declare function compressBrotliFile(srcPath: string, destPath: string, options?: CompressOptions | undefined): Promise; export declare function compressBrotliFile(srcPath: string, options: CompressFileOptions): Promise; /** * Create a brotli compress transform stream. Compose into your own pipeline. * The `pipeline` from `node:stream/promises` is the safe way to wire it up — it * handles error propagation across all stages. */ export declare function createBrotliCompressor(options?: CompressOptions | undefined): import("node:zlib").BrotliCompress; /** * Create a brotli decompress transform stream. * * @unused No internal or Socket consumers; exercised only by its unit tests. */ export declare function createBrotliDecompressor(): import("node:zlib").BrotliDecompress; /** * Decompress a brotli-compressed Buffer. */ export declare function decompressBrotli(input: Buffer): Promise; /** * Stream-decompress a brotli file. Two call shapes: * * DecompressBrotliFile(src, dest) Writes decompressed output to `dest`. Source * is left intact. * * DecompressBrotliFile(src, { inPlace: true }) Strips the `.br`/`.brotli` * suffix to derive the destination, then deletes the compressed source after * the write succeeds. Throws if `src` has no recognizable extension. * * Returns the destination path in both shapes. */ export declare function decompressBrotliFile(srcPath: string, destPath: string): Promise; export declare function decompressBrotliFile(srcPath: string, options: CompressFileOptions): Promise; /** * Extension check for brotli paths — matches `.br` / `.brotli` * (case-insensitive). Naming follows node:path's `extname`. */ export declare function hasBrotliExt(filePath: string): boolean; /** * Cheap pre-flight check: does the buffer look like it could be brotli? Returns * false for inputs too short to be valid. Brotli has no fixed magic bytes, so * this is intentionally permissive — the authoritative test is * `decompressBrotli(buf)` succeeding. Use for UI hints, not correctness. * * @unused No internal or Socket consumers; exercised only by its unit tests. */ export declare function isBrotliCompressed(input: Buffer): boolean; /** * Translate `CompressOptions` into the `BrotliOptions` zlib expects. Defaults * `quality` to 11 (max) when not provided, and forwards a positive `size` hint. * Exposed for callers building their own zlib pipelines and for unit-test * coverage. */ export declare function resolveBrotliOptions(options: CompressOptions | undefined): ResolvedBrotliOptions;