CacheMap
@twine-protocol/twine-core v0.1.0 • Docs
twine-js / @twine-protocol/twine-core / CacheMap
Class: CacheMap<K, V>
A map that caches the most recently accessed items
Extends
Map
<K
,V
>
Type Parameters
K
V
Constructors
new CacheMap()
new CacheMap<
K
,V
>(iterable
?,options
?):CacheMap
<K
,V
>
Create a new cache map
Parameters
iterable
?
Iterable
<[K
, V
], any
, any
>
An iterable of key-value pairs
options
?
Options for the cache
Returns
CacheMap
<K
, V
>
Overrides
Map<K, V>.constructor
Defined in
packages/twine-core/src/store/cache-helpers.ts:30
Properties
[species]
readonly
MapConstructor
-
Map.[species]
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319
size
readonly
number
Map.size
node_modules/typescript/lib/lib.es2015.collection.d.ts:45
[toStringTag]
readonly
string
-
Map.[toStringTag]
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137
Methods
groupBy()
static
groupBy<K
,T
>(items
,keySelector
):Map
<K
,T
[]>
Groups members of an iterable according to the return value of the passed callback.
Type Parameters
K
T
Parameters
items
Iterable
<T
, any
, any
>
An iterable.
keySelector
(item
, index
) => K
A callback which will be invoked for each item in items.
Returns
Map
<K
, T
[]>
Inherited from
Map.groupBy
Defined in
node_modules/typescript/lib/lib.esnext.collection.d.ts:25
setMaxSize()
setMaxSize(
maxSize
):void
Set the maximum number of items to keep in the cache
If the cache is already larger than the new max size, the oldest items will be removed.
Parameters
maxSize
number
Returns
void
Defined in
packages/twine-core/src/store/cache-helpers.ts:40
set()
set(
key
,value
):CacheMap
<K
,V
>
See Map.set
Parameters
key
K
value
V
Returns
CacheMap
<K
, V
>
Overrides
Map.set
Defined in
packages/twine-core/src/store/cache-helpers.ts:57
get()
get(
key
):undefined
|V
See Map.get
Parameters
key
K
Returns
undefined
| V
Overrides
Map.get
Defined in
packages/twine-core/src/store/cache-helpers.ts:66
clear()
clear():
void
Returns
void
Inherited from
Map.clear
Defined in
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
node_modules/typescript/lib/lib.es2015.collection.d.ts:24
forEach()
forEach(
callbackfn
,thisArg
?):void
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
callbackfn
(value
, key
, map
) => void
thisArg
?
any
Returns
void
Inherited from
Map.forEach
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:28
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
node_modules/typescript/lib/lib.es2015.collection.d.ts:37
entries()
entries():
MapIterator
<[K
,V
]>
Returns an iterable of key, value pairs for every entry in the map.
Returns
MapIterator
<[K
, V
]>
Inherited from
Map.entries
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:148
keys()
keys():
MapIterator
<K
>
Returns an iterable of keys in the map
Returns
MapIterator
<K
>
Inherited from
Map.keys
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:153
values()
values():
MapIterator
<V
>
Returns an iterable of values in the map
Returns
MapIterator
<V
>
Inherited from
Map.values
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:158
[iterator]()
[iterator]():
MapIterator
<[K
,V
]>
Returns an iterable of entries in the map.
Returns
MapIterator
<[K
, V
]>
Inherited from
Map.[iterator]
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:143
Last updated