Array deduplication
Less than 1 minute
Array
deduplication
Modules
Types
interface Array<T> {
uniqueBy(resolver?: (item: any) => any): Array<T>;
}
interface TypedArray {
uniqueBy(resolver?: (item: any) => any): TypedArray;;
}
Entry points
core-js/proposals/array-unique
core-js(-pure)/full/array(/virtual)/unique-by
core-js/full/typed-array/unique-by
Example
[1, 2, 3, 2, 1].uniqueBy(); // [1, 2, 3]
[
{ id: 1, uid: 10000 },
{ id: 2, uid: 10000 },
{ id: 3, uid: 10001 },
].uniqueBy((it) => it.uid); // => [{ id: 1, uid: 10000 }, { id: 3, uid: 10001 }]