Class LRUMap<K, V>

LRU (Least Recently Used) Map implementation

Type Parameters

  • K = any

  • V = any

Hierarchy

Functional Constructors

  • LRU (Least Recently Used) Map implementation

    will remove the oldest item when reach the size limit

    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

Returns

the number of elements in the Map.

[species]: MapConstructor

Methods

  • Returns an iterable of entries in the map.

    Returns IterableIterator<[K, V]>

  • Returns void

  • Returns

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

    Parameters

    • key: K

    Returns boolean

  • 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: 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

  • Parameters

    • key: K

    Returns V

  • Returns number

  • Returns

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

    Parameters

    • key: K

    Returns boolean

  • Returns an iterable of keys in the map

    Returns IterableIterator<K>

  • Parameters

    • key: K
    • val: V

    Returns LRUMap<K, V>

  • Parameters

    • maxSize: number

    Returns void

  • Returns an iterable of values in the map

    Returns IterableIterator<V>