MCPcopy
hub / github.com/opentrace/opentrace / expandLevel

Function expandLevel

ui/src/components/panels/useDiscoverTree.ts:105–124  ·  view source on GitHub ↗
(
          nodes: TreeNodeData[],
          depth: number,
        )

Source from the content-addressed store, hash-verified

103 const newChildrenMap = new Map<string, TreeNodeData[]>();
104
105 async function expandLevel(
106 nodes: TreeNodeData[],
107 depth: number,
108 ): Promise<void> {
109 if (depth >= autoExpandDepth || cancelled) return;
110 const expandable = nodes.filter((n) => isExpandable(n));
111 const childResults = await Promise.all(
112 expandable.map(async (n) => {
113 const children = await dataProvider.fetchChildren(n.id, n.type);
114 return { parentId: n.id, children };
115 }),
116 );
117 if (cancelled) return;
118 for (const { parentId, children } of childResults) {
119 newChildrenMap.set(parentId, children);
120 if (children.length > 0) newExpandedIds.add(parentId);
121 }
122 const allChildren = childResults.flatMap((r) => r.children);
123 await expandLevel(allChildren, depth + 1);
124 }
125
126 await expandLevel(fetchedRoots, 0);
127 if (!cancelled) {

Callers 1

initFunction · 0.85

Calls 3

isExpandableFunction · 0.85
fetchChildrenMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected