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

Function inv

ark/schema/shared/compile.ts:330–343  ·  view source on GitHub ↗

an expression calling node's traversal, or a referenced one's by id

(node: BaseNode | NodeId, opts?: InvokeOptions)

Source from the content-addressed store, hash-verified

328
329 /** an expression calling node's traversal, or a referenced one's by id */
330 inv(node: BaseNode | NodeId, opts?: InvokeOptions): string {
331 const arg = opts?.arg ?? this.data
332 if (typeof node === "string")
333 return `${this.refToId(node, opts)}(${arg}, ${this.ctx})`
334 const kind = opts?.kind ?? this.trav
335 if (this.trav === "Transform" && kind === "Allows" && node.allowsCtx)
336 return this.allows(node, arg)
337 const reference = this.refToId(node.id, opts)
338 if (kind === "Transform" && node.tfsById)
339 return `${this.ref(transformResolution)}(${this.ctx}, "${this.nameOf(node.id)}", ${arg}, ${reference})`
340 return this.needsCtxFor(node, kind) ?
341 `${reference}(${arg}, ${this.ctx})`
342 : `${reference}(${arg})`
343 }
344
345 // Allows adds no errors to ctx, so a predicate reading it runs in a branch
346 allows(node: BaseNode, arg: string = this.data): string {

Callers

nothing calls this directly

Calls 5

allowsMethod · 0.80
needsCtxForMethod · 0.80
refToIdMethod · 0.65
refMethod · 0.45
nameOfMethod · 0.45

Tested by

no test coverage detected