Skip to main

filter

filter

Signature - source.ts#L1694

function filter<T>(
    predicate: (value: T, index: number) => false,
): Operator<T, never>

Calls the predicate function for each Push event of the given source, only passing through events whose value meet the condition specified by the predicate function.

Parameters

ParameterTypeDescription
predicate
(value: T, index: number) => false

A function that accepts a value and an index. The filter method calls this function one time for each Push event of the given source. If and only if the function returns a truthy value, then the event will pass through.

function filter<T, S extends T>(
    predicate: (value: T, index: number) => value is S,
): Operator<T, S>
function filter<T>(
    predicate: (value: T, index: number) => unknown,
): Operator<T, T>