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

Function calledMembersOf

ark/type/standalone/units.ts:97–112  ·  view source on GitHub ↗
(
	members: readonly UnitMember[],
	readers: readonly string[]
)

Source from the content-addressed store, hash-verified

95}
96
97export const calledMembersOf = (
98 members: readonly UnitMember[],
99 readers: readonly string[]
100): UnitMember[] => {
101 const sourcesByName = new Map(members)
102 const called = new Set<string>()
103 const read = (text: string) => {
104 for (const name of text.match(/[\w$]+/g) ?? []) {
105 if (called.has(name) || !sourcesByName.has(name)) continue
106 called.add(name)
107 read(sourcesByName.get(name)!)
108 }
109 }
110 for (const reader of readers) read(reader)
111 return members.filter(([name]) => called.has(name))
112}
113
114// a traversal only calling another of its unit is that one
115export const forwardedOf = (

Callers 2

declareMembersMethod · 0.90
namesReadByFunction · 0.85

Calls 3

filterMethod · 0.80
readFunction · 0.70
hasMethod · 0.45

Tested by

no test coverage detected