/// /** An outdated or not found value from cache */ export type Invalid = Record & Tag.OpaqueTag<"Invalid">; export declare const Invalid: Invalid; /** * Check is {@link v} is not {@link Invalid}. * @param v thing to check * @returns whether v is found or not */ export declare function isValid(v: V | Invalid): v is V; /** * Wrap {@link fn} with a cache indexed by {@link K}. * @example sort(ts, cache(t => "heavy compute...")) * @param fn function to cache * @param getK optional function to extract {@link K} from {@link Ts} * @returns cached function */ export declare function cache(fn: (...ts: Ts) => V, getK: ((...ts: Ts) => K) | (Ts extends [K] ? undefined : never)): (...ts: Ts) => V; /** * Wrap {@link fn} with a cache indexed by {@link K} it is refreshed every given {@link ticks}. * @param fn function to cache * @param ticks number of ticks to keep * @returns cached function */ export declare function cacheForTicks(fn: (key: K) => V, ticks?: number): (key: K) => V;