Collection

API reference for Collection in @erlcjs/core.

A collection class that extends the built-in Map class, providing additional utility methods for managing key-value pairs. K - The type of keys in the collection. V - The type of values in the collection.

Signature:

declare class Collection<K, V> extends Map<K, V>

Extends: Map<K, V>

#Methods

Method

Modifiers

Description

at(index)

Returns the value at the given index (supports negative indices from the end), or undefined if out of bounds.

every(predicate)

Returns whether every value in the collection satisfies the predicate.

filter(predicate)

Filters the collection based on a provided predicate function, returning a new collection containing only the entries that satisfy the predicate.

find(predicate)

Retrieves the first value in the collection that satisfies the provided predicate function.

findKey(predicate)

Returns the first key in the collection whose value satisfies the predicate.

first()

Returns the first value in the collection, or undefined if the collection is empty.

last()

Returns the last value in the collection, or undefined if the collection is empty.

some(predicate)

Returns whether any value in the collection satisfies the predicate.