Skip to main

takeWhile

takeWhile

Signature - source.ts#L2817

function takeWhile<T, S extends T>(
    shouldContinue: (value: T, index: number) => value is S,
): Operator<T, S>

Calls the shouldContinue function for each Push event of the given source. The returned source will emit an End event instead of the received Push event when the given shouldContinue function returns a falsy value.

Parameters

ParameterTypeDescription
shouldContinue
(value: T, index: number) => value is S

A function that accepts a value and an index. The takeWhile method calls this function one time for each Push event of the given source.

function takeWhile<T>(
    shouldContinue: (value: T, index: number) => unknown,
): Operator<T, T>