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

Function composePath

src/resolution/frameworks/tanstack-router.ts:240–256  ·  view source on GitHub ↗

The address a code-based route sits at, following `getParentRoute` up.

(
  name: string,
  decls: Map<string, { path: string | null; parent: string | null }>
)

Source from the content-addressed store, hash-verified

238
239/** The address a code-based route sits at, following `getParentRoute` up. */
240function composePath(
241 name: string,
242 decls: Map<string, { path: string | null; parent: string | null }>
243): string | null {
244 const segs: string[] = [];
245 let cur: string | null = name;
246 for (let hops = 0; cur !== null && hops < 24; hops++) {
247 const decl: { path: string | null; parent: string | null } | undefined = decls.get(cur);
248 if (!decl) return null; // a parent declared in another file — not composed
249 if (decl.path !== null) {
250 const own = decl.path.split('/').filter((s) => s.length > 0);
251 segs.unshift(...own);
252 }
253 cur = decl.parent;
254 }
255 return '/' + segs.join('/');
256}
257
258/**
259 * The text of the call chain starting at `at` — `({ … })`, and any `.update({ … })`

Callers 1

parseTanstackRoutesFunction · 0.85

Calls 2

getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected