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