takeWhile (Functional Programming) es-toolkit
Creates a function that takes leading values while a predicate passes. Use it with pipe.
Info
Usage
takeWhile walks the piped array from the beginning and keeps values while predicate returns true. It is lazy-capable and can stop earlier lazy operations inside pipe.
Parameters
predicate(element: T, index: number) => booleanrequired
The function that decides whether a leading value should be kept.
Returns
A function that maps a readonly T[] to the leading values that pass.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.