> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# compact (Functional Programming) es-toolkit

Creates a function that removes falsey values from an array. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, compact());
```

::: info

Prefer the original es-toolkit [`compact`](https://massaman.dev/reference/array/compact.md) in ordinary code. Use this `fp` variant when composing transformations with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

:::

## Usage

`compact` removes `false`, `null`, `undefined`, `0`, `-0`, `0n`, an empty string, and `NaN`. It is lazy-capable inside [`pipe`](https://massaman.dev/reference/fp/pipe.md), so a trailing `take` can stop the walk early.

```typescript
import { compact, pipe } from 'es-toolkit/fp';

pipe([0, 1, false, 2, '', 3], compact()); // => [1, 2, 3]
```

#### Parameters

This function takes no arguments; call it as `compact()`.

#### Returns

A function that maps a `readonly T[]` to an array without falsey values.

```typescript
(array: readonly T[]) => Array<NotFalsey<T>>
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/fp/reference/compact.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
