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/zipWith.md.

zipWith (Functional Programming) es-toolkit

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

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

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

Usage

zipWith passes values at the same index from the piped array and configured arrays to combine. If arrays have different lengths, missing values are passed as undefined.

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

pipe(
  [1, 2],
  zipWith([10, 20], (a, b) => a + b)
); // => [11, 22]

pipe(
  [1, 2, 3],
  zipWith([10], (a, b = 0) => a + b)
); // => [11, 2, 3]

Parameters

arrsArray<readonly unknown[]>required

The arrays to combine with the piped array.

combine(...values: unknown[]) => Rrequired

The function that receives values at the same index, followed by the index, and returns a new value.

Returns

A function that maps the piped array to combined values.

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