import { CancellationToken } from './cancellation.js'; import { IDisposable } from './lifecycle.js'; export interface CacheResult extends IDisposable { promise: Promise; } export declare class Cache { private task; private result; constructor(task: (ct: CancellationToken) => Promise); get(): CacheResult; } export declare function identity(t: T): T; interface ICacheOptions { /** * The cache key is used to identify the cache entry. * Strict equality is used to compare cache keys. */ getCacheKey: (arg: TArg) => unknown; } /** * Uses a LRU cache to make a given parametrized function cached. * Caches just the last key/value. */ export declare class LRUCachedFunction { private lastCache; private lastArgKey; private readonly _fn; private readonly _computeKey; constructor(fn: (arg: TArg) => TComputed); constructor(options: ICacheOptions, fn: (arg: TArg) => TComputed); get(arg: TArg): TComputed; } /** * Uses an unbounded cache to memoize the results of the given function. */ export declare class CachedFunction { private readonly _map; private readonly _map2; get cachedValues(): ReadonlyMap; private readonly _fn; private readonly _computeKey; constructor(fn: (arg: TArg) => TComputed); constructor(options: ICacheOptions, fn: (arg: TArg) => TComputed); get(arg: TArg): TComputed; } export {};