Class: LRUCache<K, V>
A Least Recently Used cache, implemented as an extended Map.
Extends
Map
<K
,V
>
Type Parameters
• K
• V
Constructors
new LRUCache()
new LRUCache<
K
,V
>(maxSize
,entries
?):LRUCache
<K
,V
>
Parameters
• maxSize: number
= 128
• entries?: Iterable
<[K
, V
]>
Returns an iterable of key, value pairs for every entry in the map.
Returns
LRUCache
<K
, V
>
Overrides
Map<K, V>.constructor
Defined in
Properties
[toStringTag]
readonly
[toStringTag]:string
Inherited from
Map.[toStringTag]
Defined in
docs/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137
maxSize
readonly
maxSize:number
Defined in
size
readonly
size:number
Inherited from
Map.size
Defined in
docs/node_modules/typescript/lib/lib.es2015.collection.d.ts:45
[species]
readonly
static
[species]:MapConstructor
Inherited from
Map.[species]
Defined in
docs/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319
Methods
[iterator]()
[iterator]():
IterableIterator
<[K
,V
]>
Returns an iterable of entries in the map.
Returns
IterableIterator
<[K
, V
]>
Inherited from
Map.[iterator]
Defined in
docs/node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
clear()
clear():
void
Returns
void
Inherited from
Map.clear
Defined in
docs/node_modules/typescript/lib/lib.es2015.collection.d.ts:20
delete()
delete(
key
):boolean
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.
Inherited from
Map.delete
Defined in
docs/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
entries()
entries():
IterableIterator
<[K
,V
]>
Returns an iterable of key, value pairs for every entry in the map.
Returns
IterableIterator
<[K
, V
]>
Inherited from
Map.entries
Defined in
docs/node_modules/typescript/lib/lib.es2015.iterable.d.ts:124
first()
first():
any
Returns
any
Defined in
forEach()
forEach(
callbackfn
,thisArg
?):void
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
• callbackfn
• thisArg?: any
Returns
void
Inherited from
Map.forEach
Defined in
docs/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get()
get(
key
):undefined
|V
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
Parameters
• key: K
Returns
undefined
| V
Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
Overrides
Map.get
Defined in
has()
has(
key
):boolean
Parameters
• key: K
Returns
boolean
boolean indicating whether an element with the specified key exists or not.
Inherited from
Map.has
Defined in
docs/node_modules/typescript/lib/lib.es2015.collection.d.ts:37
keys()
keys():
IterableIterator
<K
>
Returns an iterable of keys in the map
Returns
IterableIterator
<K
>
Inherited from
Map.keys
Defined in
docs/node_modules/typescript/lib/lib.es2015.iterable.d.ts:129
set()
set(
key
,value
):this
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
Parameters
• key: K
• value: V
Returns
this
Overrides
Map.set
Defined in
values()
values():
IterableIterator
<V
>
Returns an iterable of values in the map
Returns
IterableIterator
<V
>
Inherited from
Map.values
Defined in
docs/node_modules/typescript/lib/lib.es2015.iterable.d.ts:134