MCPcopy Create free account
hub / github.com/TanStack/router / getUniqueProgramIdentifier

Function getUniqueProgramIdentifier

packages/router-plugin/src/core/utils.ts:43–66  ·  view source on GitHub ↗
(
  programPath: babel.NodePath<t.Program>,
  baseName: string,
)

Source from the content-addressed store, hash-verified

41}
42
43export function getUniqueProgramIdentifier(
44 programPath: babel.NodePath<t.Program>,
45 baseName: string,
46): t.Identifier {
47 let name = baseName
48 let suffix = 2
49
50 const programScope = programPath.scope.getProgramParent()
51
52 while (
53 programScope.hasBinding(name) ||
54 programScope.hasGlobal(name) ||
55 programScope.hasReference(name)
56 ) {
57 name = `${baseName}${suffix}`
58 suffix++
59 }
60
61 // Register the name so subsequent calls within the same traversal
62 // see it and avoid collisions
63 programScope.references[name] = true
64
65 return t.identifier(name)
66}

Callers 4

onSplitRoutePropertyFunction · 0.90
onAddHmrFunction · 0.90
utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected