refactor: optimize bundle size

This commit is contained in:
2023-12-05 12:58:17 +00:00
parent 6905fb63fd
commit 13edd58987
21 changed files with 501 additions and 293 deletions

View File

@ -68,3 +68,13 @@ export function getEventFromLocationState(state: unknown | undefined | null) {
? (state as NostrEvent)
: undefined;
}
export function uniqBy<T>(vals: Array<T>, key: (x: T) => string) {
return Object.values(
vals.reduce((acc, v) => {
const k = key(v);
acc[k] ??= v;
return acc;
}, {} as Record<string, T>)
);
}