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

Function passedReaderOf

ark/aot/usage.ts:980–992  ·  view source on GitHub ↗
(
	parse: () => Program
)

Source from the content-addressed store, hash-verified

978// how each factory a module of validators exports reads a parameter, other
979// than the index a shared factory takes first
980export const passedReaderOf = (
981 parse: () => Program
982): ((exported: string, position: number) => PassedRead) => {
983 let functionsByExport: Map<string, Node | undefined> | undefined
984 const readsByExport = new Map<string, PassedReads | undefined>()
985 return (exported, position) => {
986 functionsByExport ??= exportedFunctionsOf(parse())
987 if (!readsByExport.has(exported))
988 readsByExport.set(exported, readsOf(functionsByExport.get(exported)))
989 const reads = readsByExport.get(exported)
990 return reads ? (reads.get(position) ?? "none") : "any"
991 }
992}
993
994type PassedReads = Map<number, PassedRead>
995

Callers 1

foldSiteMethod · 0.90

Calls 6

exportedFunctionsOfFunction · 0.85
parseFunction · 0.70
readsOfFunction · 0.70
getMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected