Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / filter

Function: filter() ​

Call Signature ​

filter<T>(predicateOrValue): Operator<T, T>

Defined in: projects/libraries/streamix/src/lib/operators/filter.ts:21

Creates a stream operator that filters values emitted by the source stream.

This operator provides flexible filtering capabilities. It processes each value from the source stream and passes it through to the output stream only if it meets a specific criterion.

The filtering can be configured in one of three ways:

  • A predicate function: A function that returns true for values to be included.
  • A single value: Only values that are strictly equal (===) to this value are included.
  • An array of values: Only values that are present in this array are included.

Values that do not pass the filter are simply not emitted downstream.

Type Parameters ​

T ​

T

The type of the values in the stream.

Parameters ​

predicateOrValue ​

(value, index) => MaybePromise<boolean>

The filtering criterion. Can be a predicate function, a single value, or an array of values.

Returns ​

Operator<T, T>

An Operator instance that can be used in a stream's pipe method.

Call Signature ​

filter<T>(predicateOrValue): Operator<T, T>

Defined in: projects/libraries/streamix/src/lib/operators/filter.ts:24

Creates a stream operator that filters values emitted by the source stream.

This operator provides flexible filtering capabilities. It processes each value from the source stream and passes it through to the output stream only if it meets a specific criterion.

The filtering can be configured in one of three ways:

  • A predicate function: A function that returns true for values to be included.
  • A single value: Only values that are strictly equal (===) to this value are included.
  • An array of values: Only values that are present in this array are included.

Values that do not pass the filter are simply not emitted downstream.

Type Parameters ​

T ​

T

The type of the values in the stream.

Parameters ​

predicateOrValue ​

readonly T[]

The filtering criterion. Can be a predicate function, a single value, or an array of values.

Returns ​

Operator<T, T>

An Operator instance that can be used in a stream's pipe method.

Call Signature ​

filter<T>(predicateOrValue): Operator<T, T>

Defined in: projects/libraries/streamix/src/lib/operators/filter.ts:25

Creates a stream operator that filters values emitted by the source stream.

This operator provides flexible filtering capabilities. It processes each value from the source stream and passes it through to the output stream only if it meets a specific criterion.

The filtering can be configured in one of three ways:

  • A predicate function: A function that returns true for values to be included.
  • A single value: Only values that are strictly equal (===) to this value are included.
  • An array of values: Only values that are present in this array are included.

Values that do not pass the filter are simply not emitted downstream.

Type Parameters ​

T ​

T

The type of the values in the stream.

Parameters ​

predicateOrValue ​

T

The filtering criterion. Can be a predicate function, a single value, or an array of values.

Returns ​

Operator<T, T>

An Operator instance that can be used in a stream's pipe method.

Released under the MIT License.