Skip to content

Commit

Permalink
perf: use Set instead of Map
Browse files Browse the repository at this point in the history
  • Loading branch information
isekovanic committed Feb 13, 2025
1 parent ae1b610 commit c4f4578
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,11 @@ const get = <T>(obj: T, path: string): unknown =>
export const uniqBy = <T>(array: T[] | unknown, iteratee: ((item: T) => unknown) | keyof T): T[] => {
if (!Array.isArray(array)) return [];

const seen = new Map<unknown, boolean>();
const seen = new Set<unknown>();
return array.filter((item) => {
const key = typeof iteratee === 'function' ? iteratee(item) : get(item, iteratee as string);
if (seen.has(key)) return false;
seen.set(key, true);
seen.add(key);
return true;
});
};
Expand Down

0 comments on commit c4f4578

Please sign in to comment.