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

Function reaches

ark/schema/structure/structure.ts:229–241  ·  view source on GitHub ↗
(node: BaseNode)

Source from the content-addressed store, hash-verified

227 const final = isResolutionFinal()
228 const reached = new Set<BaseNode>()
229 const reaches = (node: BaseNode): boolean => {
230 if (node.userCode) return true
231 if (!node.hasAlias || reached.has(node)) return false
232 if (node.c.reachesUserCode !== undefined) return node.c.reachesUserCode
233 reached.add(node)
234 const found =
235 node.is("alias") ?
236 reaches(node.resolution)
237 : node.children.some(reaches) ||
238 (!node.is("union") && node.otherRefs.some(reaches))
239 if (found && final) node.c.reachesUserCode = true
240 return found
241 }
242 if (reaches(root)) return true
243 if (final) for (const node of reached) node.c.reachesUserCode = false
244 return false

Callers 2

jsElementsMethod · 0.70
reachesUserCodeFunction · 0.70

Calls 3

isMethod · 0.80
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected