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