uniq
@guoba-ai/utils / array / uniq
Function: uniq()
function uniq<T>(array): T[];Defined in: array.ts:38
Remove duplicate elements from an array.
Parameters
array
T[]
The input array
Returns
T[]
A new array with duplicates removed, preserving order
Example
uniq([1, 2, 2, 3]) // [1, 2, 3]
uniq([3, 1, 3, 2]) // [3, 1, 2]
const item = { id: 1 }
uniq([item, item]) // [item]