MCPcopy Create free account
hub / github.com/arktypeio/arktype / referencesThroughAliases

Function referencesThroughAliases

ark/schema/node.ts:1907–1921  ·  view source on GitHub ↗
(
	references: readonly BaseNode[]
)

Source from the content-addressed store, hash-verified

1905
1906// every alias a node reaches resolves before it's compiled
1907export const referencesThroughAliases = (
1908 references: readonly BaseNode[]
1909): BaseNode[] => {
1910 // keyed by id, as a node bound to another scope keeps its id
1911 const reached = new Map<string, BaseNode>(
1912 references.map(reference => [reference.id, reference])
1913 )
1914 for (const reference of reached.values()) {
1915 if (!reference.is("alias")) continue
1916 const resolved = reference.resolution.byId
1917 for (const id in resolved)
1918 if (!reached.has(id)) reached.set(id, resolved[id])
1919 }
1920 return [...reached.values()]
1921}
1922
1923// in the order of `byId`, leaving out each union's cases, which hold nothing its
1924// branches don't, so reading what's reached doesn't discriminate

Callers 5

includeFunction · 0.90
referencesFunction · 0.90
jitFunction · 0.90
trackedIdFunction · 0.85
node.tsFile · 0.85

Calls 4

isMethod · 0.80
mapMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected