diff options
| author | Joe Carstairs <me@joeac.net> | 2024-10-22 07:46:43 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-10-22 07:46:43 +0100 |
| commit | 5824c353f978a5b9ab9696451ee3014c6a614ffc (patch) | |
| tree | bc39754ca417e84eb00b0aa9a1ae2330da0bf282 /gui/src/util | |
| parent | 7adaace61a4fe983eba5ded3aaaf624ce6fb9014 (diff) | |
Refactors importer to use core stuff
Diffstat (limited to 'gui/src/util')
| -rw-r--r-- | gui/src/util/groupCategories.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gui/src/util/groupCategories.ts b/gui/src/util/groupCategories.ts new file mode 100644 index 0000000..a0336ea --- /dev/null +++ b/gui/src/util/groupCategories.ts @@ -0,0 +1,12 @@ +import { Category } from "../types/category"; +import { Group } from "../types/group"; + +export function* groupCategories(categories: Category[]): Generator<Group> { + const groupNames = new Set(categories.map(c => c.groupName)); + for (const name of groupNames) { + yield { + name, + categories: categories.filter(c => c.groupName === name) + }; + } +} |
