filter (Functional Programming) es-toolkit
Creates a function that keeps only the elements that pass a test, equivalent to Array.prototype.filter. Use it with pipe.
This helper is specific to es-toolkit/fp. Use it when you want this operation as part of a pipe pipeline.
Usage
filter keeps the elements for which predicate returns a truthy value. A type predicate narrows the element type of the result. It is lazy-capable: inside a pipe it is fused with adjacent lazy operations.
A type guard narrows the result type.
Parameters
A function called for each element; return true to keep the element. A type guard (value is S) narrows the result.
Returns
A function that maps a readonly T[] to a filtered array. With a type guard, the result is S[].
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.