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

Function nodeFacts

ark/type/deferred.ts:727–758  ·  view source on GitHub ↗
(node: BaseRoot)

Source from the content-addressed store, hash-verified

725}
726
727const nodeFacts = (node: BaseRoot): Facts | undefined => {
728 if (node.isNever() || node.topAlias) return
729 const key = `@${node.id}`
730 const domains = domainsOf(node)
731 if (node.hasAlias) return { key, domains, pure: false, cyclic: true }
732 let values: unknown[] | undefined = []
733 let units = false
734 for (const branch of node.branches) {
735 if (branch.is("unit")) {
736 units = true
737 if (typeof branch.unit !== "object") values?.push(branch.unit)
738 else values = undefined
739 } else {
740 values = undefined
741 units ||= outputsUnit(branch)
742 }
743 }
744 const { bits, ends } = nodeHolds(node)
745 // a node says nothing of where it holds a predicate or a unit
746 const narrowed = (bits & holdsNarrow) !== 0
747 return {
748 key,
749 domains,
750 pure: !node.alters,
751 values,
752 units,
753 unitsWithin: (bits & holdsUnit) !== 0,
754 narrowed,
755 narrowedWithin: narrowed,
756 ends
757 }
758}
759
760// a prop's `this`, its own at each call, whose nodes each reference what's being defined
761const thisFacts = (v: unknown): Facts | undefined =>

Callers 2

valueFactsFunction · 0.85
walkLiteralFunction · 0.85

Calls 5

domainsOfFunction · 0.85
outputsUnitFunction · 0.85
nodeHoldsFunction · 0.85
isMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected