Files
wumpfetch/index.d.ts
August 7774f3c435 Update typings
Wessel, tell me the profile data so I can add it to typings too!
2019-07-10 07:17:58 -07:00

68 lines
2.8 KiB
TypeScript

declare module 'wumpfetch' {
import { URL } from 'url';
import { IncomingMessage, ServerResponse } from 'http';
export function get(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function post(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function put(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function patch(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function connect(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function options(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
export function trace(url: string | URLOptions, method?: URLMethod | URLOptions): WumpRequest;
export class WumpRequest {
public o: {
m: string;
url: URL;
data: any;
parse: any;
follow: boolean;
streamed: boolean;
chaining: boolean;
compressed: boolean;
rHeaders: { [x: string]: string; }
timeoutTime: number;
coreOptions: object;
};
constructor(url: string | URLOptions, method?: URLMethod | MethodOptions);
public query(a: string | object, b?: string): this;
public body(data: any, SA?: any): this;
public header(a: string | object, b?: string): this;
public compress(): this;
public path(p: string): this;
public stream(): this;
public option(n: string, v: string): this;
public timeout(timeout: number): this;
public send(): Promise<WumpResponse>;
}
export class WumpResponse {
public body: Buffer | string;
public coreRes: ServerResponse;
public headers: { [x: string]: string };
public statusCode: number;
constructor(res: any);
private _addChunk(chunk: any): void;
public text(): string;
public json(): NormalObject;
public json<T>(): T;
}
export type KVObject = { [x: string]: string };
export type NormalObject = { [x: string]: any };
export type URLMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | "DELETE" | 'CONNECT' | 'OPTIONS' | 'TRACE';
export interface URLOptions {
url: string;
method: URLMethods;
data?: NormalObject;
headers?: KVObject;
chaining?: boolean;
parse?: 'json' | 'buffer' | 'form';
}
export interface MethodOptions {
method?: URLMethods;
data?: NormalObject;
headers?: KVObject;
chaining?: boolean;
parse?: 'json' | 'buffer' | 'form';
}
export default function w(url: string | URLOptions, method?: URLMethod | MethodOptions): WumpRequest;
}