Skip to content

dependabit / utils/src / unique

Function: unique()

ts
function unique<T>(arr): T[];

Defined in: packages/utils/src/array.ts:16

Removes duplicates from an array using Set equality.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
arrT[]The array to deduplicate.

Returns

T[]

Array with unique elements, preserving insertion order.

Example

ts
unique([1, 2, 2, 3]); // [1, 2, 3]

Released under the MIT License.