> 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.

# combinations (Functional Programming) es-toolkit

Creates a function that returns combinations of a given size. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, combinations(size));
```

::: info

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

:::

## Usage

`combinations` returns every way to choose `size` values from the piped array while preserving their original order in each combination.

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

pipe(['a', 'b', 'c'], combinations(2)); // => [['a', 'b'], ['a', 'c'], ['b', 'c']]
```

#### Parameters


sizenumberrequired

The number of values in each combination.

#### Returns

A function that maps a `readonly T[]` to an array of combinations.

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

#### Throws

Throws an error if `size` is not a non-negative integer.


Source: es-toolkit

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