refactor: remove lodash

This commit is contained in:
2024-02-27 19:15:18 +00:00
parent 3103b994a1
commit d59e0c9f36
6 changed files with 19 additions and 31 deletions

View File

@ -154,3 +154,12 @@ export function trackEvent(
});
}
}
export function groupBy<T>(val: Array<T>, selector: (a: T) => string | number): Record<string, Array<T>> {
return val.reduce((acc, v) => {
const key = selector(v);
acc[key] ??= [];
acc[key].push(v);
return acc;
}, {} as Record<string, Array<T>>)
}