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

Function mayReadThrough

ark/aot/usage.ts:1098–1115  ·  view source on GitHub ↗
(
	key: string,
	literal: Node,
	module: SourceModule,
	reads: ThisReads,
	isDirectValidator = false
)

Source from the content-addressed store, hash-verified

1096// through `this`, which no reference to the object shows: by a function that
1097// can be bound to it, as one in its own literal, or one it holds
1098export const mayReadThrough = (
1099 key: string,
1100 literal: Node,
1101 module: SourceModule,
1102 reads: ThisReads,
1103 isDirectValidator = false
1104): boolean => {
1105 const own = reads.byLiteral.get(literal)
1106 if (own && (own.any || own.keys.has(key))) return true
1107 if (!reads.escaped.any && !reads.escaped.keys.has(key)) return false
1108 if (
1109 !reads.patchesBuiltins &&
1110 literal.type === "ObjectExpression" &&
1111 receivesNoEscapedThis(literal, module, isDirectValidator ? key : undefined)
1112 )
1113 return false
1114 return true
1115}
1116
1117export const globalNameOf = (
1118 callee: Node,

Callers 2

readAtMethod · 0.90
readMethod · 0.85

Calls 3

receivesNoEscapedThisFunction · 0.85
getMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected