Skip to content

Commit

Permalink
Consolidate metadata types and expose OnUpdateCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuk committed Jul 20, 2022
1 parent 5be00df commit 852887a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions index.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
/**
Expand Down Expand Up @@ -170,11 +170,6 @@ declare namespace JSZip {
decodeFileName?: (bytes: string[] | Uint8Array | Buffer) => string;
}

interface JSZipMetadata {
percent: number;
currentFile: string;
}

type DataEventCallback<T> = (dataChunk: T, metadata: JSZipMetadata) => void
type EndEventCallback = () => void
type ErrorEventCallback = (error: Error) => void
Expand Down Expand Up @@ -287,7 +282,7 @@ interface JSZip {
* @param onUpdate The optional function called on each internal update with the metadata.
* @return The serialized archive
*/
generateAsync<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>, onUpdate?: OnUpdateCallback): Promise<OutputByType[T]>;
generateAsync<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>, onUpdate?: JSZip.OnUpdateCallback): Promise<OutputByType[T]>;

/**
* Generates a new archive asynchronously
Expand All @@ -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
Expand Down

0 comments on commit 852887a

Please sign in to comment.