MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / depthOf

Function depthOf

src/ui-server/api/file.ts:231–247  ·  view source on GitHub ↗
(
  id: string,
  parentOf: Map<string, string>,
  fileNodeId: string | undefined
)

Source from the content-addressed store, hash-verified

229}
230
231function depthOf(
232 id: string,
233 parentOf: Map<string, string>,
234 fileNodeId: string | undefined
235): number {
236 let depth = 0;
237 let current = id;
238 // Bounded by the number of links so a cyclic `contains` chain — which should
239 // be impossible, but is one bad index away — cannot spin here.
240 for (let guard = 0; guard < 32; guard++) {
241 const parent = parentOf.get(current);
242 if (!parent || parent === fileNodeId) return depth;
243 depth++;
244 current = parent;
245 }
246 return depth;
247}
248
249/** Fold edges into one row per file at the far end, ordered by symbol count. */
250function groupByFile(

Callers 1

buildOutlineEntriesFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected