1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
declare module "zlib" {
import * as stream from "stream";
interface ZlibOptions {
flush?: number; // default: zlib.constants.Z_NO_FLUSH
finishFlush?: number; // default: zlib.constants.Z_FINISH
chunkSize?: number; // default: 16*1024
windowBits?: number;
level?: number; // compression only
memLevel?: number; // compression only
strategy?: number; // compression only
dictionary?: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
}
interface Zlib {
/** @deprecated Use bytesWritten instead. */
readonly bytesRead: number;
readonly bytesWritten: number;
shell?: boolean | string;
close(callback?: () => void): void;
flush(kind?: number | (() => void), callback?: () => void): void;
}
interface ZlibParams {
params(level: number, strategy: number, callback: () => void): void;
}
interface ZlibReset {
reset(): void;
}
interface Gzip extends stream.Transform, Zlib { }
interface Gunzip extends stream.Transform, Zlib { }
interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
interface Inflate extends stream.Transform, Zlib, ZlibReset { }
interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
interface InflateRaw extends stream.Transform, Zlib, ZlibReset { }
interface Unzip extends stream.Transform, Zlib { }
function createGzip(options?: ZlibOptions): Gzip;
function createGunzip(options?: ZlibOptions): Gunzip;
function createDeflate(options?: ZlibOptions): Deflate;
function createInflate(options?: ZlibOptions): Inflate;
function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
function createInflateRaw(options?: ZlibOptions): InflateRaw;
function createUnzip(options?: ZlibOptions): Unzip;
type InputType = string | Buffer | DataView | ArrayBuffer | NodeJS.TypedArray;
function deflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function deflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
function deflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function deflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
function gzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function gzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
function gunzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function gunzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
function inflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function inflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
function inflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function inflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
function unzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
function unzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
namespace constants {
// Allowed flush values.
const Z_NO_FLUSH: number;
const Z_PARTIAL_FLUSH: number;
const Z_SYNC_FLUSH: number;
const Z_FULL_FLUSH: number;
const Z_FINISH: number;
const Z_BLOCK: number;
const Z_TREES: number;
// Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events.
const Z_OK: number;
const Z_STREAM_END: number;
const Z_NEED_DICT: number;
const Z_ERRNO: number;
const Z_STREAM_ERROR: number;
const Z_DATA_ERROR: number;
const Z_MEM_ERROR: number;
const Z_BUF_ERROR: number;
const Z_VERSION_ERROR: number;
// Compression levels.
const Z_NO_COMPRESSION: number;
const Z_BEST_SPEED: number;
const Z_BEST_COMPRESSION: number;
const Z_DEFAULT_COMPRESSION: number;
// Compression strategy.
const Z_FILTERED: number;
const Z_HUFFMAN_ONLY: number;
const Z_RLE: number;
const Z_FIXED: number;
const Z_DEFAULT_STRATEGY: number;
}
// Constants
const Z_NO_FLUSH: number;
const Z_PARTIAL_FLUSH: number;
const Z_SYNC_FLUSH: number;
const Z_FULL_FLUSH: number;
const Z_FINISH: number;
const Z_BLOCK: number;
const Z_TREES: number;
const Z_OK: number;
const Z_STREAM_END: number;
const Z_NEED_DICT: number;
const Z_ERRNO: number;
const Z_STREAM_ERROR: number;
const Z_DATA_ERROR: number;
const Z_MEM_ERROR: number;
const Z_BUF_ERROR: number;
const Z_VERSION_ERROR: number;
const Z_NO_COMPRESSION: number;
const Z_BEST_SPEED: number;
const Z_BEST_COMPRESSION: number;
const Z_DEFAULT_COMPRESSION: number;
const Z_FILTERED: number;
const Z_HUFFMAN_ONLY: number;
const Z_RLE: number;
const Z_FIXED: number;
const Z_DEFAULT_STRATEGY: number;
const Z_BINARY: number;
const Z_TEXT: number;
const Z_ASCII: number;
const Z_UNKNOWN: number;
const Z_DEFLATED: number;
}
|