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

Function sharedPrefix

src/resolution/import-resolver.ts:1284–1292  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

1282function pickClosestJvmCandidate(candidates: Node[], fromPath: string): Node {
1283 const fromDirs = fromPath.split('/').slice(0, -1);
1284 const sharedPrefix = (p: string): number => {
1285 const d = p.split('/').slice(0, -1);
1286 let shared = 0;
1287 for (let i = 0; i < Math.min(fromDirs.length, d.length); i++) {
1288 if (fromDirs[i] === d[i]) shared++;
1289 else break;
1290 }
1291 return shared;
1292 };
1293 const isExpect = (n: Node): boolean => Array.isArray(n.decorators) && n.decorators.includes('expect');
1294 let best = candidates[0]!;
1295 let bestProx = sharedPrefix(best.filePath);

Callers 1

pickClosestJvmCandidateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected