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

# windowed (Functional Programming) es-toolkit

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

```typescript
const result = pipe(array, windowed(size, step, options));
```

::: info

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

:::

## Usage

`windowed` returns sub-arrays of length `size`, moving forward by `step` each time. Full-window mode is lazy-capable inside [`pipe`](https://massaman.dev/reference/fp/pipe.md).

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

pipe([1, 2, 3, 4], windowed(2)); // => [[1, 2], [2, 3], [3, 4]]

pipe([1, 2, 3, 4], windowed(2, 2)); // => [[1, 2], [3, 4]]
```

#### Parameters


sizenumberrequired

The length of each window.


stepnumber, optionalrequired

The number of positions to move between windows. Defaults to `1`.


optionsWindowedOptions, optionalrequired

Options such as whether to include partial trailing windows.

#### Returns

A function that maps a `readonly T[]` to sliding windows.

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

#### Throws

Throws an error if `size` or `step` is not a positive integer.


Source: es-toolkit

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