Options
All
  • Public
  • Public/Protected
  • All
Menu

LRU (Least Recently Used) Map implementation

Type parameters

  • K = any

  • V = any

Hierarchy

Index

Functional Constructors

  • new LRUMap<K, V>(maxSize?: number): LRUMap<K, V>
  • LRU (Least Recently Used) Map implementation

    will remove the oldest item when reach the size limit

    category

    Functional

    since

    5.15.0

    example
    const m = new LRUMap(1)
    m.set('a','v') // {'a':'v'}
    m.set('b','c') // {'b':'c'}

    Type parameters

    • K = any

    • V = any

    Parameters

    • maxSize: number = 1024

      maximum cache item number, default is 1024

    Returns LRUMap<K, V>

Properties

[toStringTag]: string
size: number
[species]: MapConstructor

Methods

  • [iterator](): IterableIterator<[K, V]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[K, V]>

  • clear(): void
  • Returns void

  • delete(key: K): boolean
  • Parameters

    • key: K

    Returns boolean

  • entries(): IterableIterator<[K, V]>
  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[K, V]>

  • forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: V, key: K, map: Map<K, V>) => void
        • (value: V, key: K, map: Map<K, V>): void
        • Parameters

          • value: V
          • key: K
          • map: Map<K, V>

          Returns void

    • Optional thisArg: any

    Returns void

  • get(key: K): V
  • Parameters

    • key: K

    Returns V

  • getMaxSize(): number
  • Returns number

  • has(key: K): boolean
  • Parameters

    • key: K

    Returns boolean

  • keys(): IterableIterator<K>
  • Returns an iterable of keys in the map

    Returns IterableIterator<K>

  • set(key: K, val: V): LRUMap<K, V>
  • Parameters

    • key: K
    • val: V

    Returns LRUMap<K, V>

  • setMaxSize(maxSize: number): void
  • Parameters

    • maxSize: number

    Returns void

  • values(): IterableIterator<V>
  • Returns an iterable of values in the map

    Returns IterableIterator<V>