UNPKG

r3bl-ts-utils

Version:

The `r3bl-ts-utils` package is a set of useful TypeScript functions and classes that can be used in Node.js and browser environments. They are inspired by Kotlin stdlib, and Rust to write code as expressions rather than statements, colorized text, powerfu

20 lines (19 loc) 883 B
import { Analytics } from "./analytics"; import { Cache, ComputeValueForKeyAsyncFn, ComputeValueForKeyFn, EvictionPolicy } from "./externals"; export declare class CacheImpl<K, V> implements Cache<K, V> { readonly name: string; readonly maxSize: number; readonly evictionPolicy: EvictionPolicy; readonly _map: Map<K, V>; readonly analytics: Analytics.KeyHistory<K>; constructor(name: string, maxSize: number, evictionPolicy: EvictionPolicy); clear: () => void; get: (arg: K) => V | undefined; getAndComputeIfAbsent: (arg: K, keyNotFoundFn: ComputeValueForKeyFn<K, V>) => V; getAndComputeIfAbsentAsync: (arg: K, keyNotFoundAsyncFn: ComputeValueForKeyAsyncFn<K, V>) => Promise<V>; cleanUp: () => void; put: (arg: K, value: V) => void; contains: (arg: K) => boolean; /** Getter that returns the size. */ get size(): number; }