Class

Collection

Extended Map with utility methods for key-value collections.

Extends Map

Constructor

new Collection()

Methods

clone(): Collection<, >
concat(collections: ReadonlyCollection<, >[]): Collection<, >
ParamTypeDescription
collectionsReadonlyCollection<, >[]
each(fn: (value: , key: , collection: this) => void): this

Iterate without allocating; returns `this` for chaining.

ParamTypeDescription
fn(value: , key: , collection: this) => void
every(fn: (value: , key: ) => boolean): boolean
ParamTypeDescription
fn(value: , key: ) => boolean
filter(fn: (value: , key: ) => boolean): Collection<, >
ParamTypeDescription
fn(value: , key: ) => boolean
find(fn: (value: , key: ) => boolean): | undefined
ParamTypeDescription
fn(value: , key: ) => boolean
findKey(fn: (value: , key: ) => boolean): | undefined
ParamTypeDescription
fn(value: , key: ) => boolean
first(): | undefined

First value, or the first `amount` values.

first(amount: number): []
ParamTypeDescription
amountnumber
first(amount?: number): | [] | undefined
ParamTypeDescription
amount?number
last(): | undefined

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

last(amount: number): []
ParamTypeDescription
amountnumber
last(amount?: number): | [] | undefined
ParamTypeDescription
amount?number
map(fn: (value: , key: ) => ): []
ParamTypeDescription
fn(value: , key: ) =>
partition(fn: (value: , key: ) => boolean): [Collection<, >, Collection<, >]
ParamTypeDescription
fn(value: , key: ) => boolean
random(): | undefined

One random value, or `amount` unique random values.

random(amount: number): []
ParamTypeDescription
amountnumber
random(amount?: number): | [] | undefined
ParamTypeDescription
amount?number
reduce(fn: (acc: , value: , key: ) => , initialValue: ):
ParamTypeDescription
fn(acc: , value: , key: ) =>
initialValueT
some(fn: (value: , key: ) => boolean): boolean
ParamTypeDescription
fn(value: , key: ) => boolean
sort(compareFn?: (a: , b: , aKey: , bKey: ) => number): this
ParamTypeDescription
compareFn?(a: , b: , aKey: , bKey: ) => number
tap(fn: (collection: this) => void): this
ParamTypeDescription
fn(collection: this) => void
toJSON(): []
toString(): string