declare enum Status { UNTERMINATED = 0, TERMINATED = 1, ERRORED = 2 } interface CacheNode { s: Status; v: any; e: number; swr: number; sie: number; _maxAge: number; _swr: number; _sie: number; } interface Options { maxAge?: number; swr?: number; sie?: number; globalCache?: boolean; gcThrottle?: number; cacheFulfilled?: (args: any[], value: any) => boolean; cacheRejected?: (args: any[], error: any) => boolean; argsEqual?: (a: any[], b: any[]) => boolean; storeCreator?: (promiseFn: PromiseFn, globalCache?: boolean) => any; onEmitted?: (event: string, info: { cache: Map; args?: any[]; gcCount?: number; }) => void; } type PromiseFn = (...args: any[]) => Promise; /** * @param {Function} promiseFn * @param {Number} options.maxAge Cache validity period (ms), default is 0, when it is Infinity, it is cached permanently * @param {Number} options.swr Cache expiration tolerance time (ms), default Infinity * @param {Number} options.sie Update error tolerance time (ms), default is Infinity * @param {Number} options.gcThrottle Garbage collection throttling time (ms), the default is 0, when it is 0, no garbage collection is performed * * @param {Function} options.cacheFulfilled Whether to cache the current normal result, the default is true (arguments, value) => boolean * @param {Function} options.cacheRejected Whether to cache the current exception result, the default is false (arguments, error) => boolean * @returns */ export default function swrPromise(promiseFn: PromiseFn, options?: Options): (...args: any[]) => Promise; export {};