Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

chore: refactor getOutgoers

victorbrambati41743f1ff0d0
diff --git a/src/utils/getOutgoers.ts b/src/utils/getOutgoers.ts
index 6d861ea6..e1d58d4a 100644
--- a/src/utils/getOutgoers.ts
+++ b/src/utils/getOutgoers.ts
@@ -6,20 +6,20 @@ export const getOutgoers = (
): [NodeData[], string[]] => {
const outgoerNodes: NodeData[] = [];
const matchingNodes: string[] = [];
- const runner = (nodeId: string) => {
- const outgoerIds = edges.filter(e => e.from === nodeId).map(e => e.to);
- if (parent.includes(nodeId)) {
- const initialParentNode = nodes.find(n => n.id === nodeId);
- if (initialParentNode) outgoerNodes.push(initialParentNode);
- }
+ if (parent.includes(nodeId)) {
+ const initialParentNode = nodes.find(n => n.id === nodeId);
+ if (initialParentNode) outgoerNodes.push(initialParentNode);
+ }
+ const runner = (nodeId: string) => {
+ const outgoerIds = edges.filter(e => e.from === nodeId).map(e => e.to);
const nodeList = nodes.filter(n => {
if (parent.includes(n.id) && !matchingNodes.includes(n.id))
matchingNodes.push(n.id);
return outgoerIds.includes(n.id) && !parent.includes(n.id);
});
-
+
outgoerNodes.push(...nodeList);
nodeList.forEach(node => runner(node.id));
};