Class

Collection

Extended Map with utility methods for key-value collections.

Extends Map

Constructor

new Collection()

Properties

NameTypeDescription
cacheread-onlythis

Methods

.each(fn)

fn: (value: V, key: K, collection: this) => voidthis

Iterate without allocating; returns this for chaining.

client.users.each(fn);

.every(fn)

fn: (value: V, key: K) => booleanboolean

client.users.every(fn);

.find(fn)

fn: (value: V, key: K) => booleanV | undefined

client.users.find(fn);

.findKey(fn)

fn: (value: V, key: K) => booleanK | undefined

client.users.findKey(fn);

.first()

V | undefined

amount: numberV[]

First value, or the first amount values.

client.users.first();

.last()

V | undefined

amount: numberV[]

Last value, or the last amount values (no full-array alloc for a single item).

client.users.last();

.map(fn)

fn: (value: V, key: K) => TT[]

client.users.map(fn);

.random()

V | undefined

amount: numberV[]

One random value, or amount unique random values.

client.users.random();

.some(fn)

fn: (value: V, key: K) => booleanboolean

client.users.some(fn);

.sort(compareFn?)

compareFn?: (a: V, b: V, aKey: K, bKey: K) => numberthis

client.users.sort();

.tap(fn)

fn: (collection: this) => voidthis

client.users.tap(fn);