Collection
A collection of key-value pairs.
Extends
Map
<T
,V
>
Type parameters
Type parameter |
---|
T extends string | number | symbol |
V |
Constructors
new Collection()
Creates a new collection.
Parameters
Parameter | Type | Description |
---|---|---|
entries ? | null | readonly readonly [T , V ][] | The entries to set in the collection. |
Returns
Collection
<T
, V
>
Overrides
Map<T, V>.constructor
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:11
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
[toStringTag] | readonly | string | - | Map.[toStringTag] |
size | readonly | number | Map.size | |
[species] | readonly | MapConstructor | - | Map.[species] |
Methods
[iterator]
()
Returns an iterable of entries in the map.
Returns
IterableIterator
<[T
, V
]>
Inherited from
Map.[iterator]
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
clear()
Returns
void
Inherited from
Map.clear
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:20
delete()
Parameters
Parameter | Type |
---|---|
key | T |
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
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
entries()
Returns an iterable of key, value pairs for every entry in the map.
Returns
IterableIterator
<[T
, V
]>
Inherited from
Map.entries
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:124
every()
Checks if every value satisfies the condition.
Parameters
Parameter | Type | Description |
---|---|---|
fn | (value : V , key : T , collection : this ) => boolean | The function to execute. |
Returns
boolean
Whether every value satisfies the condition.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:76
filter()
Filters the collection by a condition.
Parameters
Parameter | Type | Description |
---|---|---|
fn | (value : V , key : T , collection : this ) => boolean | The function to execute. |
Returns
Collection
<T
, V
>
The filtered collection.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:34
find()
Finds the first value that satisfies the condition.
Parameters
Parameter | Type | Description |
---|---|---|
fn | (value : V , key : T , collection : this ) => boolean | The function to execute. |
Returns
undefined
| V
Returns the value if found, otherwise undefined.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:20
first()
Returns the first value of the collection.
Returns
undefined
| V
The first value of the collection.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:103
forEach()
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
Parameter | Type |
---|---|
callbackfn | (value : V , key : T , map : Map <T , V >) => void |
thisArg ? | any |
Returns
void
Inherited from
Map.forEach
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get()
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
Parameter | Type |
---|---|
key | T |
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
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:33
has()
Parameters
Parameter | Type |
---|---|
key | T |
Returns
boolean
boolean indicating whether an element with the specified key exists or not.
Inherited from
Map.has
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:37
keys()
Returns an iterable of keys in the map
Returns
IterableIterator
<T
>
Inherited from
Map.keys
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:129
map()
Maps the collection.
Type parameters
Type parameter |
---|
T2 |
Parameters
Parameter | Type | Description |
---|---|---|
fn | (value : V , key : T , collection : this ) => T2 | The function to execute. |
Returns
Collection
<T
, T2
>
The mapped collection.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:49
reduce()
Reduces the collection to a single value.
Type parameters
Type parameter |
---|
T2 |
Parameters
Parameter | Type | Description |
---|---|---|
fn | (accumulator : T2 , value : V , key : T , collection : this ) => T2 | The function to execute. |
initial | T2 | The initial value. |
Returns
T2
The reduced value.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:91
set()
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
Parameter | Type |
---|---|
key | T |
value | V |
Returns
this
Inherited from
Map.set
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.collection.d.ts:41
some()
Checks if any value satisfies the condition.
Parameters
Parameter | Type | Description |
---|---|---|
fn | (value : V , key : T , collection : this ) => boolean | The function to execute. |
Returns
boolean
Whether any value satisfies the condition.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:62
toArray()
Transform the collection into an array containing the values of it.
Returns
V
[]
The array containing the values of the collection.
Source
twitchfy/packages/chatbot/src/structures/Collection.ts:111
values()
Returns an iterable of values in the map
Returns
IterableIterator
<V
>
Inherited from
Map.values
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:134
groupBy()
Groups members of an iterable according to the return value of the passed callback.
Type parameters
Type parameter |
---|
K |
T |
Parameters
Parameter | Type | Description |
---|---|---|
items | Iterable <T > | An iterable. |
keySelector | (item : T , index : number ) => K | A callback which will be invoked for each item in items. |
Returns
Map
<K
, T
[]>
Inherited from
Map.groupBy
Source
node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/lib.esnext.collection.d.ts:25