1 |
|
2 |
|
3 | declare namespace StreamZip {
|
4 | interface StreamZipOptions {
|
5 | |
6 |
|
7 |
|
8 |
|
9 | file?: string;
|
10 |
|
11 | |
12 |
|
13 |
|
14 |
|
15 | fd?: number;
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | storeEntries?: boolean;
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | skipEntryNameValidation?: boolean;
|
30 |
|
31 | |
32 |
|
33 |
|
34 |
|
35 | chunkSize?: number;
|
36 | }
|
37 |
|
38 | interface ZipEntry {
|
39 | |
40 |
|
41 |
|
42 | name: string;
|
43 |
|
44 | |
45 |
|
46 |
|
47 | isDirectory: boolean;
|
48 |
|
49 | |
50 |
|
51 |
|
52 | isFile: boolean;
|
53 |
|
54 | |
55 |
|
56 |
|
57 | comment: string;
|
58 |
|
59 | |
60 |
|
61 |
|
62 | encrypted: boolean;
|
63 |
|
64 | |
65 |
|
66 |
|
67 | verMade: number;
|
68 |
|
69 | |
70 |
|
71 |
|
72 | version: number;
|
73 |
|
74 | |
75 |
|
76 |
|
77 | flags: number;
|
78 |
|
79 | |
80 |
|
81 |
|
82 | method: number;
|
83 |
|
84 | |
85 |
|
86 |
|
87 | time: number;
|
88 |
|
89 | |
90 |
|
91 |
|
92 | crc: number;
|
93 |
|
94 | |
95 |
|
96 |
|
97 | compressedSize: number;
|
98 |
|
99 | |
100 |
|
101 |
|
102 | size: number;
|
103 |
|
104 | |
105 |
|
106 |
|
107 | diskStart: number;
|
108 |
|
109 | |
110 |
|
111 |
|
112 | inattr: number;
|
113 |
|
114 | |
115 |
|
116 |
|
117 | attr: number;
|
118 |
|
119 | |
120 |
|
121 |
|
122 | offset: number;
|
123 | }
|
124 | }
|
125 |
|
126 | type StreamZipOptions = StreamZip.StreamZipOptions;
|
127 | type ZipEntry = StreamZip.ZipEntry;
|
128 |
|
129 | declare class StreamZipAsync {
|
130 | constructor(config: StreamZipOptions);
|
131 |
|
132 | entriesCount: Promise<number>;
|
133 | comment: Promise<string>;
|
134 |
|
135 | entry(name: string): Promise<ZipEntry | undefined>;
|
136 | entries(name: string): Promise<{ [name: string]: ZipEntry }>;
|
137 | entryData(entry: string | ZipEntry): Promise<Buffer>;
|
138 | stream(entry: string | ZipEntry): Promise<NodeJS.ReadableStream>;
|
139 | extract(entry: string | ZipEntry | null, outPath: string): Promise<number | undefined>;
|
140 |
|
141 | on(event: 'entry', handler: (entry: ZipEntry) => void): void;
|
142 | on(event: 'extract', handler: (entry: ZipEntry, outPath: string) => void): void;
|
143 |
|
144 | close(): Promise<void>;
|
145 | }
|
146 |
|
147 | declare class StreamZip {
|
148 | constructor(config: StreamZipOptions);
|
149 |
|
150 | /**
|
151 | * number of entries in the archive
|
152 | */
|
153 | entriesCount: number;
|
154 |
|
155 | /**
|
156 | * archive comment
|
157 | */
|
158 | comment: string;
|
159 |
|
160 | on(event: 'error', handler: (error: any) => void): void;
|
161 | on(event: 'entry', handler: (entry: ZipEntry) => void): void;
|
162 | on(event: 'ready', handler: () => void): void;
|
163 | on(event: 'extract', handler: (entry: ZipEntry, outPath: string) => void): void;
|
164 |
|
165 | entry(name: string): ZipEntry | undefined;
|
166 |
|
167 | entries(): { [name: string]: ZipEntry };
|
168 |
|
169 | stream(
|
170 | entry: string | ZipEntry,
|
171 | callback: (err: any | null, stream?: NodeJS.ReadableStream) => void
|
172 | ): void;
|
173 |
|
174 | entryDataSync(entry: string | ZipEntry): Buffer;
|
175 |
|
176 | openEntry(
|
177 | entry: string | ZipEntry,
|
178 | callback: (err: any | null, entry?: ZipEntry) => void,
|
179 | sync: boolean
|
180 | ): void;
|
181 |
|
182 | extract(
|
183 | entry: string | ZipEntry | null,
|
184 | outPath: string,
|
185 | callback: (err?: any, res?: number) => void
|
186 | ): void;
|
187 |
|
188 | close(callback?: (err?: any) => void): void;
|
189 |
|
190 | static async: typeof StreamZipAsync;
|
191 | }
|
192 |
|
193 | export = StreamZip;
|