UNPKG

3.82 kBTypeScriptView Raw
1// Modified from the node.js definitions.
2// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/zlib.d.ts
3
4import { InputType, CompressCallback, BrotliOptions, ZlibOptions } from "zlib";
5export * from "zlib";
6
7/**
8 * Compress the buffer using the **Brotli Compression** algorithm.
9 *
10 * @param buf The buffer.
11 * @param options The compression options.
12 */
13export function brotliCompress(buf: InputType, callback: CompressCallback): void;
14export function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
15export function brotliCompress(buf: InputType, options?: BrotliOptions): Promise<Buffer>;
16
17/**
18 * Decompress the buffer using the **Brotli Compression** algorithm.
19 *
20 * @param buf The buffer.
21 * @param options The compression options.
22 */
23export function brotliDecompress(buf: InputType, callback: CompressCallback): void;
24export function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
25export function brotliDecompress(buf: InputType, options?: BrotliOptions): Promise<Buffer>;
26
27/**
28 * Compress the buffer using the **DEFLATE** algorithm.
29 *
30 * @param buf The buffer.
31 * @param options The compression options.
32 */
33export function deflate(buf: InputType, callback: CompressCallback): void;
34export function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
35export function deflate(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
36
37/**
38 * Compress the buffer using the **DEFLATE** algorithm.
39 *
40 * @param buf The buffer.
41 * @param options The compression options.
42 */
43export function deflateRaw(buf: InputType, callback: CompressCallback): void;
44export function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
45export function deflateRaw(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
46
47/**
48 * Compress the buffer using the **GZIP** algorithm.
49 *
50 * @param buf The buffer.
51 * @param options The compression options.
52 */
53export function gzip(buf: InputType, callback: CompressCallback): void;
54export function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
55export function gzip(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
56
57/**
58 * Decompress the buffer using the **GZIP** algorithm.
59 *
60 * @param buf The buffer.
61 * @param options The compression options.
62 */
63export function gunzip(buf: InputType, callback: CompressCallback): void;
64export function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
65export function gunzip(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
66
67/**
68 * Decompress the buffer using the **DEFLATE** algorithm.
69 *
70 * @param buf The buffer.
71 * @param options The compression options.
72 */
73export function inflate(buf: InputType, callback: CompressCallback): void;
74export function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
75export function inflate(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
76
77/**
78 * Decompress the buffer using the **DEFLATE** algorithm.
79 *
80 * @param buf The buffer.
81 * @param options The compression options.
82 */
83export function inflateRaw(buf: InputType, callback: CompressCallback): void;
84export function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
85export function inflateRaw(buf: InputType, options?: ZlibOptions): Promise<Buffer>;
86
87/**
88 * Decompress the buffer using the **ZIP** algorithm.
89 *
90 * @param buf The buffer.
91 * @param options The compression options.
92 */
93export function unzip(buf: InputType, callback: CompressCallback): void;
94export function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
95export function unzip(buf: InputType, options?: ZlibOptions): Promise<Buffer>;