Collection
@discordeno/bot • Docs
Documentation / @discordeno/bot / Collection
Class: Collection<K, V>
Extends
Map
<K
,V
>
Type Parameters
• K
• V
Constructors
new Collection()
new Collection<
K
,V
>(entries
?,options
?):Collection
<K
,V
>
Parameters
• entries?: null
| Map
<K
, V
> | readonly readonly [K
, V
][]
• options?: CollectionOptions
<K
, V
>
Returns
Collection
<K
, V
>
Overrides
Map<K, V>.constructor
Defined in
packages/utils/dist/types/Collection.d.ts:13
Properties
[toStringTag]
readonly
[toStringTag]:string
Inherited from
Map.[toStringTag]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137
maxSize
maxSize:
undefined
|number
The maximum amount of items allowed in this collection. To disable cache, set it 0, set to undefined to make it infinite.
Default
undefined
Defined in
packages/utils/dist/types/Collection.d.ts:8
size
readonly
size:number
Returns
the number of elements in the Map.
Inherited from
Map.size
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:45
sweeper
sweeper:
undefined
|CollectionSweeper
<K
,V
> &object
Handler to remove items from the collection every so often.
Defined in
packages/utils/dist/types/Collection.d.ts:10
[species]
readonly
static
[species]:MapConstructor
Inherited from
Map.[species]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319
Methods
[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
array()
array():
V
[]
Convert the collection to an array.
Returns
V
[]
Defined in
packages/utils/dist/types/Collection.d.ts:23
changeSweeperFilter()
changeSweeperFilter(
newFilter
):void
Parameters
• newFilter
Returns
void
Defined in
packages/utils/dist/types/Collection.d.ts:17
changeSweeperInterval()
changeSweeperInterval(
newInterval
):void
Parameters
• newInterval: number
Returns
void
Defined in
packages/utils/dist/types/Collection.d.ts:16
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
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
every()
every(
callback
):boolean
Check if all of the items in the collection matches the pattern.
Parameters
• callback
Returns
boolean
Defined in
packages/utils/dist/types/Collection.d.ts:39
filter()
filter(
callback
):Collection
<K
,V
>
Find all elements in this collection that match the given pattern.
Parameters
• callback
Returns
Collection
<K
, V
>
Defined in
packages/utils/dist/types/Collection.d.ts:33
find()
find(
callback
):undefined
|NonNullable
<V
>
Find a specific element in this collection.
Parameters
• callback
Returns
undefined
| NonNullable
<V
>
Defined in
packages/utils/dist/types/Collection.d.ts:31
first()
first():
undefined
|V
Retrieve the value of the first element in this collection.
Returns
undefined
| V
Defined in
packages/utils/dist/types/Collection.d.ts:25
forceSet()
forceSet(
key
,value
):this
Add an item to the collection, no matter what the maxSize is.
Parameters
• key: K
• value: V
Returns
this
Defined in
packages/utils/dist/types/Collection.d.ts:21
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
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.
Inherited from
Map.get
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:33
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
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
last()
last():
undefined
|V
Retrieve the value of the last element in this collection.
Returns
undefined
| V
Defined in
packages/utils/dist/types/Collection.d.ts:27
map()
map<
T
>(callback
):T
[]
Converts the collection into an array by running a callback on all items in the collection.
Type Parameters
• T
Parameters
• callback
Returns
T
[]
Defined in
packages/utils/dist/types/Collection.d.ts:35
random()
random():
undefined
|V
Retrieve the value of a random element in this collection.
Returns
undefined
| V
Defined in
packages/utils/dist/types/Collection.d.ts:29
reduce()
reduce<
T
>(callback
,initialValue
?):T
Runs a callback on all items in the collection, merging them into a single value.
Type Parameters
• T
Parameters
• callback
• initialValue?: T
Returns
T
Defined in
packages/utils/dist/types/Collection.d.ts:41
set()
set(
key
,value
):this
Add an item to the collection. Makes sure not to go above the maxSize.
Parameters
• key: K
• value: V
Returns
this
Overrides
Map.set
Defined in
packages/utils/dist/types/Collection.d.ts:19
some()
some(
callback
):boolean
Check if one of the items in the collection matches the pattern.
Parameters
• callback
Returns
boolean
Defined in
packages/utils/dist/types/Collection.d.ts:37
startSweeper()
startSweeper(
options
):Timeout
Parameters
• options: CollectionSweeper
<K
, V
>
Returns
Timeout
Defined in
packages/utils/dist/types/Collection.d.ts:14
stopSweeper()
stopSweeper():
void
Returns
void
Defined in
packages/utils/dist/types/Collection.d.ts:15
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