Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve types of uncompress (close #157) #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions index.d.ts
Expand Up @@ -7,23 +7,23 @@ export interface DecOptions {
asBuffer?: boolean
/**
* do not use `create_external_buffer` to create the output buffer

* set this option to `true` will make the API slower

* for compatibility with electron >= 21

* see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
*/
copyOutputData?: boolean
}
export interface EncOptions {
/**
* do not use `create_external_buffer` to create the output buffer

* for compatibility with electron >= 21

* set this option to `true` will make the API slower

* see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
*/
copyOutputData?: boolean
Expand All @@ -34,9 +34,9 @@ export function compress(
options?: EncOptions | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<Buffer>
export function uncompressSync(input: string | Buffer, options?: DecOptions | undefined | null): string | Buffer
export function uncompress(
export function uncompressSync<T extends DecOptions>(input: string | Buffer, options?: T | undefined | null): T extends { asBuffer: false } ? string : Buffer
export function uncompress<T extends DecOptions>(
input: string | Buffer,
options?: DecOptions | undefined | null,
options?: T | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string | Buffer>
): Promise<T extends { asBuffer: false } ? string : Buffer>