mirror of
https://github.com/versia-pub/server.git
synced 2025-12-07 00:48:18 +01:00
12 lines
333 B
TypeScript
12 lines
333 B
TypeScript
|
|
type ElementWithId = { id: string };
|
||
|
|
|
||
|
|
export const mergeAndDeduplicate = <T extends ElementWithId>(
|
||
|
|
...elements: T[][]
|
||
|
|
): T[] =>
|
||
|
|
elements
|
||
|
|
.reduce((acc, val) => acc.concat(val), [])
|
||
|
|
.filter(
|
||
|
|
(element, index, self) =>
|
||
|
|
index === self.findIndex((t) => t.id === element.id),
|
||
|
|
);
|