UNPKG

thorish

Version:

This is a library of useful JS concepts and data structures for Node and the browser. It it, unashamedly, a dumping ground for code needed by [@samthor](https://twitter.com/samthor)'s projects.

25 lines (24 loc) 591 B
/** * A dead-simple cache helper. */ export declare class SimpleCache<K, V> { private readonly gen; private readonly m; constructor(gen: (k: K) => V); /** * Copies this as a regular {@link Map}. */ copy(): Map<K, V>; has(k: K): boolean; get(k: K): V; get size(): number; clear(): void; keys(): MapIterator<K>; entries(): MapIterator<[K, V]>; values(): MapIterator<V>; delete(k: K): boolean; } /** * Return a helper which runs the passed function at most once. */ export declare function once<T = void>(fn: () => T): () => T;