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