@giapspzoo/uniq-by
v1.0.0
Published
Keeps only the first occurrence of each unique key in an array.
Downloads
70
Readme
@giapspzoo/uniq-by
A simple utility function to return a new array containing only the first occurrence of elements with unique values for the specified key.
Installation
npm i @giapspzoo/uniq-byExample
import uniqBy from "@giapspzoo/uniq-by";
const data = [
{ id: 1, value: "a" },
{ id: 2, value: "b" },
{ id: 3, value: "a" },
{ id: 4, value: "c" },
{ id: 5, value: "b" },
];
const result = uniqBy(data, "value");
// [
// { id: 1, value: "a" },
// { id: 2, value: "b" },
// { id: 4, value: "c" }
// ]License
MIT
