xior
Version:
A lite http request lib based on fetch with plugins support and similar API to axios.
36 lines (33 loc) • 1.21 kB
text/typescript
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 XiorCacheOptions = {
/**
* check if we need enable cache, default only `GET` method or`isGet: true` enable cache
*/
enableCache?: boolean | ((config?: XiorRequestConfig) => boolean);
defaultCache?: ICacheLike<XiorPromise>;
/** max cache number in LRU, default is 100 */
cacheItems?: number;
/** cache time in ms, default is 5 minutes */
cacheTime?: number;
};
/** @ts-ignore */
declare module 'xior' {
interface XiorRequestConfig extends Omit<XiorCacheOptions, 'cacheItems' | 'cacheTime'> {
/** forceUpdate, default: false */
forceUpdate?: boolean;
}
interface XiorResponse {
fromCache?: boolean;
cacheTime?: number;
cacheKey?: string;
}
interface XiorResponseInterceptorConfig {
fromCache?: boolean;
cacheTime?: number;
cacheKey?: string;
}
}
declare function xiorCachePlugin(options?: XiorCacheOptions): XiorPlugin;
export { type XiorCacheOptions, xiorCachePlugin as default };