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

Function passThroughDirs

src/ui-server/api/map.ts:241–260  ·  view source on GitHub ↗
(paths: Iterable<string>)

Source from the content-addressed store, hash-verified

239 * change when the reader toggles tests. The repository root is never one.
240 */
241export function passThroughDirs(paths: Iterable<string>): Set<string> {
242 const children = new Map<string, Set<string>>();
243 const holdsFiles = new Set<string>();
244 for (const raw of paths) {
245 const parts = toPosixPath(raw).split('/').filter(Boolean);
246 let dir = '';
247 for (let i = 0; i < parts.length - 1; i++) {
248 let kids = children.get(dir);
249 if (!kids) children.set(dir, (kids = new Set()));
250 kids.add(parts[i]!);
251 dir = dir ? `${dir}/${parts[i]}` : parts[i]!;
252 }
253 holdsFiles.add(dir);
254 }
255 const out = new Set<string>();
256 for (const [dir, kids] of children) {
257 if (dir !== '' && kids.size === 1 && !holdsFiles.has(dir)) out.add(dir);
258 }
259 return out;
260}
261
262/**
263 * Where each level of a file's directory path ends, as indexes into `dirs`: a

Callers 2

ui-map-api.test.tsFile · 0.90
buildMapFunction · 0.85

Calls 4

hasMethod · 0.80
getMethod · 0.65
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected