Skip to content

Commit

Permalink
feat(lib): add isRegrouped function to validate regroup values agains…
Browse files Browse the repository at this point in the history
…t children
  • Loading branch information
narekhovhannisyan committed Jan 10, 2025
1 parent 8854b66 commit 9f3273d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/if-run/lib/regroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,20 @@ export const Regroup = (

return acc.children;
};

/**
* Grabs all the values according to grouping criteria, then
* checks if regroup values are present in the children list.
*/
export const isRegrouped = (
groups: string[],
outputStorage: PluginParams[],
childNames: Set<string>
) => {
const validatedGroups = validateGroups(groups);
const regroupValues = validatedGroups
.map(group => [...new Set(outputStorage.map(output => output[group]))])
.flat();

return regroupValues.every(one => [...childNames].includes(one));
};

0 comments on commit 9f3273d

Please sign in to comment.