Skip to content

Commit 9f3273d

Browse files
feat(lib): add isRegrouped function to validate regroup values against children
1 parent 8854b66 commit 9f3273d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/if-run/lib/regroup.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,20 @@ export const Regroup = (
8686

8787
return acc.children;
8888
};
89+
90+
/**
91+
* Grabs all the values according to grouping criteria, then
92+
* checks if regroup values are present in the children list.
93+
*/
94+
export const isRegrouped = (
95+
groups: string[],
96+
outputStorage: PluginParams[],
97+
childNames: Set<string>
98+
) => {
99+
const validatedGroups = validateGroups(groups);
100+
const regroupValues = validatedGroups
101+
.map(group => [...new Set(outputStorage.map(output => output[group]))])
102+
.flat();
103+
104+
return regroupValues.every(one => [...childNames].includes(one));
105+
};

0 commit comments

Comments
 (0)