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

Function referencesWithoutCases

ark/schema/node.ts:1925–1936  ·  view source on GitHub ↗
(root: BaseNode)

Source from the content-addressed store, hash-verified

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
1925export const referencesWithoutCases = (root: BaseNode): Set<BaseNode> => {
1926 const references = new Set<BaseNode>()
1927 const include = (node: BaseNode): void => {
1928 if (references.has(node)) return
1929 references.add(node)
1930 for (let i = 0; i < node.children.length; i++) include(node.children[i])
1931 if (node.is("union")) return
1932 for (const referenced of node.otherRefs) include(referenced)
1933 }
1934 include(root)
1935 return references
1936}
1937
1938// resolves what referencesThroughAliases lists, in its order since any can throw,
1939// without listing it for a Type that may never compile. what a node reaches

Callers 4

computeReachesDefaultFunction · 0.90
operationsOfFunction · 0.90
transformsOnEncodeFunction · 0.90
reachesFunction · 0.85

Calls 1

includeFunction · 0.70

Tested by

no test coverage detected