method Stream.takeWhile
Stream.takeWhile(fn: (value: T) => Promisable<boolean>): Stream<T, E>

Yields successful values while the predicate returns true. Once the predicate returns false, iteration stops. Errors pass through until the stream is stopped. If the predicate throws, an error result is emitted and iteration stops.

Examples

Example 1

const belowTen = source.takeWhile((value) => value < 10);

Parameters

fn: (value: T) => Promisable<boolean>

Return Type

Stream<T, E>

Usage

import { type Stream } from ".";