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

Method readBinding

ark/aot/usage.ts:604–645  ·  view source on GitHub ↗
(
		binding: Binding,
		runtime: RuntimeModule,
		path: readonly string[] = []
	)

Source from the content-addressed store, hash-verified

602 }
603
604 private readBinding(
605 binding: Binding,
606 runtime: RuntimeModule,
607 path: readonly string[] = []
608 ): void {
609 const paths = this.readBindings.get(binding)
610 const key = path.join(".")
611 if (paths?.has(key)) return
612 if (paths) paths.add(key)
613 else this.readBindings.set(binding, new Set([key]))
614 const { module } = runtime
615 const write =
616 binding.writes[0] ??
617 binding.references.find(reference => reference.isWrite)?.id
618 if (write) {
619 escape(
620 `${module.positionOf(write)} assigns ${binding.name}, which holds a validator`
621 )
622 }
623 if (binding.kind !== "const" && binding.kind !== "import") {
624 escape(
625 `${module.positionOf(binding.id)} holds a validator in ${binding.name}, which isn't a const`
626 )
627 }
628 if (runtime.passed.includes(binding)) {
629 escape(
630 `${module.positionOf(binding.id)} passes ${binding.name} to a factory that checks it, which may read any member`
631 )
632 }
633 for (const reference of binding.references) {
634 if (isDead(reference.id, runtime)) continue
635 const [operand, parent] = operatorOf(reference.id)
636 // read by importers through the export
637 if (
638 parent?.type === "ExportSpecifier" ||
639 parent?.type === "ExportDefaultDeclaration"
640 )
641 continue
642 this.read(operand, parent, runtime, path)
643 }
644 for (const name of binding.exportNames) this.readExport(runtime, name, path)
645 }
646
647 private readExport(
648 runtime: RuntimeModule,

Callers 2

readValueMethod · 0.95
readExportMethod · 0.95

Calls 11

readMethod · 0.95
readExportMethod · 0.95
operatorOfFunction · 0.90
isDeadFunction · 0.85
findMethod · 0.80
positionOfMethod · 0.80
escapeFunction · 0.70
getMethod · 0.65
hasMethod · 0.45
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected