collectype

collectype v0.11.0


collectype / Collection / Collection

Class: Collection<T, F>

Defined in: Collection.ts:21

Base collection implementation using a configurable functions class.

Type Parameters

T

T

The type of items in the collection.

F

F extends BaseFunctions<T> = BaseFunctions<T>

The type of the functions class, must extend BaseFunctions.

The functions class constructor must match the Constructor<F> type, i.e., it must accept an array of items as its only argument.

Example usage:

import { Collection, BaseFunctions, Constructor } from 'collectype';
const collection = new Collection<MyType, Constructor<BaseFunctions>>(items, BaseFunctions);

Implements

Constructors

Constructor

new Collection<T, F>(items, FunctionsClass): Collection<T, F>

Defined in: Collection.ts:34

Creates an instance of Collection.

Parameters

items

T[]

Array of items.

FunctionsClass

Constructor<F>

The class constructor for chainable operations, must match Constructor.

Returns

Collection<T, F>

Properties

_items

protected _items: T[]

Defined in: Collection.ts:22


_functionsClass

protected _functionsClass: Constructor<F>

Defined in: Collection.ts:27

The constructor for the functions class, typed as Constructor. This allows CollecType to instantiate the correct chainable API.

Accessors

items

Get Signature

get items(): T[]

Defined in: Collection.ts:43

Gets the array of items.

Returns

T[]

The current array of items.

Implementation of

Collectable.items


count

Get Signature

get count(): number

Defined in: Collection.ts:51

Gets the number of items.

Returns

number

The count of items.

Implementation of

Collectable.count


fn

Get Signature

get fn(): F

Defined in: Collection.ts:59

Gets a new instance of the functions class with current items for chainable operations. The type reflects the actual class passed.

Returns

F