MCPcopy
hub / github.com/lightningpixel/modly / nearestUpstreamWaits

Function nearestUpstreamWaits

src/areas/workflows/nodeBehaviors.ts:65–81  ·  view source on GitHub ↗
(
  nodeId:  string,
  edges:   WFEdge[],
  nodeMap: Map<string, WFNode>,
)

Source from the content-addressed store, hash-verified

63 * merges two distinct branches.
64 */
65export function nearestUpstreamWaits(
66 nodeId: string,
67 edges: WFEdge[],
68 nodeMap: Map<string, WFNode>,
69): Set<string> {
70 const result = new Set<string>()
71 const seen = new Set<string>()
72 const stack = edges.filter((e) => e.target === nodeId).map((e) => e.source)
73 while (stack.length > 0) {
74 const id = stack.pop()!
75 if (seen.has(id)) continue
76 seen.add(id)
77 if (isBranchStarter(nodeMap.get(id)?.type)) { result.add(id); continue }
78 for (const e of edges) if (e.target === id) stack.push(e.source)
79 }
80 return result
81}
82
83/**
84 * True if any forward path from `sourceId` reaches a sceneOutput node, walking

Callers 3

identifyBranchesFunction · 0.90
pushBranchSceneMeshFunction · 0.90

Calls 2

isBranchStarterFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected