Class
Collection
Extended Map with utility methods for key-value collections.
Extends Map
Constructor
new Collection
()Methods
clone
(): Collection<, >concat
(collections: ReadonlyCollection<, >[]): Collection<, >| Param | Type | Description |
|---|---|---|
| collections | ReadonlyCollection<, >[] |
each
(fn: (value: , key: , collection: this) => void): thisIterate without allocating; returns `this` for chaining.
| Param | Type | Description |
|---|---|---|
| fn | (value: , key: , collection: this) => void |
every
(fn: (value: , key: ) => boolean): boolean| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
filter
(fn: (value: , key: ) => boolean): Collection<, >| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
find
(fn: (value: , key: ) => boolean): | undefined| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
findKey
(fn: (value: , key: ) => boolean): | undefined| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
first
(): | undefinedFirst value, or the first `amount` values.
first
(amount: number): []| Param | Type | Description |
|---|---|---|
| amount | number |
first
(amount?: number): | [] | undefined| Param | Type | Description |
|---|---|---|
| amount? | number |
last
(): | undefinedLast value, or the last `amount` values (no full-array alloc for a single item).
last
(amount: number): []| Param | Type | Description |
|---|---|---|
| amount | number |
last
(amount?: number): | [] | undefined| Param | Type | Description |
|---|---|---|
| amount? | number |
map
(fn: (value: , key: ) => ): []| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => |
partition
(fn: (value: , key: ) => boolean): [Collection<, >, Collection<, >]| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
random
(): | undefinedOne random value, or `amount` unique random values.
random
(amount: number): []| Param | Type | Description |
|---|---|---|
| amount | number |
random
(amount?: number): | [] | undefined| Param | Type | Description |
|---|---|---|
| amount? | number |
reduce
(fn: (acc: , value: , key: ) => , initialValue: ): | Param | Type | Description |
|---|---|---|
| fn | (acc: , value: , key: ) => | |
| initialValue | T |
some
(fn: (value: , key: ) => boolean): boolean| Param | Type | Description |
|---|---|---|
| fn | (value: , key: ) => boolean |
sort
(compareFn?: (a: , b: , aKey: , bKey: ) => number): this| Param | Type | Description |
|---|---|---|
| compareFn? | (a: , b: , aKey: , bKey: ) => number |
tap
(fn: (collection: this) => void): this| Param | Type | Description |
|---|---|---|
| fn | (collection: this) => void |
toJSON
(): []toString
(): string