Class LRUMap<K, V>

LRU (Least Recently Used) Map implementation

Type Parameters

  • K = any

  • V = any

Hierarchy

Constructors - Functional

  • LRU (Least Recently Used) Map implementation

    will remove the oldest item when reach the size limit

    Type Parameters

    • K = any

    • V = any

    Parameters

    • maxSize: number = 1024

      maximum cache item number, default is 1024

    Returns LRUMap<K, V>

    Since

    5.15.0

    Example

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

Properties

[toStringTag]: string
size: number

Returns

the number of elements in the Map.

[species]: MapConstructor

Methods

  • Returns an iterable of entries in the map.

    Returns IterableIterator<[K, V]>

  • Parameters

    • key: K

    Returns boolean

    true if an element in the Map existed and has been removed, or false if the element does not exist.

  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[K, V]>

  • Executes a provided function once per each key/value pair in the Map, in insertion order.

    Parameters

    • callbackfn: ((value, key, map) => void)
        • (value, key, map): void
        • Parameters

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

          Returns void

    • Optional thisArg: any
      Optional

    Returns void

  • Parameters

    • key: K

    Returns boolean

    boolean indicating whether an element with the specified key exists or not.

  • Returns an iterable of keys in the map

    Returns IterableIterator<K>

  • Returns an iterable of values in the map

    Returns IterableIterator<V>