method StreamClass.prototype.takeWhile
Private
StreamClass.prototype.takeWhile(predicate: (
value: T,
index: number
) => boolean
): StreamClass<T, E>

Ends the stream at the first value predicate refuses. Failures inside the window pass through and are never tested — the predicate speaks about values only.

await Stream.from([1, 2, 9, 1]).takeWhile((n) => n < 5).collect(); // [1, 2]

Parameters

predicate: (
value: T,
index: number
) => boolean

Return Type

Usage

import { StreamClass } from "lib/stream/stream.ts";