evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a lightweight HTTP client factory that wraps a fetch-compatible library, supports layered defaults, and works with request/response primitives.
export interface ClientDefaults {
baseUrl?: string;
headers?: Record<string, string>;
retry?: number | {
retries?: number;
factor?: number;
maxTimeout?: number;
minTimeout?: number;
randomize?: boolean;
};
}
export interface RequestLike {
url: string | URL;
method?: string;
headers?: Record<string, string>;
body?: any;
}
export interface HttpClient {
request(input: string | URL | RequestLike, init?: {
method?: string;
headers?: Record<string, string>;
body?: any;
}): Promise<Response>;
withDefaults(overrides: ClientDefaults): HttpClient;
}
export function createHttpClient(defaults?: ClientDefaults): HttpClient;HTTP client with fetch-compatible Request/Response primitives and default-layering support.