-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
node_stream_zip.d.ts
199 lines (157 loc) · 4.36 KB
/
node_stream_zip.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/// <reference types="node" />
declare namespace StreamZip {
interface StreamZipOptions {
/**
* File to read
* @default undefined
*/
file?: string;
/**
* Alternatively, you can pass fd here
* @default undefined
*/
fd?: number;
/**
* You will be able to work with entries inside zip archive,
* otherwise the only way to access them is entry event
* @default true
*/
storeEntries?: boolean;
/**
* By default, entry name is checked for malicious characters, like ../ or c:\123,
* pass this flag to disable validation error
* @default false
*/
skipEntryNameValidation?: boolean;
/**
* Filesystem read chunk size
* @default automatic based on file size
*/
chunkSize?: number;
/**
* Encoding used to decode file names
* @default UTF8
*/
nameEncoding?: string;
}
interface ZipEntry {
/**
* file name
*/
name: string;
/**
* true if it's a directory entry
*/
isDirectory: boolean;
/**
* true if it's a file entry, see also isDirectory
*/
isFile: boolean;
/**
* file comment
*/
comment: string;
/**
* if the file is encrypted
*/
encrypted: boolean;
/**
* version made by
*/
verMade: number;
/**
* version needed to extract
*/
version: number;
/**
* encrypt, decrypt flags
*/
flags: number;
/**
* compression method
*/
method: number;
/**
* modification time
*/
time: number;
/**
* uncompressed file crc-32 value
*/
crc: number;
/**
* compressed size
*/
compressedSize: number;
/**
* uncompressed size
*/
size: number;
/**
* volume number start
*/
diskStart: number;
/**
* internal file attributes
*/
inattr: number;
/**
* external file attributes
*/
attr: number;
/**
* LOC header offset
*/
offset: number;
}
class StreamZipAsync {
constructor(config: StreamZipOptions);
entriesCount: Promise<number>;
comment: Promise<string>;
entry(name: string): Promise<ZipEntry | undefined>;
entries(): Promise<{ [name: string]: ZipEntry }>;
entryData(entry: string | ZipEntry): Promise<Buffer>;
stream(entry: string | ZipEntry): Promise<NodeJS.ReadableStream>;
extract(entry: string | ZipEntry | null, outPath: string): Promise<number | undefined>;
on(event: 'entry', handler: (entry: ZipEntry) => void): void;
on(event: 'extract', handler: (entry: ZipEntry, outPath: string) => void): void;
close(): Promise<void>;
}
}
type StreamZipOptions = StreamZip.StreamZipOptions;
type ZipEntry = StreamZip.ZipEntry;
declare class StreamZip {
constructor(config: StreamZipOptions);
/**
* number of entries in the archive
*/
entriesCount: number;
/**
* archive comment
*/
comment: string;
on(event: 'error', handler: (error: any) => void): void;
on(event: 'entry', handler: (entry: ZipEntry) => void): void;
on(event: 'ready', handler: () => void): void;
on(event: 'extract', handler: (entry: ZipEntry, outPath: string) => void): void;
entry(name: string): ZipEntry | undefined;
entries(): { [name: string]: ZipEntry };
stream(
entry: string | ZipEntry,
callback: (err: any | null, stream?: NodeJS.ReadableStream) => void
): void;
entryDataSync(entry: string | ZipEntry): Buffer;
openEntry(
entry: string | ZipEntry,
callback: (err: any | null, entry?: ZipEntry) => void,
sync: boolean
): void;
extract(
entry: string | ZipEntry | null,
outPath: string,
callback: (err?: any, res?: number) => void
): void;
close(callback?: (err?: any) => void): void;
static async: typeof StreamZip.StreamZipAsync;
}
export = StreamZip;