unionBy es-toolkit
Creates a new array containing unique elements from two arrays based on values transformed by a specific function.
Usage
unionBy(arr1, arr2, mapper)
Use unionBy when you want to remove duplicates based on a specific property from object arrays. Elements are treated as identical if the values returned by the mapper function are the same.
You can also get unions by complex criteria using custom comparison functions.
Parameters
The first array to merge.
The second array to merge.
A function that transforms each element into a value for comparison.
Returns
Returns the union of the two arrays with duplicates removed based on values returned by the mapper function.
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.