@newdash/newdash
Version:
javascript/typescript utility library
34 lines (33 loc) • 816 B
TypeScript
/**
* LRU (Least Recently Used) Map implementation
*/
export declare class LRUMap<K = any, V = any> extends Map<K, V> {
/**
* the max number of total items
*/
private _maxSize;
/**
* LRU (Least Recently Used) Map implementation
*
* will remove the oldest item when reach the size limit
*
* @category Functional
* @since 5.15.0
* @param maxSize maximum cache item number, default is 1024
* @example
*
* ```ts
* const m = new LRUMap(1)
* m.set('a','v') // {'a':'v'}
* m.set('b','c') // {'b':'c'}
* ```
*/
constructor(maxSize?: number);
get(key: K): V;
set(key: K, val: V): this;
clear(): void;
private first;
setMaxSize(maxSize: number): void;
getMaxSize(): number;
}
export default LRUMap;