@@ -13,7 +13,7 @@ interface JSZipSupport {
13
13
nodebuffer : boolean ;
14
14
}
15
15
16
- type Compression = ' STORE' | ' DEFLATE' ;
16
+ type Compression = " STORE" | " DEFLATE" ;
17
17
18
18
/**
19
19
* Depends on the compression type. With `STORE` (no compression), these options are ignored. With
@@ -23,9 +23,9 @@ interface CompressionOptions {
23
23
level : number ;
24
24
}
25
25
26
- interface Metadata {
26
+ interface Metadata {
27
27
percent : number ;
28
- currentFile : string ;
28
+ currentFile : string | null ;
29
29
}
30
30
31
31
type OnUpdateCallback = ( metadata : Metadata ) => void ;
@@ -64,7 +64,9 @@ interface OutputByType {
64
64
// compressedContent: string|ArrayBuffer|Uint8Array|Buffer;
65
65
// }
66
66
67
- type InputFileFormat = InputByType [ keyof InputByType ] | Promise < InputByType [ keyof InputByType ] > ;
67
+ type InputFileFormat =
68
+ | InputByType [ keyof InputByType ]
69
+ | Promise < InputByType [ keyof InputByType ] > ;
68
70
69
71
declare namespace JSZip {
70
72
type InputType = keyof InputByType ;
@@ -93,8 +95,14 @@ declare namespace JSZip {
93
95
* @param onUpdate a function to call on each internal update.
94
96
* @return Promise the promise of the result.
95
97
*/
96
- async < T extends OutputType > ( type : T , onUpdate ?: OnUpdateCallback ) : Promise < OutputByType [ T ] > ;
97
- nodeStream ( type ?: 'nodebuffer' , onUpdate ?: OnUpdateCallback ) : NodeJS . ReadableStream ;
98
+ async < T extends OutputType > (
99
+ type : T ,
100
+ onUpdate ?: OnUpdateCallback
101
+ ) : Promise < OutputByType [ T ] > ;
102
+ nodeStream (
103
+ type ?: "nodebuffer" ,
104
+ onUpdate ?: OnUpdateCallback
105
+ ) : NodeJS . ReadableStream ;
98
106
}
99
107
100
108
interface JSZipFileOptions {
@@ -159,7 +167,7 @@ declare namespace JSZip {
159
167
/** Stream the files and create file descriptors */
160
168
streamFiles ?: boolean ;
161
169
/** DOS (default) or UNIX */
162
- platform ?: ' DOS' | ' UNIX' ;
170
+ platform ?: " DOS" | " UNIX" ;
163
171
}
164
172
165
173
interface JSZipLoadOptions {
@@ -175,25 +183,27 @@ declare namespace JSZip {
175
183
currentFile : string ;
176
184
}
177
185
178
- type DataEventCallback < T > = ( dataChunk : T , metadata : JSZipMetadata ) => void
179
- type EndEventCallback = ( ) => void
180
- type ErrorEventCallback = ( error : Error ) => void
186
+ type DataEventCallback < T > = ( dataChunk : T , metadata : JSZipMetadata ) => void ;
187
+ type EndEventCallback = ( ) => void ;
188
+ type ErrorEventCallback = ( error : Error ) => void ;
181
189
182
190
interface JSZipStreamHelper < T > {
183
191
/**
184
192
* Register a listener on an event
185
193
*/
186
- on ( event : ' data' , callback : DataEventCallback < T > ) : this;
187
- on ( event : ' end' , callback : EndEventCallback ) : this;
188
- on ( event : ' error' , callback : ErrorEventCallback ) : this;
194
+ on ( event : " data" , callback : DataEventCallback < T > ) : this;
195
+ on ( event : " end" , callback : EndEventCallback ) : this;
196
+ on ( event : " error" , callback : ErrorEventCallback ) : this;
189
197
190
198
/**
191
199
* Read the whole stream and call a callback with the complete content
192
200
*
193
201
* @param updateCallback The function called every time the stream updates
194
202
* @return A Promise of the full content
195
203
*/
196
- accumulate ( updateCallback ?: ( metadata : JSZipMetadata ) => void ) : Promise < T > ;
204
+ accumulate (
205
+ updateCallback ?: ( metadata : JSZipMetadata ) => void
206
+ ) : Promise < T > ;
197
207
198
208
/**
199
209
* Resume the stream if the stream is paused. Once resumed, the stream starts sending data events again
@@ -212,7 +222,7 @@ declare namespace JSZip {
212
222
}
213
223
214
224
interface JSZip {
215
- files : { [ key : string ] : JSZip . JSZipObject } ;
225
+ files : { [ key : string ] : JSZip . JSZipObject } ;
216
226
217
227
/**
218
228
* Get a file from the archive
@@ -238,8 +248,16 @@ interface JSZip {
238
248
* @param options Optional information about the file
239
249
* @return JSZip object
240
250
*/
241
- file < T extends JSZip . InputType > ( path : string , data : InputByType [ T ] | Promise < InputByType [ T ] > , options ?: JSZip . JSZipFileOptions ) : this;
242
- file < T extends JSZip . InputType > ( path : string , data : null , options ?: JSZip . JSZipFileOptions & { dir : true } ) : this;
251
+ file < T extends JSZip . InputType > (
252
+ path : string ,
253
+ data : InputByType [ T ] | Promise < InputByType [ T ] > ,
254
+ options ?: JSZip . JSZipFileOptions
255
+ ) : this;
256
+ file < T extends JSZip . InputType > (
257
+ path : string ,
258
+ data : null ,
259
+ options ?: JSZip . JSZipFileOptions & { dir : true }
260
+ ) : this;
243
261
244
262
/**
245
263
* Returns an new JSZip instance with the given folder as root
@@ -262,15 +280,19 @@ interface JSZip {
262
280
*
263
281
* @param callback function
264
282
*/
265
- forEach ( callback : ( relativePath : string , file : JSZip . JSZipObject ) => void ) : void ;
283
+ forEach (
284
+ callback : ( relativePath : string , file : JSZip . JSZipObject ) => void
285
+ ) : void ;
266
286
267
287
/**
268
288
* Get all files which match the given filter function
269
289
*
270
290
* @param predicate Filter function
271
291
* @return Array of matched elements
272
292
*/
273
- filter ( predicate : ( relativePath : string , file : JSZip . JSZipObject ) => boolean ) : JSZip . JSZipObject [ ] ;
293
+ filter (
294
+ predicate : ( relativePath : string , file : JSZip . JSZipObject ) => boolean
295
+ ) : JSZip . JSZipObject [ ] ;
274
296
275
297
/**
276
298
* Removes the file or folder from the archive
@@ -287,7 +309,10 @@ interface JSZip {
287
309
* @param onUpdate The optional function called on each internal update with the metadata.
288
310
* @return The serialized archive
289
311
*/
290
- generateAsync < T extends JSZip . OutputType > ( options ?: JSZip . JSZipGeneratorOptions < T > , onUpdate ?: OnUpdateCallback ) : Promise < OutputByType [ T ] > ;
312
+ generateAsync < T extends JSZip . OutputType > (
313
+ options ?: JSZip . JSZipGeneratorOptions < T > ,
314
+ onUpdate ?: OnUpdateCallback
315
+ ) : Promise < OutputByType [ T ] > ;
291
316
292
317
/**
293
318
* Generates a new archive asynchronously
@@ -296,15 +321,20 @@ interface JSZip {
296
321
* @param onUpdate The optional function called on each internal update with the metadata.
297
322
* @return A Node.js `ReadableStream`
298
323
*/
299
- generateNodeStream ( options ?: JSZip . JSZipGeneratorOptions < 'nodebuffer' > , onUpdate ?: OnUpdateCallback ) : NodeJS . ReadableStream ;
324
+ generateNodeStream (
325
+ options ?: JSZip . JSZipGeneratorOptions < "nodebuffer" > ,
326
+ onUpdate ?: OnUpdateCallback
327
+ ) : NodeJS . ReadableStream ;
300
328
301
329
/**
302
330
* Generates the complete zip file with the internal stream implementation
303
331
*
304
332
* @param options Optional options for the generator
305
333
* @return a StreamHelper
306
334
*/
307
- generateInternalStream < T extends JSZip . OutputType > ( options ?: JSZip . JSZipGeneratorOptions < T > ) : JSZip . JSZipStreamHelper < OutputByType [ T ] > ;
335
+ generateInternalStream < T extends JSZip . OutputType > (
336
+ options ?: JSZip . JSZipGeneratorOptions < T >
337
+ ) : JSZip . JSZipStreamHelper < OutputByType [ T ] > ;
308
338
309
339
/**
310
340
* Deserialize zip file asynchronously
@@ -313,12 +343,15 @@ interface JSZip {
313
343
* @param options Options for deserializing
314
344
* @return Returns promise
315
345
*/
316
- loadAsync ( data : InputFileFormat , options ?: JSZip . JSZipLoadOptions ) : Promise < JSZip > ;
346
+ loadAsync (
347
+ data : InputFileFormat ,
348
+ options ?: JSZip . JSZipLoadOptions
349
+ ) : Promise < JSZip > ;
317
350
318
351
/**
319
352
* Create JSZip instance
320
353
*/
321
- new ( ) : this;
354
+ new ( ) : this;
322
355
323
356
( ) : JSZip ;
324
357
0 commit comments