Collection
A collection of key-value pairs.
Extends
Map<T,V>
Type parameters
| Type parameter |
|---|
T extends string | number | symbol |
V |
Constructors
new Collection()
1new Collection<T, V>(entries?: null | readonly readonly [T, V][]): Collection<T, V>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]()
1iterator: IterableIterator<[T, V]>Returns an iterable of entries in the map.
Returns
IterableIterator<[T, V]>
Inherited from
Map.[iterator]
Source
node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
clear()
1clear(): voidReturns
void
Inherited from
Map.clear
Source
node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:20
delete()
1delete(key: T): booleanParameters
| 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.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
entries()
1entries(): IterableIterator<[T, V]>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.4.5/node_modules/typescript/lib/lib.es2015.iterable.d.ts:124
every()
1every(fn: (value: V, key: T, collection: this) => boolean): booleanChecks 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()
1filter(fn: (value: V, key: T, collection: this) => boolean): Collection<T, V>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()
1find(fn: (value: V, key: T, collection: this) => boolean): undefined | VFinds 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()
1first(): undefined | VReturns 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()
1forEach(callbackfn: (value: V, key: T, map: Map<T, V>) => void, thisArg?: any): voidExecutes 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.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get()
1get(key: T): undefined | VReturns 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.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:33
has()
1has(key: T): booleanParameters
| 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.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:37
keys()
1keys(): IterableIterator<T>Returns an iterable of keys in the map
Returns
IterableIterator<T>
Inherited from
Map.keys
Source
node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/lib.es2015.iterable.d.ts:129
map()
1map<T2>(fn: (value: V, key: T, collection: this) => T2): Collection<T, T2>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()
1reduce<T2>(fn: (accumulator: T2, value: V, key: T, collection: this) => T2, initial: T2): T2Reduces 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()
1set(key: T, value: V): thisAdds 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.4.5/node_modules/typescript/lib/lib.es2015.collection.d.ts:41
some()
1some(fn: (value: V, key: T, collection: this) => boolean): booleanChecks 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()
1toArray(): V[]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()
1values(): IterableIterator<V>Returns an iterable of values in the map
Returns
IterableIterator<V>
Inherited from
Map.values
Source
node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/lib.es2015.iterable.d.ts:134
groupBy()
1static groupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]>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.4.5/node_modules/typescript/lib/lib.esnext.collection.d.ts:25