Files
2025-11-28 19:45:44 -07:00

14 lines
300 B
JavaScript

function uniqBy(arr, mapper) {
const map = new Map();
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = mapper(item);
if (!map.has(key)) {
map.set(key, item);
}
}
return Array.from(map.values());
}
export { uniqBy };