1 | declare module 'zlib' {
|
---|
2 | import * as stream from 'stream';
|
---|
3 |
|
---|
4 | interface ZlibOptions {
|
---|
5 | /**
|
---|
6 | * @default constants.Z_NO_FLUSH
|
---|
7 | */
|
---|
8 | flush?: number | undefined;
|
---|
9 | /**
|
---|
10 | * @default constants.Z_FINISH
|
---|
11 | */
|
---|
12 | finishFlush?: number | undefined;
|
---|
13 | /**
|
---|
14 | * @default 16*1024
|
---|
15 | */
|
---|
16 | chunkSize?: number | undefined;
|
---|
17 | windowBits?: number | undefined;
|
---|
18 | level?: number | undefined; // compression only
|
---|
19 | memLevel?: number | undefined; // compression only
|
---|
20 | strategy?: number | undefined; // compression only
|
---|
21 | dictionary?: NodeJS.ArrayBufferView | ArrayBuffer | undefined; // deflate/inflate only, empty dictionary by default
|
---|
22 | info?: boolean | undefined;
|
---|
23 | maxOutputLength?: number | undefined;
|
---|
24 | }
|
---|
25 |
|
---|
26 | interface BrotliOptions {
|
---|
27 | /**
|
---|
28 | * @default constants.BROTLI_OPERATION_PROCESS
|
---|
29 | */
|
---|
30 | flush?: number | undefined;
|
---|
31 | /**
|
---|
32 | * @default constants.BROTLI_OPERATION_FINISH
|
---|
33 | */
|
---|
34 | finishFlush?: number | undefined;
|
---|
35 | /**
|
---|
36 | * @default 16*1024
|
---|
37 | */
|
---|
38 | chunkSize?: number | undefined;
|
---|
39 | params?: {
|
---|
40 | /**
|
---|
41 | * Each key is a `constants.BROTLI_*` constant.
|
---|
42 | */
|
---|
43 | [key: number]: boolean | number;
|
---|
44 | } | undefined;
|
---|
45 | maxOutputLength?: number | undefined;
|
---|
46 | }
|
---|
47 |
|
---|
48 | interface Zlib {
|
---|
49 | /** @deprecated Use bytesWritten instead. */
|
---|
50 | readonly bytesRead: number;
|
---|
51 | readonly bytesWritten: number;
|
---|
52 | shell?: boolean | string | undefined;
|
---|
53 | close(callback?: () => void): void;
|
---|
54 | flush(kind?: number, callback?: () => void): void;
|
---|
55 | flush(callback?: () => void): void;
|
---|
56 | }
|
---|
57 |
|
---|
58 | interface ZlibParams {
|
---|
59 | params(level: number, strategy: number, callback: () => void): void;
|
---|
60 | }
|
---|
61 |
|
---|
62 | interface ZlibReset {
|
---|
63 | reset(): void;
|
---|
64 | }
|
---|
65 |
|
---|
66 | interface BrotliCompress extends stream.Transform, Zlib { }
|
---|
67 | interface BrotliDecompress extends stream.Transform, Zlib { }
|
---|
68 | interface Gzip extends stream.Transform, Zlib { }
|
---|
69 | interface Gunzip extends stream.Transform, Zlib { }
|
---|
70 | interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
|
---|
71 | interface Inflate extends stream.Transform, Zlib, ZlibReset { }
|
---|
72 | interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
|
---|
73 | interface InflateRaw extends stream.Transform, Zlib, ZlibReset { }
|
---|
74 | interface Unzip extends stream.Transform, Zlib { }
|
---|
75 |
|
---|
76 | function createBrotliCompress(options?: BrotliOptions): BrotliCompress;
|
---|
77 | function createBrotliDecompress(options?: BrotliOptions): BrotliDecompress;
|
---|
78 | function createGzip(options?: ZlibOptions): Gzip;
|
---|
79 | function createGunzip(options?: ZlibOptions): Gunzip;
|
---|
80 | function createDeflate(options?: ZlibOptions): Deflate;
|
---|
81 | function createInflate(options?: ZlibOptions): Inflate;
|
---|
82 | function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
|
---|
83 | function createInflateRaw(options?: ZlibOptions): InflateRaw;
|
---|
84 | function createUnzip(options?: ZlibOptions): Unzip;
|
---|
85 |
|
---|
86 | type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
|
---|
87 |
|
---|
88 | type CompressCallback = (error: Error | null, result: Buffer) => void;
|
---|
89 |
|
---|
90 | function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
---|
91 | function brotliCompress(buf: InputType, callback: CompressCallback): void;
|
---|
92 | namespace brotliCompress {
|
---|
93 | function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
|
---|
94 | }
|
---|
95 |
|
---|
96 | function brotliCompressSync(buf: InputType, options?: BrotliOptions): Buffer;
|
---|
97 |
|
---|
98 | function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
---|
99 | function brotliDecompress(buf: InputType, callback: CompressCallback): void;
|
---|
100 | namespace brotliDecompress {
|
---|
101 | function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
|
---|
102 | }
|
---|
103 |
|
---|
104 | function brotliDecompressSync(buf: InputType, options?: BrotliOptions): Buffer;
|
---|
105 |
|
---|
106 | function deflate(buf: InputType, callback: CompressCallback): void;
|
---|
107 | function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
108 | namespace deflate {
|
---|
109 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
110 | }
|
---|
111 |
|
---|
112 | function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
113 |
|
---|
114 | function deflateRaw(buf: InputType, callback: CompressCallback): void;
|
---|
115 | function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
116 | namespace deflateRaw {
|
---|
117 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
118 | }
|
---|
119 |
|
---|
120 | function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
121 |
|
---|
122 | function gzip(buf: InputType, callback: CompressCallback): void;
|
---|
123 | function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
124 | namespace gzip {
|
---|
125 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
126 | }
|
---|
127 |
|
---|
128 | function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
129 |
|
---|
130 | function gunzip(buf: InputType, callback: CompressCallback): void;
|
---|
131 | function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
132 | namespace gunzip {
|
---|
133 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
134 | }
|
---|
135 |
|
---|
136 | function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
137 |
|
---|
138 | function inflate(buf: InputType, callback: CompressCallback): void;
|
---|
139 | function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
140 | namespace inflate {
|
---|
141 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
142 | }
|
---|
143 |
|
---|
144 | function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
145 |
|
---|
146 | function inflateRaw(buf: InputType, callback: CompressCallback): void;
|
---|
147 | function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
148 | namespace inflateRaw {
|
---|
149 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
150 | }
|
---|
151 |
|
---|
152 | function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
153 |
|
---|
154 | function unzip(buf: InputType, callback: CompressCallback): void;
|
---|
155 | function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
---|
156 | namespace unzip {
|
---|
157 | function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
|
---|
158 | }
|
---|
159 |
|
---|
160 | function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
|
---|
161 |
|
---|
162 | namespace constants {
|
---|
163 | const BROTLI_DECODE: number;
|
---|
164 | const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
|
---|
165 | const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number;
|
---|
166 | const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number;
|
---|
167 | const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number;
|
---|
168 | const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number;
|
---|
169 | const BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number;
|
---|
170 | const BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number;
|
---|
171 | const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number;
|
---|
172 | const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number;
|
---|
173 | const BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number;
|
---|
174 | const BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number;
|
---|
175 | const BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number;
|
---|
176 | const BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number;
|
---|
177 | const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number;
|
---|
178 | const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number;
|
---|
179 | const BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number;
|
---|
180 | const BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number;
|
---|
181 | const BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number;
|
---|
182 | const BROTLI_DECODER_ERROR_FORMAT_RESERVED: number;
|
---|
183 | const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number;
|
---|
184 | const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number;
|
---|
185 | const BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number;
|
---|
186 | const BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number;
|
---|
187 | const BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number;
|
---|
188 | const BROTLI_DECODER_ERROR_UNREACHABLE: number;
|
---|
189 | const BROTLI_DECODER_NEEDS_MORE_INPUT: number;
|
---|
190 | const BROTLI_DECODER_NEEDS_MORE_OUTPUT: number;
|
---|
191 | const BROTLI_DECODER_NO_ERROR: number;
|
---|
192 | const BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number;
|
---|
193 | const BROTLI_DECODER_PARAM_LARGE_WINDOW: number;
|
---|
194 | const BROTLI_DECODER_RESULT_ERROR: number;
|
---|
195 | const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number;
|
---|
196 | const BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number;
|
---|
197 | const BROTLI_DECODER_RESULT_SUCCESS: number;
|
---|
198 | const BROTLI_DECODER_SUCCESS: number;
|
---|
199 |
|
---|
200 | const BROTLI_DEFAULT_MODE: number;
|
---|
201 | const BROTLI_DEFAULT_QUALITY: number;
|
---|
202 | const BROTLI_DEFAULT_WINDOW: number;
|
---|
203 | const BROTLI_ENCODE: number;
|
---|
204 | const BROTLI_LARGE_MAX_WINDOW_BITS: number;
|
---|
205 | const BROTLI_MAX_INPUT_BLOCK_BITS: number;
|
---|
206 | const BROTLI_MAX_QUALITY: number;
|
---|
207 | const BROTLI_MAX_WINDOW_BITS: number;
|
---|
208 | const BROTLI_MIN_INPUT_BLOCK_BITS: number;
|
---|
209 | const BROTLI_MIN_QUALITY: number;
|
---|
210 | const BROTLI_MIN_WINDOW_BITS: number;
|
---|
211 |
|
---|
212 | const BROTLI_MODE_FONT: number;
|
---|
213 | const BROTLI_MODE_GENERIC: number;
|
---|
214 | const BROTLI_MODE_TEXT: number;
|
---|
215 |
|
---|
216 | const BROTLI_OPERATION_EMIT_METADATA: number;
|
---|
217 | const BROTLI_OPERATION_FINISH: number;
|
---|
218 | const BROTLI_OPERATION_FLUSH: number;
|
---|
219 | const BROTLI_OPERATION_PROCESS: number;
|
---|
220 |
|
---|
221 | const BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number;
|
---|
222 | const BROTLI_PARAM_LARGE_WINDOW: number;
|
---|
223 | const BROTLI_PARAM_LGBLOCK: number;
|
---|
224 | const BROTLI_PARAM_LGWIN: number;
|
---|
225 | const BROTLI_PARAM_MODE: number;
|
---|
226 | const BROTLI_PARAM_NDIRECT: number;
|
---|
227 | const BROTLI_PARAM_NPOSTFIX: number;
|
---|
228 | const BROTLI_PARAM_QUALITY: number;
|
---|
229 | const BROTLI_PARAM_SIZE_HINT: number;
|
---|
230 |
|
---|
231 | const DEFLATE: number;
|
---|
232 | const DEFLATERAW: number;
|
---|
233 | const GUNZIP: number;
|
---|
234 | const GZIP: number;
|
---|
235 | const INFLATE: number;
|
---|
236 | const INFLATERAW: number;
|
---|
237 | const UNZIP: number;
|
---|
238 |
|
---|
239 | const Z_NO_FLUSH: number;
|
---|
240 | const Z_PARTIAL_FLUSH: number;
|
---|
241 | const Z_SYNC_FLUSH: number;
|
---|
242 | const Z_FULL_FLUSH: number;
|
---|
243 | const Z_FINISH: number;
|
---|
244 | const Z_BLOCK: number;
|
---|
245 | const Z_TREES: number;
|
---|
246 |
|
---|
247 | const Z_OK: number;
|
---|
248 | const Z_STREAM_END: number;
|
---|
249 | const Z_NEED_DICT: number;
|
---|
250 | const Z_ERRNO: number;
|
---|
251 | const Z_STREAM_ERROR: number;
|
---|
252 | const Z_DATA_ERROR: number;
|
---|
253 | const Z_MEM_ERROR: number;
|
---|
254 | const Z_BUF_ERROR: number;
|
---|
255 | const Z_VERSION_ERROR: number;
|
---|
256 |
|
---|
257 | const Z_NO_COMPRESSION: number;
|
---|
258 | const Z_BEST_SPEED: number;
|
---|
259 | const Z_BEST_COMPRESSION: number;
|
---|
260 | const Z_DEFAULT_COMPRESSION: number;
|
---|
261 |
|
---|
262 | const Z_FILTERED: number;
|
---|
263 | const Z_HUFFMAN_ONLY: number;
|
---|
264 | const Z_RLE: number;
|
---|
265 | const Z_FIXED: number;
|
---|
266 | const Z_DEFAULT_STRATEGY: number;
|
---|
267 |
|
---|
268 | const Z_DEFAULT_WINDOWBITS: number;
|
---|
269 | const Z_MIN_WINDOWBITS: number;
|
---|
270 | const Z_MAX_WINDOWBITS: number;
|
---|
271 |
|
---|
272 | const Z_MIN_CHUNK: number;
|
---|
273 | const Z_MAX_CHUNK: number;
|
---|
274 | const Z_DEFAULT_CHUNK: number;
|
---|
275 |
|
---|
276 | const Z_MIN_MEMLEVEL: number;
|
---|
277 | const Z_MAX_MEMLEVEL: number;
|
---|
278 | const Z_DEFAULT_MEMLEVEL: number;
|
---|
279 |
|
---|
280 | const Z_MIN_LEVEL: number;
|
---|
281 | const Z_MAX_LEVEL: number;
|
---|
282 | const Z_DEFAULT_LEVEL: number;
|
---|
283 |
|
---|
284 | const ZLIB_VERNUM: number;
|
---|
285 | }
|
---|
286 |
|
---|
287 | // Allowed flush values.
|
---|
288 | /** @deprecated Use `constants.Z_NO_FLUSH` */
|
---|
289 | const Z_NO_FLUSH: number;
|
---|
290 | /** @deprecated Use `constants.Z_PARTIAL_FLUSH` */
|
---|
291 | const Z_PARTIAL_FLUSH: number;
|
---|
292 | /** @deprecated Use `constants.Z_SYNC_FLUSH` */
|
---|
293 | const Z_SYNC_FLUSH: number;
|
---|
294 | /** @deprecated Use `constants.Z_FULL_FLUSH` */
|
---|
295 | const Z_FULL_FLUSH: number;
|
---|
296 | /** @deprecated Use `constants.Z_FINISH` */
|
---|
297 | const Z_FINISH: number;
|
---|
298 | /** @deprecated Use `constants.Z_BLOCK` */
|
---|
299 | const Z_BLOCK: number;
|
---|
300 | /** @deprecated Use `constants.Z_TREES` */
|
---|
301 | const Z_TREES: number;
|
---|
302 |
|
---|
303 | // Return codes for the compression/decompression functions.
|
---|
304 | // Negative values are errors, positive values are used for special but normal events.
|
---|
305 | /** @deprecated Use `constants.Z_OK` */
|
---|
306 | const Z_OK: number;
|
---|
307 | /** @deprecated Use `constants.Z_STREAM_END` */
|
---|
308 | const Z_STREAM_END: number;
|
---|
309 | /** @deprecated Use `constants.Z_NEED_DICT` */
|
---|
310 | const Z_NEED_DICT: number;
|
---|
311 | /** @deprecated Use `constants.Z_ERRNO` */
|
---|
312 | const Z_ERRNO: number;
|
---|
313 | /** @deprecated Use `constants.Z_STREAM_ERROR` */
|
---|
314 | const Z_STREAM_ERROR: number;
|
---|
315 | /** @deprecated Use `constants.Z_DATA_ERROR` */
|
---|
316 | const Z_DATA_ERROR: number;
|
---|
317 | /** @deprecated Use `constants.Z_MEM_ERROR` */
|
---|
318 | const Z_MEM_ERROR: number;
|
---|
319 | /** @deprecated Use `constants.Z_BUF_ERROR` */
|
---|
320 | const Z_BUF_ERROR: number;
|
---|
321 | /** @deprecated Use `constants.Z_VERSION_ERROR` */
|
---|
322 | const Z_VERSION_ERROR: number;
|
---|
323 |
|
---|
324 | // Compression levels.
|
---|
325 | /** @deprecated Use `constants.Z_NO_COMPRESSION` */
|
---|
326 | const Z_NO_COMPRESSION: number;
|
---|
327 | /** @deprecated Use `constants.Z_BEST_SPEED` */
|
---|
328 | const Z_BEST_SPEED: number;
|
---|
329 | /** @deprecated Use `constants.Z_BEST_COMPRESSION` */
|
---|
330 | const Z_BEST_COMPRESSION: number;
|
---|
331 | /** @deprecated Use `constants.Z_DEFAULT_COMPRESSION` */
|
---|
332 | const Z_DEFAULT_COMPRESSION: number;
|
---|
333 |
|
---|
334 | // Compression strategy.
|
---|
335 | /** @deprecated Use `constants.Z_FILTERED` */
|
---|
336 | const Z_FILTERED: number;
|
---|
337 | /** @deprecated Use `constants.Z_HUFFMAN_ONLY` */
|
---|
338 | const Z_HUFFMAN_ONLY: number;
|
---|
339 | /** @deprecated Use `constants.Z_RLE` */
|
---|
340 | const Z_RLE: number;
|
---|
341 | /** @deprecated Use `constants.Z_FIXED` */
|
---|
342 | const Z_FIXED: number;
|
---|
343 | /** @deprecated Use `constants.Z_DEFAULT_STRATEGY` */
|
---|
344 | const Z_DEFAULT_STRATEGY: number;
|
---|
345 |
|
---|
346 | /** @deprecated */
|
---|
347 | const Z_BINARY: number;
|
---|
348 | /** @deprecated */
|
---|
349 | const Z_TEXT: number;
|
---|
350 | /** @deprecated */
|
---|
351 | const Z_ASCII: number;
|
---|
352 | /** @deprecated */
|
---|
353 | const Z_UNKNOWN: number;
|
---|
354 | /** @deprecated */
|
---|
355 | const Z_DEFLATED: number;
|
---|
356 | }
|
---|