You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zlib.d.ts 12KB

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