Update typings

This commit is contained in:
August
2019-02-23 17:22:12 -07:00
committed by GitHub
parent 953a1b5056
commit f1eb6fe45a

37
index.d.ts vendored
View File

@@ -1,19 +1,37 @@
// Typings for component: "wumpfetch"
// Typings created by auguwu, project made by Wesselgame / PassTheWessel
import { URL } from 'url';
/** The package wumpfetch */
declare namespace wumpfetch {
/**
* Declares a `GET` request
* @param url The url of the request
* @returns The request to execute
*/
export function get(url: string): wumpfetch.WumpRequest;
export function get(url: string | wumpfetch.URLOptions): wumpfetch.WumpRequest;
/**
* Declares a `POST` request
* @param url The url of the request
* @returns The request to execute
*/
export function post(url: string): wumpfetch.WumpRequest;
export function post(url: string | wumpfetch.URLOptions): wumpfetch.WumpRequest;
/**
* Declares a `PUT` request
* @param url The url of the request
* @returns The request class
*/
export function put(url: string | wumpfetch.URLOptions): wumpfetch.WumpRequest;
/**
* Declares a `PATCH` request
* @param url The url
* @returns The request class
*/
export function patch(url: string | wumpfetch.URLOptions): wumpfetch.WumpRequest;
/** The request class */
export class WumpRequest {
@@ -31,7 +49,7 @@ declare namespace wumpfetch {
coreOptions: object;
};
constructor(url: string, method: string);
constructor(url: string | wumpfetch.URLOptions, method?: wumpfetch.URLMethods);
public query(a: string | object, b?: string): this;
public body(data: any, SA: any): this;
public header(a: string | object, b?: string): this;
@@ -52,7 +70,18 @@ declare namespace wumpfetch {
constructor(res: any);
private _addChunk(chunk: any): void;
public text(): string;
public json(): { [x: string]: any };
public json(): NormalObject;
}
export type KVObject = { [x: string]: string };
export type NormalObject = { [x: string]: any };
export type URLMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | "DELETE";
// wessel add more options when needed
export interface URLOptions {
url: string;
method: URLMethods;
data?: NormalObject;
headers?: KVObject;
}
}