mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(database): ♻️ Simplify User and Note logic further
This commit is contained in:
parent
a8541bdc44
commit
83399ba5f1
6 changed files with 67 additions and 107 deletions
11
utils/lib.ts
Normal file
11
utils/lib.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue