mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
8 lines
274 B
TypeScript
8 lines
274 B
TypeScript
export const unique = <T extends string | number>(items: T[]): T[] =>
|
|
Array.from(new Set(items));
|
|
|
|
export const uniqueByKey = <T extends Record<string, unknown>>(
|
|
items: T[],
|
|
key: keyof T,
|
|
): T[] => [...new Map(items.map((item) => [item[key], item])).values()];
|