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

Method settle

ark/aot/precompile.ts:6612–6638  ·  view source on GitHub ↗
(candidate: SiteCandidate)

Source from the content-addressed store, hash-verified

6610 }
6611
6612 private settle(candidate: SiteCandidate): boolean {
6613 const type = this.typeEndOf(candidate)
6614 if (type) {
6615 candidate.state = type
6616 candidate.fallbacks = candidate.fallbacks.filter(node =>
6617 contains(type.node, node)
6618 )
6619 this.interpreter.sitesByNode.set(type.node, type)
6620 }
6621 while (true) {
6622 const state = this.interpreter.evaluateSite(candidate.state)
6623 // reading a member a validator has makes no request
6624 if (
6625 candidate.kind === "reference" &&
6626 !state.requests.length &&
6627 !state.unavailableReads.length &&
6628 isMemberRead(state.node, candidate.root)
6629 )
6630 return false
6631 const rejection = rejectionOf(state)
6632 const fallback = rejection && this.fallbackOf(candidate, rejection)
6633 if (!fallback) return true
6634 if (fallback === candidate.root) return false
6635 candidate.state = createSiteState(fallback, state.module)
6636 this.interpreter.sitesByNode.set(fallback, candidate.state)
6637 }
6638 }
6639
6640 // e.g. `$.type("b")` in `$.type("b").assert(data)`
6641 private typeEndOf({ ends, state }: SiteCandidate): SiteState | undefined {

Callers 2

_analyzeMethod · 0.95
calledParamOfMethod · 0.95

Calls 9

typeEndOfMethod · 0.95
fallbackOfMethod · 0.95
containsFunction · 0.90
isMemberReadFunction · 0.90
rejectionOfFunction · 0.90
createSiteStateFunction · 0.90
filterMethod · 0.80
evaluateSiteMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected