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

Function travKey

ark/schema/shared/compile.ts:485–501  ·  view source on GitHub ↗
(keyExpr: string, accessExpression: string, node: BaseNode)

Source from the content-addressed store, hash-verified

483 }
484
485 travKey(keyExpr: string, accessExpression: string, node: BaseNode): this {
486 const fails = this.keyFails(keyExpr, accessExpression, node)
487 if (fails !== undefined) return this.if(fails, () => this.return(false))
488 if (this.trav === "Apply")
489 return this.applyKey(keyExpr, accessExpression, node)
490 // read once, so the string remembered is the one its pattern rejected
491 if (this.loopDepth > 0 && isRefinedPattern(node)) {
492 const allows = this.traversal(node, "Allows")
493 return this.const("value", accessExpression).if(`!${allows}(value)`, () =>
494 this.return(`${this.ref(rejected)}(${allows}, value)`)
495 )
496 }
497 // a value whose predicates read ctx is checked at its key's path
498 this.line(`${this.ctx}.path.push(${keyExpr})`)
499 this.check(node, { arg: accessExpression })
500 return this.line(`${this.ctx}.path.pop()`)
501 }
502
503 keyFails(key: string, value: string, node: BaseNode): string | undefined {
504 if (this.trav !== "Apply") {

Callers 10

tAllowsMethod · 0.90
tApplyMethod · 0.90
tAllowsFunction · 0.90
tApplyFunction · 0.90
tAllowsMethod · 0.90
tApplyMethod · 0.90
tfElemsMethod · 0.90
_traverseMethod · 0.90
tfKeyMethod · 0.90
tfSharedKeyMethod · 0.90

Calls 8

isRefinedPatternFunction · 0.85
ifMethod · 0.80
returnMethod · 0.80
traversalMethod · 0.80
constMethod · 0.80
lineMethod · 0.80
refMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected