Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions types/unzipper.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
import 'unzipper';
import type { Readable } from 'stream';

declare module 'unzipper' {
type Source = {
stream: (offset: number, length: number) => NodeJS.ReadableStream;
size: () => Promise<number>;
};
type Options = {
/**
* Represents a source from which ZIP data can be streamed.
*/
export interface Source {
stream(offset: number, length: number): Readable;
size(): Promise<number>;
}

/**
* Optional configuration for reading ZIP files.
*/
export interface Options {
tailSize?: number;
};
namespace Open {
function custom(
source: Source,
options?: Options,
): Promise<CentralDirectory>;
}

/**
* Represents the central directory structure of the ZIP file.
* This is part of unzipper’s internal API.
*/
export interface CentralDirectory {
files: unknown[];
comment: string;
}

export namespace Open {
/**
* Opens a ZIP file from a custom source.
*
* @param source - A custom data source providing stream and size methods.
* @param options - Optional configuration for reading ZIP files.
* @returns A promise resolving to a CentralDirectory instance.
*/
function custom(source: Source, options?: Options): Promise<CentralDirectory>;
}
}
Loading