Skip to content

Function: filter()

filter<T, S>(source, predicate): Sequence<S>

Same semantics as Array.prototype.filter, over a single Container. A type-guard predicate narrows the resulting element type.

T

S

Source<T>

The container to filter (nullish yields an empty sequence).

(value, index) => value is S

Keeps elements for which it returns true.

Sequence<S>

filter<T>(source, predicate): Sequence<T>

Same semantics as Array.prototype.filter, over a single Container. A type-guard predicate narrows the resulting element type.

T

Source<T>

The container to filter (nullish yields an empty sequence).

(value, index) => boolean

Keeps elements for which it returns true.

Sequence<T>