Skip to content

Commit

Permalink
fix: fix helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Klesse committed Dec 9, 2024
1 parent 18d08df commit 1935d46
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/runtime/composables/use-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ export function useHelper() {
}

function groupBy<T>(arr: T[], fn: (item: T) => any) {
return arr.reduce<Record<string, T[]>>((prev, curr) => {
const result = arr.reduce<Record<string, T[]>>((prev, curr) => {
const groupKey = fn(curr);
const group = prev[groupKey] || [];
group.push(curr);
return { ...prev, [groupKey]: group };
}, {});

// sort alphabetically
return Object.keys(result)
.sort()
.reduce<Record<string, T[]>>((prev, curr) => {
prev[curr] = result[curr];
return prev;
}, {});
}

function getDifferences(obj1: any, obj2: any): any {
Expand Down

0 comments on commit 1935d46

Please sign in to comment.