unionBy (Functional Programming) es-toolkit
Creates a function that combines arrays by a mapped key without duplicates. Use it with pipe.
Info
Usage
unionBy compares the values returned by mapper. It keeps the first value for each mapped key from the piped array, then from secondArray.
Parameters
secondArrayreadonly T[]required
The array to combine after the piped array.
mapper(item: T) => Urequired
The function that returns the key used for uniqueness.
Returns
A function that maps a readonly T[] to a union by mapped key.
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.