From f1eb6fe45a1dc8b6fe0826d75aedc0d5b7ead25f Mon Sep 17 00:00:00 2001 From: August Date: Sat, 23 Feb 2019 17:22:12 -0700 Subject: [PATCH] Update typings --- index.d.ts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7f9de14..4f01b3e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; } }