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

Function levelLabel

src/ui-server/api/map.ts:281–290  ·  view source on GitHub ↗

The first `levels` levels of `dirs`, a chain of three or more folders written `first/…/last`.

(root: string, dirs: readonly string[], ends: readonly number[])

Source from the content-addressed store, hash-verified

279
280/** The first `levels` levels of `dirs`, a chain of three or more folders written `first/…/last`. */
281function levelLabel(root: string, dirs: readonly string[], ends: readonly number[]): string {
282 const out: string[] = root ? [root] : [];
283 let from = 0;
284 for (const end of ends) {
285 const chain = dirs.slice(from, end);
286 out.push(chain.length >= 3 ? `${chain[0]}/…/${chain[chain.length - 1]}` : chain.join('/'));
287 from = end;
288 }
289 return out.join('/');
290}
291
292/**
293 * Which module a file belongs to, or `null` when it is outside the root.

Callers 1

moduleIdForFunction · 0.85

Calls 2

pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected