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

Function nodeHolds

ark/type/deferred.ts:705–725  ·  view source on GitHub ↗
(node: BaseNode)

Source from the content-addressed store, hash-verified

703// asked of what a node is made of and pipes to: its references are a union's
704// cases too, which it has once it's discriminated, when it's first used
705const nodeHolds = (node: BaseNode): NodeHeld => {
706 let held = heldByNode.get(node)
707 if (!held) {
708 held = {
709 bits:
710 node.is("unit") ? holdsUnit
711 : isNarrow(node) ? holdsNarrow
712 : 0,
713 ends: endOf(node)
714 }
715 const within =
716 node.is("morph") ? [...node.children, ...node.otherRefs] : node.children
717 for (const part of within) {
718 const { bits, ends } = nodeHolds(part)
719 held.bits |= bits
720 held.ends = joinEnds(held.ends, ends)
721 }
722 heldByNode.set(node, held)
723 }
724 return held
725}
726
727const nodeFacts = (node: BaseRoot): Facts | undefined => {
728 if (node.isNever() || node.topAlias) return

Callers 1

nodeFactsFunction · 0.85

Calls 6

isNarrowFunction · 0.85
endOfFunction · 0.85
joinEndsFunction · 0.85
isMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected