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

Method readNamespace

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

Source from the content-addressed store, hash-verified

695
696 // `ns.T` reads the export, and nothing else may read the namespace
697 private readNamespace(
698 binding: Binding,
699 runtime: RuntimeModule,
700 name: string,
701 path: readonly string[]
702 ): void {
703 const { module } = runtime
704 const wholeRead = `reads the namespace ${binding.name}, which holds ${name}, whole`
705 if (binding.exportNames.length || runtime.passed.includes(binding))
706 escape(`${module.positionOf(binding.id)} ${wholeRead}`)
707 for (const reference of binding.references) {
708 if (isDead(reference.id, runtime)) continue
709 const [operand, parent] = operatorOf(reference.id)
710 if (
711 parent?.type !== "MemberExpression" ||
712 parent.object !== operand ||
713 isWriteTarget(parent)
714 )
715 return escape(`${module.positionOf(reference.id)} ${wholeRead}`)
716 const read = memberNameOf(parent)
717 if (typeof read !== "string") {
718 return escape(
719 `${module.positionOf(reference.id)} reads the namespace ${binding.name}, which holds ${name}, at a computed key`
720 )
721 }
722 if (read !== name) continue
723 const [member, memberParent] = operatorOf(parent)
724 this.read(member, memberParent, runtime, path)
725 }
726 }
727
728 // a read of a validator, or of an object holding one at path, e.g.
729 // `schemas.user(data)` where `const schemas = { user: User }`

Callers 1

readExportMethod · 0.95

Calls 7

readMethod · 0.95
operatorOfFunction · 0.90
isWriteTargetFunction · 0.90
memberNameOfFunction · 0.90
isDeadFunction · 0.85
positionOfMethod · 0.80
escapeFunction · 0.70

Tested by

no test coverage detected