uniqBy
Import from @varavel/vdl-plugin-sdk/utils/arrays.
Returns a new array containing only the unique elements from the original array, based on the values returned by the mapper function.
When duplicates are found, the first occurrence is kept and the rest are discarded.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of elements in the array. |
U |
The type of mapped elements. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr |
readonly T[] |
The array to process. |
mapper |
(item, index, array) => U |
The function used to convert the array elements. |
Returns
T[]
A new array containing only the unique elements from the original array, based on the values returned by the mapper function.