@straw-hat/fetcher
Version:
Simple HTTP Client
16 lines (15 loc) • 742 B
TypeScript
import { HttpRequest } from './request.js';
export type Dispatch<T> = (request: HttpRequest) => Promise<T>;
export type Middleware<T, P = Response> = (next: Dispatch<P>) => Dispatch<T>;
export declare function compose(...fns: any[]): any;
/**
* Compose the list of middleware into a single middleware.
* @param middlewares List of middleware
*/
export declare function composeMiddleware<T = any>(...middlewares: Array<Middleware<T, any>>): any;
/**
* This function doesn't really "do anything" at runtime, it's just the identity
* function. Its only purpose is to defeat TypeScript's type.
* @param middleware The middleware
*/
export declare function createMiddleware<T, P = Response>(middleware: Middleware<T, P>): Middleware<T, P>;