Skip to content

Collection

A collection of key-value pairs.

Extends

  • Map<T, V>

Type parameters

Type parameter
T extends string | number | symbol
V

Constructors

new Collection()

1
new Collection<T, V>(entries?: null | readonly readonly [T, V][]): Collection<T, V>

Creates a new collection.

Parameters

ParameterTypeDescription
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

PropertyModifierTypeDescriptionInherited from
[toStringTag]readonlystring-Map.[toStringTag]
sizereadonlynumberMap.size
[species]readonlyMapConstructor-Map.[species]

Methods

[iterator]()

1
iterator: 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.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:119


clear()

1
clear(): void

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()

1
delete(key: T): boolean

Parameters

ParameterType
keyT

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()

1
entries(): 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.5.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts:124


every()

1
every(fn: (value: V, key: T, collection: this) => boolean): boolean

Checks if every value satisfies the condition.

Parameters

ParameterTypeDescription
fn(value: V, key: T, collection: this) => booleanThe function to execute.

Returns

boolean

Whether every value satisfies the condition.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:76


filter()

1
filter(fn: (value: V, key: T, collection: this) => boolean): Collection<T, V>

Filters the collection by a condition.

Parameters

ParameterTypeDescription
fn(value: V, key: T, collection: this) => booleanThe function to execute.

Returns

Collection<T, V>

The filtered collection.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:34


find()

1
find(fn: (value: V, key: T, collection: this) => boolean): undefined | V

Finds the first value that satisfies the condition.

Parameters

ParameterTypeDescription
fn(value: V, key: T, collection: this) => booleanThe function to execute.

Returns

undefined | V

Returns the value if found, otherwise undefined.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:20


first()

1
first(): undefined | V

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()

1
forEach(callbackfn: (value: V, key: T, map: Map<T, V>) => void, thisArg?: any): void

Executes a provided function once per each key/value pair in the Map, in insertion order.

Parameters

ParameterType
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()

1
get(key: T): 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

ParameterType
keyT

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()

1
has(key: T): boolean

Parameters

ParameterType
keyT

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()

1
keys(): IterableIterator<T>

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()

1
map<T2>(fn: (value: V, key: T, collection: this) => T2): Collection<T, T2>

Maps the collection.

Type parameters

Type parameter
T2

Parameters

ParameterTypeDescription
fn(value: V, key: T, collection: this) => T2The function to execute.

Returns

Collection<T, T2>

The mapped collection.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:49


reduce()

1
reduce<T2>(fn: (accumulator: T2, value: V, key: T, collection: this) => T2, initial: T2): T2

Reduces the collection to a single value.

Type parameters

Type parameter
T2

Parameters

ParameterTypeDescription
fn(accumulator: T2, value: V, key: T, collection: this) => T2The function to execute.
initialT2The initial value.

Returns

T2

The reduced value.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:91


set()

1
set(key: T, value: V): this

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

ParameterType
keyT
valueV

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()

1
some(fn: (value: V, key: T, collection: this) => boolean): boolean

Checks if any value satisfies the condition.

Parameters

ParameterTypeDescription
fn(value: V, key: T, collection: this) => booleanThe function to execute.

Returns

boolean

Whether any value satisfies the condition.

Source

twitchfy/packages/chatbot/src/structures/Collection.ts:62


toArray()

1
toArray(): 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()

1
values(): IterableIterator<V>

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()

1
static 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

ParameterTypeDescription
itemsIterable<T>An iterable.
keySelector(item: T, index: number) => KA 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