UNPKG

xior

Version:

A lite http request lib based on fetch with plugins support and similar API to axios.

29 lines (26 loc) 1.07 kB
import { I as ICacheLike } from '../utils-_ORP98vM.mjs'; import { a as XiorRequestConfig, d as XiorResponse, e as XiorPlugin } from '../xior-D4BXsC0R.mjs'; type XiorPromise = Promise<XiorResponse>; type RecordedCache = { timestamp: number; value?: XiorPromise; }; type XiorThrottleOptions = { /** threshold in milliseconds, default: 1000ms */ threshold?: number; /** * check if we need enable throttle, default only `GET` method or`isGet: true` enable */ enableThrottle?: boolean | ((config?: XiorRequestConfig) => boolean); throttleCache?: ICacheLike<RecordedCache>; onThrottle?: (config: XiorRequestConfig) => void; /** max throttle numbers in LRU, default is 100 */ throttleItems?: number; }; /** @ts-ignore */ declare module 'xior' { interface XiorRequestConfig extends Omit<XiorThrottleOptions, 'throttleCache' | 'throttleItems'> { } } declare function xiorThrottlePlugin(options?: XiorThrottleOptions): XiorPlugin; export { type RecordedCache, type XiorThrottleOptions, xiorThrottlePlugin as default };