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

Method readValue

ark/aot/usage.ts:572–602  ·  view source on GitHub ↗
(
		node: Node,
		runtime: RuntimeModule,
		path: readonly string[] = []
	)

Source from the content-addressed store, hash-verified

570
571 // a validator, or an object literal holding one at path, as a value
572 private readValue(
573 node: Node,
574 runtime: RuntimeModule,
575 path: readonly string[] = []
576 ): void {
577 const [operand, parent] = operatorOf(node)
578 const declaration = parent?.parent
579 if (
580 parent?.type === "VariableDeclarator" &&
581 parent.init === operand &&
582 parent.id.type === "Identifier" &&
583 declaration?.type === "VariableDeclaration" &&
584 declaration.kind === "const"
585 ) {
586 // a namespace's export is read off the namespace
587 if (
588 declaration.parent?.type === "ExportNamedDeclaration" &&
589 declaration.parent.parent?.type !== "Program"
590 ) {
591 escape(
592 `${runtime.module.positionOf(declaration)} exports a validator from a namespace`
593 )
594 }
595 return this.readBinding(
596 runtime.module.scopes.bindingsById.get(parent.id)!,
597 runtime,
598 path
599 )
600 }
601 this.read(operand, parent, runtime, path)
602 }
603
604 private readBinding(
605 binding: Binding,

Callers 2

analyzeMethod · 0.95
readMethod · 0.95

Calls 6

readBindingMethod · 0.95
readMethod · 0.95
operatorOfFunction · 0.90
positionOfMethod · 0.80
escapeFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected