Array deduplication
Specification: proposal-array-unique
Modules
esnext.array.unique-by
and esnext.typed-array.unique-by
class Array {
uniqueBy(resolver?: (item: any) => any): Array<mixed>;
}
class %TypedArray% {
uniqueBy(resolver?: (item: any) => any): %TypedArray%;;
}
CommonJS entry points
core-js/proposals/array-unique
core-js(-pure)/full/array(/virtual)/unique-by
core-js/full/typed-array/unique-by
Examples
[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 }]