Skip to content

uniqWith

uniqWith<A>(eq): (data) => readonly A[]

Defined in: Data/Arr.ts:345

Removes duplicate elements using a custom equality check. Preserves the order of first occurrences. Complements uniq (reference equality) and uniqBy (key extraction).

A

Equality<A>

(data) => readonly A[]

type Point = { x: number; y: number };
const eqPoint: Equality<Point> = (a, b) => a.x === b.x && a.y === b.y;

pipe(
  [{ x: 1, y: 1 }, { x: 2, y: 2 }, { x: 1, y: 1 }],
  Arr.uniqWith(eqPoint),
); // [{ x: 1, y: 1 }, { x: 2, y: 2 }]