collectype

collectype v0.11.0


collectype / types/collection / PredicateFn

Type Alias: PredicateFn()<T>

PredicateFn<T> = (item) => boolean

Defined in: types/collection.ts:27

Predicate function type for filtering collections.

Type Parameters

T

T

The type of item in the collection.

Parameters

item

T

The item to test.

Returns

boolean

True if the item should be included, false otherwise.

Example

const isEven: PredicateFn<number> = n => n % 2 === 0;
[1,2,3,4].filter(isEven); // [2,4]