For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/zip.md.

zip (Functional Programming) es-toolkit

Creates a function that groups values from arrays by index. Use it with pipe.

const result = pipe(array, zip(...arrs));
Info

Prefer the original es-toolkit zip in ordinary code. Use this fp variant when composing transformations with pipe.

Usage

zip groups the value at each index from the piped array and the configured arrays. If arrays have different lengths, missing values are undefined.

import { pipe, zip } from 'es-toolkit/fp';

pipe([1, 2], zip(['a', 'b'])); // => [[1, 'a'], [2, 'b']]

pipe([1, 2, 3], zip(['a'])); // => [[1, 'a'], [2, undefined], [3, undefined]]

Parameters

arrsArray<readonly T[]>required

The arrays to zip with the piped array.

Returns

A function that maps the piped array to grouped rows by index.

(array: readonly T[]) => T[][]
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.