From 852887aa9483c552cd88e4eb8c298a475c0f9269 Mon Sep 17 00:00:00 2001 From: Stuart Knightley Date: Wed, 20 Jul 2022 14:25:06 -0700 Subject: [PATCH] Consolidate metadata types and expose OnUpdateCallback --- index.d.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4d646ada..b1c93082 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,13 +23,6 @@ interface CompressionOptions { level: number; } -interface Metadata { - percent: number; - currentFile: string | null; -} - -type OnUpdateCallback = (metadata: Metadata) => void; - interface InputByType { base64: string; string: string; @@ -71,6 +64,13 @@ declare namespace JSZip { type OutputType = keyof OutputByType; + interface JSZipMetadata { + percent: number; + currentFile: string | null; + } + + type OnUpdateCallback = (metadata: JSZipMetadata) => void; + interface JSZipObject { name: string; /** @@ -170,11 +170,6 @@ declare namespace JSZip { decodeFileName?: (bytes: string[] | Uint8Array | Buffer) => string; } - interface JSZipMetadata { - percent: number; - currentFile: string; - } - type DataEventCallback = (dataChunk: T, metadata: JSZipMetadata) => void type EndEventCallback = () => void type ErrorEventCallback = (error: Error) => void @@ -287,7 +282,7 @@ interface JSZip { * @param onUpdate The optional function called on each internal update with the metadata. * @return The serialized archive */ - generateAsync(options?: JSZip.JSZipGeneratorOptions, onUpdate?: OnUpdateCallback): Promise; + generateAsync(options?: JSZip.JSZipGeneratorOptions, onUpdate?: JSZip.OnUpdateCallback): Promise; /** * Generates a new archive asynchronously @@ -296,7 +291,7 @@ interface JSZip { * @param onUpdate The optional function called on each internal update with the metadata. * @return A Node.js `ReadableStream` */ - generateNodeStream(options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>, onUpdate?: OnUpdateCallback): NodeJS.ReadableStream; + generateNodeStream(options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>, onUpdate?: JSZip.OnUpdateCallback): NodeJS.ReadableStream; /** * Generates the complete zip file with the internal stream implementation