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

Function memberReadsOf

ark/aot/flat.ts:595–614  ·  view source on GitHub ↗
(binding: Binding)

Source from the content-addressed store, hash-verified

593
594// the member every read of a binding reads, as `.assert` or `.allows`
595const memberReadsOf = (binding: Binding): MemberReads | undefined => {
596 let name: string | undefined
597 const spans: [number, number][] = []
598 for (const { id } of binding.references) {
599 const member = id.parent
600 const read =
601 member?.type === "MemberExpression" && member.object === id ?
602 memberNameOf(member)
603 : undefined
604 if (
605 typeof read !== "string" ||
606 (name !== undefined && read !== name) ||
607 isWriteTarget(member!)
608 )
609 return
610 name = read
611 spans.push([id.end, member!.end])
612 }
613 return name === undefined ? undefined : { name, spans }
614}
615
616// oxc's minifier keeps the annotations of creations kept code reads
617const keptAnnotationsIn = (

Callers 1

creationsInFunction · 0.85

Calls 3

memberNameOfFunction · 0.90
isWriteTargetFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected