Skip to content

Commit dac9c17

Browse files
refactor(lib): use isRegrouped validation logic in computeNode function
1 parent 9f3273d commit dac9c17

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/if-run/lib/compute.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {PluginParams} from '@grnsft/if-core/types';
22

3-
import {Regroup} from './regroup';
3+
import {isRegrouped, Regroup} from './regroup';
44
import {addExplainData} from './explain';
55

66
import {debugLogger} from '../../common/util/debug-logger';
@@ -23,7 +23,7 @@ const {
2323
SKIPPING_REGROUP,
2424
} = STRINGS;
2525

26-
const childNames = new Set();
26+
const childNames = new Set<string>();
2727

2828
/**
2929
* Traverses all child nodes based on children grouping.
@@ -147,16 +147,7 @@ const computeNode = async (node: Node, params: ComputeParams): Promise<any> => {
147147
if ((noFlags || params.regroup) && pipelineCopy.regroup) {
148148
const originalOutputs = params.append ? node.outputs || [] : [];
149149

150-
// Grabs all the values according to grouping criteria.
151-
const regroupValues = pipelineCopy.regroup
152-
.map(group => [...new Set(outputStorage.map(output => output[group]))])
153-
.flat();
154-
// Checks if regroup values are present in the children list.
155-
const isRegrouped = regroupValues.every(one =>
156-
[...childNames].includes(one)
157-
);
158-
159-
if (!isRegrouped) {
150+
if (!isRegrouped(pipelineCopy.regroup, outputStorage, childNames)) {
160151
node.children = Regroup(
161152
outputStorage,
162153
originalOutputs,

0 commit comments

Comments
 (0)