LendAndRegret/node_modules/es-toolkit/dist/array/uniqBy.js
2026-05-02 17:27:43 +08:00

18 lines
403 B
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
function uniqBy(arr, mapper) {
const map = new Map();
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = mapper(item, i, arr);
if (!map.has(key)) {
map.set(key, item);
}
}
return Array.from(map.values());
}
exports.uniqBy = uniqBy;