/** * 默认缓存索引生成函数, * 使用 `url`,`method`,`responseType`,`dataType`,`filePath`,`name`参数 + `data`或`formData`构建缓存Key * 请求的`header` 默认会被忽略 * @param opts 请求参数对象 * @template TOptions 完整请求参数 * @returns string */ export declare function defaultKeyBuilder(opts: TOptions): string; /** * 是否为2xx数据 * @param res 完整返回数据 */ export declare function isOkResult(res: BaseSuccessRes): boolean; /** * 缓存操作, * 维护缓存结果,自动合并同样请求的并发操作 * @template TRes 操作结果回调数据类型 * @template TOptions 参数数据类型 * @template TTask 微信任务类型 */ export declare class CacheOperator { /** * 缓存配置 */ readonly config: Configuration; private readonly op; private readonly cache; /** * 正在处理的回调 */ private readonly callbackListMap; /** * 处理完的回调,待删除 */ private readonly completeMap; /** * @param operator 底层操作 * @param config 默认配置 */ constructor(operator: (option: TOptions) => TTask, config?: Configuration); /** * 快速创建一个 */ static createHandler(operator: (option: TOptions) => TTask, config?: Configuration): CacheOperator['handle']; /** * 缓存处理 * @param options - 参数 */ handle(options: TOptions & Partial>): TTask; /** * fixed #10 * 在回调中再次发起操作前清除任务 * @param key cacheKey */ private _getMapBeforeComplete; } export interface Configuration { /** * 缓存时间 */ expire: number; /** * 结果缓存条件 * @param res 结果 */ resultCondition(res: TRes): boolean; /** * 参数缓存条件,无则全部缓存 * @param options request/downloadFile参数 * @returns 返回string键值,无返回值时不进行缓存和请求合并 */ keyBuilder?(options: TOptions): string | void | null | false; } interface WxTask { abort(): void; /** HTTP Response Header 事件的回调函数 */ onHeadersReceived(callback: (result: any) => void): void; /** 下载进度变化事件的回调函数 */ onProgressUpdate?(callback: (res: any) => any): void; } interface WxOptions { /** 开发者服务器接口地址 */ url: string; /** * HTTP 请求 Header */ header?: object; /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?(res: { errMsg: string; }): void; /** 接口调用失败的回调函数 */ fail?(res: { errMsg: string; }): void; /** 接口调用成功的回调函数 */ success?(res: any): any; } interface BaseSuccessRes { errMsg: string; statusCode: number; } export {}; //# sourceMappingURL=cache-operator.d.ts.map