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

xorWith (Functional Programming) es-toolkit

Creates a function that returns the symmetric difference using a custom equality function. Use it with pipe.

const result = pipe(array, xorWith(secondArray, areItemsEqual));
Info

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

Usage

xorWith returns values that are not matched across the two arrays according to areItemsEqual.

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

pipe(
  [{ id: 1 }, { id: 2 }],
  xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id)
); // => [{ id: 1 }, { id: 3 }]

Parameters

secondArrayreadonly T[]required

The array to compare with the piped array.

areItemsEqual(item: T, other: T) => booleanrequired

The function that decides whether two values are equal.

Returns

A function that maps a readonly T[] to the symmetric difference by custom equality.

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