/** * Represents a function used to resolve an entity by key. */ export declare type ILookupResolver = (key: Key) => Value; /** * Represents an in-memory cache that allows values to be resolved on-demand. */ export interface ILookup { /** * Looks up the value or the specified key. * If the value has already been resolved, the cached value will be returned; otherwise, * the value will be resolved. * @param key The key of the value to retrieve. */ find(key: Key): Value; /** * Stores the specified key/value pair and replaces the cached value. * @param key The key to override. * @param value The value to override. */ inject(key: Key, value: Value): void; /** * Clears the specified key and invalidates the cache. * @param key The key to invalidate. */ clear(key: Key): void; /** * Clears all keys and invalidates the cache. * @param key The key to invalidate. */ clearAll(): void; } /** * Represents a simple hash (JSON object). */ export declare type Hash = { [key: string | number]: Value; }; /** * Represents an in-memory cache that allows values to be resolved on-demand. */ export declare class Lookup implements ILookup { private readonly resolver; private readonly values; constructor(resolver: ILookupResolver); /** * Stores the specified key/value pair and replaces the cached value. * @param key The key to override. * @param value The value to override. */ inject(key: Key, value: Value): void; /** * Looks up the value or the specified key. * If the value has already been resolved, the cached value will be returned; otherwise, * the value will be resolved. * @param key The key of the value to retrieve. */ find(key: Key): Value; /** * Clears the specified key and invalidates the cache. * @param key The key to invalidate. */ clear(key: Key): void; /** * Clears all keys and invalidates the cache. * @param key The key to invalidate. */ clearAll(): void; }