compact (Functional Programming) es-toolkit
Creates a function that removes falsey values from an array. Use it with pipe.
Info
Usage
compact removes false, null, undefined, 0, -0, 0n, an empty string, and NaN. It is lazy-capable inside pipe, so a trailing take can stop the walk early.
Parameters
This function takes no arguments; call it as compact().
Returns
A function that maps a readonly T[] to an array without falsey values.
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.