-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpako.d.ts
147 lines (129 loc) · 4.85 KB
/
pako.d.ts
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
142
143
144
145
146
147
// Type definitions for pako 1.0
// Project: https://github.com/nodeca/pako
// Definitions by: Caleb Eggensperger <https://github.com/calebegg>
// Muhammet Öztürk <https://github.com/hlthi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = Pako;
export as namespace pako;
declare namespace Pako {
enum FlushValues {
Z_NO_FLUSH = 0,
Z_PARTIAL_FLUSH = 1,
Z_SYNC_FLUSH = 2,
Z_FULL_FLUSH = 3,
Z_FINISH = 4,
Z_BLOCK = 5,
Z_TREES = 6,
}
enum StrategyValues {
Z_FILTERED = 1,
Z_HUFFMAN_ONLY = 2,
Z_RLE = 3,
Z_FIXED = 4,
Z_DEFAULT_STRATEGY = 0,
}
enum ReturnCodes {
Z_OK = 0,
Z_STREAM_END = 1,
Z_NEED_DICT = 2,
Z_ERRNO = -1,
Z_STREAM_ERROR = -2,
Z_DATA_ERROR = -3,
Z_BUF_ERROR = -5,
}
interface DeflateOptions {
level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
windowBits?: number | undefined;
memLevel?: number | undefined;
strategy?: StrategyValues | undefined;
dictionary?: any;
raw?: boolean | undefined;
to?: 'string' | undefined;
chunkSize?: number | undefined;
gzip?: boolean | undefined;
header?: Header | undefined;
}
interface DeflateFunctionOptions {
level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
windowBits?: number | undefined;
memLevel?: number | undefined;
strategy?: StrategyValues | undefined;
dictionary?: any;
raw?: boolean | undefined;
to?: 'string' | undefined;
}
interface InflateOptions {
windowBits?: number | undefined;
dictionary?: any;
raw?: boolean | undefined;
to?: 'string' | undefined;
chunkSize?: number | undefined;
}
interface InflateFunctionOptions {
windowBits?: number | undefined;
raw?: boolean | undefined;
to?: 'string' | undefined;
}
interface Header {
text?: boolean | undefined;
time?: number | undefined;
os?: number | undefined;
extra?: number[] | undefined;
name?: string | undefined;
comment?: string | undefined;
hcrc?: boolean | undefined;
}
type Data = Uint8Array | number[] | string;
/**
* Compress data with deflate algorithm and options.
*/
function deflate(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
function deflate(data: Data, options?: DeflateFunctionOptions): Uint8Array;
/**
* The same as deflate, but creates raw data, without wrapper (header and adler32 crc).
*/
function deflateRaw(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
function deflateRaw(data: Data, options?: DeflateFunctionOptions): Uint8Array;
/**
* The same as deflate, but create gzip wrapper instead of deflate one.
*/
function gzip(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
function gzip(data: Data, options?: DeflateFunctionOptions): Uint8Array;
/**
* Decompress data with inflate/ungzip and options. Autodetect format via wrapper header
* by default. That's why we don't provide separate ungzip method.
*/
function inflate(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
function inflate(data: Data, options?: InflateFunctionOptions): Uint8Array;
/**
* The same as inflate, but creates raw data, without wrapper (header and adler32 crc).
*/
function inflateRaw(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
function inflateRaw(data: Data, options?: InflateFunctionOptions): Uint8Array;
/**
* Just shortcut to inflate, because it autodetects format by header.content. Done for convenience.
*/
function ungzip(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
function ungzip(data: Data, options?: InflateFunctionOptions): Uint8Array;
// https://github.com/nodeca/pako/blob/893381abcafa10fa2081ce60dae7d4d8e873a658/lib/deflate.js
class Deflate {
constructor(options?: DeflateOptions);
err: ReturnCodes;
msg: string;
result: Uint8Array | number[];
onData(chunk: Data): void;
onEnd(status: number): void;
push(data: Data | ArrayBuffer, mode?: FlushValues | boolean): boolean;
}
// https://github.com/nodeca/pako/blob/893381abcafa10fa2081ce60dae7d4d8e873a658/lib/inflate.js
class Inflate {
constructor(options?: InflateOptions);
header?: Header | undefined;
err: ReturnCodes;
msg: string;
result: Data;
onData(chunk: Data): void;
onEnd(status: number): void;
push(data: Data | ArrayBuffer, mode?: FlushValues | boolean): boolean;
}
}