unionBy
Import from @varavel/vdl-plugin-sdk/utils/arrays.
Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of elements in the array. |
U |
The type of mapped elements. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr1 |
readonly T[] |
The first array. |
arr2 |
readonly T[] |
The second array. |
mapper |
(item) => U |
The function to map array elements to comparison values. |
Returns
T[]
A new array containing the union of unique elements from arr1 and arr2, based on the values returned by the mapping function.