got-typings: use proper options for got download

This commit is contained in:
Dominique
2018-03-16 17:26:58 +01:00
parent 17c3e0a996
commit 669da2ca54
2 changed files with 48 additions and 56 deletions
+29 -27
View File
@@ -7,33 +7,35 @@
export = decompress;
declare function decompress(input: string | Buffer, output: string, opts?: Options): Promise<File>;
declare function decompress(input: string | Buffer, output: string, opts?: decompress.DecompressOptions): Promise<decompress.File>;
interface File {
data: Buffer;
mode: number;
mtime: string;
path: string;
type: string;
}
declare namespace decompress {
interface File {
data: Buffer;
mode: number;
mtime: string;
path: string;
type: string;
}
interface Options {
/**
* Filter out files before extracting
*/
filter?(file: File): boolean;
/**
* Map files before extracting
*/
map?(file: File): File;
/**
* Array of plugins to use.
* Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]
*/
plugins?: any[];
/**
* Remove leading directory components from extracted files.
* Default: 0
*/
strip?: number;
interface DecompressOptions {
/**
* Filter out files before extracting
*/
filter?(file: File): boolean;
/**
* Map files before extracting
*/
map?(file: File): File;
/**
* Array of plugins to use.
* Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]
*/
plugins?: any[];
/**
* Remove leading directory components from extracted files.
* Default: 0
*/
strip?: number;
}
}
+19 -29
View File
@@ -5,38 +5,28 @@
// TypeScript Version: 2.2
/// <reference types="node" />
import { DecompressOptions } from 'decompress';
import { GotBodyOptions, TimeoutOptions } from 'got';
interface TimeoutOptions {
connect?: number;
socket?: number;
request?: number;
}
type RetryFunction = (retry: number, error: any) => number;
declare namespace download {
type RetryFunction = (retry: number, error: any) => number;
interface DownloadOptions {
body?: string | Buffer | NodeJS.ReadableStream;
encoding?: string | null;
query?: string | object;
timeout?: number | TimeoutOptions;
retries?: number | RetryFunction;
followRedirect?: boolean;
decompress?: boolean;
useElectronNet?: boolean;
/**
* If set to true, try extracting the file using decompress.
*/
extract?: boolean;
/**
* Name of the saved file.
*/
filename?: string;
/**
* Proxy endpoint
*/
proxy?: string;
interface DownloadOptions extends DecompressOptions, GotBodyOptions<string> {
/**
* If set to true, try extracting the file using decompress.
*/
extract?: boolean;
/**
* Name of the saved file.
*/
filename?: string;
/**
* Proxy endpoint
*/
proxy?: string;
}
}
declare namespace download {}
declare function download(url: string, destination?: string, options?: DownloadOptions): Promise<Buffer> & NodeJS.WritableStream & NodeJS.ReadableStream;
declare function download(url: string, destination?: string, options?: download.DownloadOptions): Promise<Buffer> & NodeJS.WritableStream & NodeJS.ReadableStream;
export = download;