Skip to content

Commit

Permalink
Merge pull request #852 from Stuk/metadata-ts
Browse files Browse the repository at this point in the history
Consolidate metadata types and expose OnUpdateCallback
  • Loading branch information
Stuk authored Jul 21, 2022
2 parents 5be00df + 852887a commit f299cce
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
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 f299cce

Please sign in to comment.