MCPcopy
hub / github.com/markmap/markmap / dfs

Function dfs

packages/markmap-cli/src/client/index.ts:68–79  ·  view source on GitHub ↗
(node: INode, ancestors: INode[] = [])

Source from the content-addressed store, hash-verified

66 autoExpand?: boolean;
67}) {
68 function dfs(node: INode, ancestors: INode[] = []) {
69 const [start, end] =
70 (node.payload?.lines as string)?.split(',').map((s) => +s) || [];
71 if (start >= 0 && start <= line && line < end) {
72 best = node;
73 bestAncestors = ancestors;
74 }
75 ancestors = [...ancestors, node];
76 node.children?.forEach((child) => {
77 dfs(child, ancestors);
78 });
79 }
80 let best: INode | undefined;
81 let bestAncestors: INode[] = [];
82 dfs((state.content.value as ITransformResult).root as INode);

Callers 1

findActiveNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected