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

Function sharedPrefix

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

Source from the content-addressed store, hash-verified

2726function pickClosestJvmCandidate(candidates: Node[], fromPath: string): Node {
2727 const fromDirs = fromPath.split('/').slice(0, -1);
2728 const sharedPrefix = (p: string): number => {
2729 const d = p.split('/').slice(0, -1);
2730 let shared = 0;
2731 for (let i = 0; i < Math.min(fromDirs.length, d.length); i++) {
2732 if (fromDirs[i] === d[i]) shared++;
2733 else break;
2734 }
2735 return shared;
2736 };
2737 const isExpect = (n: Node): boolean => Array.isArray(n.decorators) && n.decorators.includes('expect');
2738 let best = candidates[0]!;
2739 let bestProx = sharedPrefix(best.filePath);

Callers 1

pickClosestJvmCandidateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected