Skip to content

Commit 852887a

Browse files
committed
Consolidate metadata types and expose OnUpdateCallback
1 parent 5be00df commit 852887a

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

index.d.ts

+9-14
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ interface CompressionOptions {
2323
level: number;
2424
}
2525

26-
interface Metadata {
27-
percent: number;
28-
currentFile: string | null;
29-
}
30-
31-
type OnUpdateCallback = (metadata: Metadata) => void;
32-
3326
interface InputByType {
3427
base64: string;
3528
string: string;
@@ -71,6 +64,13 @@ declare namespace JSZip {
7164

7265
type OutputType = keyof OutputByType;
7366

67+
interface JSZipMetadata {
68+
percent: number;
69+
currentFile: string | null;
70+
}
71+
72+
type OnUpdateCallback = (metadata: JSZipMetadata) => void;
73+
7474
interface JSZipObject {
7575
name: string;
7676
/**
@@ -170,11 +170,6 @@ declare namespace JSZip {
170170
decodeFileName?: (bytes: string[] | Uint8Array | Buffer) => string;
171171
}
172172

173-
interface JSZipMetadata {
174-
percent: number;
175-
currentFile: string;
176-
}
177-
178173
type DataEventCallback<T> = (dataChunk: T, metadata: JSZipMetadata) => void
179174
type EndEventCallback = () => void
180175
type ErrorEventCallback = (error: Error) => void
@@ -287,7 +282,7 @@ interface JSZip {
287282
* @param onUpdate The optional function called on each internal update with the metadata.
288283
* @return The serialized archive
289284
*/
290-
generateAsync<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>, onUpdate?: OnUpdateCallback): Promise<OutputByType[T]>;
285+
generateAsync<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>, onUpdate?: JSZip.OnUpdateCallback): Promise<OutputByType[T]>;
291286

292287
/**
293288
* Generates a new archive asynchronously
@@ -296,7 +291,7 @@ interface JSZip {
296291
* @param onUpdate The optional function called on each internal update with the metadata.
297292
* @return A Node.js `ReadableStream`
298293
*/
299-
generateNodeStream(options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>, onUpdate?: OnUpdateCallback): NodeJS.ReadableStream;
294+
generateNodeStream(options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>, onUpdate?: JSZip.OnUpdateCallback): NodeJS.ReadableStream;
300295

301296
/**
302297
* Generates the complete zip file with the internal stream implementation

0 commit comments

Comments
 (0)