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

Method write

ark/aot/readers.ts:1072–1096  ·  view source on GitHub ↗
(target: Node, module: SourceModule, held: Held)

Source from the content-addressed store, hash-verified

1070
1071 // `target = value`, where target may be a property
1072 private write(target: Node, module: SourceModule, held: Held): void {
1073 target = unwrapExpression(target)
1074 if (target.type !== "MemberExpression")
1075 return this.bindPattern(target, module, held)
1076 const owner = globalNameOf(target.object, module)
1077 if (owner && globalObjects.has(owner)) {
1078 return this.lose(
1079 target,
1080 module,
1081 "stores it on the global object, which code outside the bundle may read"
1082 )
1083 }
1084 if (isCommonJsExports(owner, memberNameOf(target)))
1085 return this.lose(target, module, "exports it from CommonJS")
1086 // `o.__proto__ = T` makes o inherit T's members, which no read of a key
1087 // shows, though `o.__proto__ = { schema: T }` holds it at a key to follow
1088 if (memberNameOf(target) === "__proto__" && !held.path.length) {
1089 return this.lose(
1090 target,
1091 module,
1092 "sets it as a prototype, which inherits its members"
1093 )
1094 }
1095 this.followField(memberNameOf(target), target, module, held)
1096 }
1097
1098 // stored at a key, which any read of it by name may read
1099 private followField(

Callers 15

readAtMethod · 0.95
bindPatternMethod · 0.95
bindLeftMethod · 0.95
builtinMethod · 0.95
renderMethod · 0.45
stopMethod · 0.45
traceFunction · 0.45
generateTraceDataFunction · 0.45
filterDurationEntriesFunction · 0.45
buildCallTreeFunction · 0.45
sortAndRankFunctionsFunction · 0.45

Calls 8

bindPatternMethod · 0.95
loseMethod · 0.95
followFieldMethod · 0.95
unwrapExpressionFunction · 0.90
globalNameOfFunction · 0.90
memberNameOfFunction · 0.90
isCommonJsExportsFunction · 0.70
hasMethod · 0.45

Tested by 3

ownFilesOfFunction · 0.36
sendFunction · 0.36
sideFunction · 0.36