server/utils/lib.ts
2025-04-14 16:51:00 +02:00

19 lines
478 B
TypeScript

import { dirname } from "node:path";
import { main } from "bun";
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),
);
export const cwdFromEntrypoint = (): string => {
return dirname(main);
};