mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-06-08 22:18:18 +02:00
Updated Typings
This commit is contained in:
29
index.d.ts
vendored
29
index.d.ts
vendored
@@ -3,56 +3,55 @@
|
|||||||
|
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
|
|
||||||
/** The package wumpfetch */
|
|
||||||
declare namespace w {
|
declare namespace w {
|
||||||
/**
|
/**
|
||||||
* Declares a `GET` request
|
* Declares a `GET` request
|
||||||
* @param url The url of the request
|
* @param url The url of the request
|
||||||
* @returns The request to execute
|
* @returns The request to execute
|
||||||
*/
|
*/
|
||||||
export function get(url: string | w.URLOptions): w.WumpRequest;
|
export function get(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares a `POST` request
|
* Declares a `POST` request
|
||||||
* @param url The url of the request
|
* @param url The url of the request
|
||||||
* @returns The request to execute
|
* @returns The request to execute
|
||||||
*/
|
*/
|
||||||
export function post(url: string | w.URLOptions): w.WumpRequest;
|
export function post(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares a `PUT` request
|
* Declares a `PUT` request
|
||||||
* @param url The url of the request
|
* @param url The url of the request
|
||||||
* @returns The request class
|
* @returns The request class
|
||||||
*/
|
*/
|
||||||
export function put(url: string | w.URLOptions): w.WumpRequest;
|
export function put(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares a `PATCH` request
|
* Declares a `PATCH` request
|
||||||
* @param url The url
|
* @param url The url
|
||||||
* @returns The request class
|
* @returns The request class
|
||||||
*/
|
*/
|
||||||
export function patch(url: string | w.URLOptions): w.WumpRequest;
|
export function patch(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares a `CONNECT` request
|
* Declares a `CONNECT` request
|
||||||
* @param url The url
|
* @param url The url
|
||||||
* @returns The request class
|
* @returns The request class
|
||||||
*/
|
*/
|
||||||
export function connect(url: string | w.URLOptions): w.WumpRequest;
|
export function connect(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares an `OPTIONS` request
|
* Declares an `OPTIONS` request
|
||||||
* @param url The url
|
* @param url The url
|
||||||
* @returns The request class
|
* @returns The request class
|
||||||
*/
|
*/
|
||||||
export function options(url: string | w.URLOptions): w.WumpRequest;
|
export function options(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares an `TRACE` request
|
* Declares an `TRACE` request
|
||||||
* @param url The url
|
* @param url The url
|
||||||
* @returns The request class
|
* @returns The request class
|
||||||
*/
|
*/
|
||||||
export function trace(url: string | w.URLOptions): w.WumpRequest;
|
export function trace(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
|
|
||||||
/** The request class */
|
/** The request class */
|
||||||
export class WumpRequest {
|
export class WumpRequest {
|
||||||
@@ -64,13 +63,14 @@ declare namespace w {
|
|||||||
parse: any;
|
parse: any;
|
||||||
follow: boolean;
|
follow: boolean;
|
||||||
streamed: boolean;
|
streamed: boolean;
|
||||||
|
chaining: boolean;
|
||||||
compressed: boolean;
|
compressed: boolean;
|
||||||
rHeaders: { [x: string]: string; }
|
rHeaders: { [x: string]: string; }
|
||||||
timeoutTime: number;
|
timeoutTime: number;
|
||||||
coreOptions: object;
|
coreOptions: object;
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(url: string | w.URLOptions, method?: w.URLMethods);
|
constructor(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions);
|
||||||
public query(a: string | object, b?: string): this;
|
public query(a: string | object, b?: string): this;
|
||||||
public body(data: any, SA?: any): this;
|
public body(data: any, SA?: any): this;
|
||||||
public header(a: string | object, b?: string): this;
|
public header(a: string | object, b?: string): this;
|
||||||
@@ -92,21 +92,22 @@ declare namespace w {
|
|||||||
private _addChunk(chunk: any): void;
|
private _addChunk(chunk: any): void;
|
||||||
public text(): string;
|
public text(): string;
|
||||||
public json(): NormalObject;
|
public json(): NormalObject;
|
||||||
|
public json<T>(): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type KVObject = { [x: string]: string };
|
export type KVObject = { [x: string]: string };
|
||||||
export type NormalObject = { [x: string]: any };
|
export type NormalObject = { [x: string]: any };
|
||||||
export type URLMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | "DELETE" | 'CONNECT' | 'OPTIONS' | 'TRACE';
|
export type URLMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | "DELETE" | 'CONNECT' | 'OPTIONS' | 'TRACE';
|
||||||
// wessel add more options when needed
|
|
||||||
export interface URLOptions {
|
export interface URLOptions {
|
||||||
url: string;
|
url: string;
|
||||||
method: URLMethods;
|
method: URLMethods;
|
||||||
data?: NormalObject;
|
data?: NormalObject;
|
||||||
headers?: KVObject;
|
headers?: KVObject;
|
||||||
|
chain?: boolean;
|
||||||
|
parse?: 'json' | 'buffer' | 'form';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'wumpfetch' {
|
declare function w(url: string | w.URLOptions, method?: w.URLMethods | w.URLOptions): w.WumpRequest;
|
||||||
export function w(url: string | w.URLOptions): w.WumpRequest;
|
|
||||||
export = w;
|
export = w;
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user