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

Method instanceMethodOf

ark/aot/graph.ts:6025–6050  ·  view source on GitHub ↗
(
		callee: Node,
		module: SourceModule
	)

Source from the content-addressed store, hash-verified

6023
6024 // e.g. `store.add` given `const store = new Store()`
6025 private instanceMethodOf(
6026 callee: Node,
6027 module: SourceModule
6028 ): [FunctionNode, SourceModule] | undefined {
6029 callee = unwrapChain(callee)
6030 if (callee.type !== "MemberExpression") return
6031 const name = memberNameOf(callee)
6032 const object = unwrapChain(callee.object)
6033 const binding = module.scopes.byId.get(object)?.binding
6034 const init =
6035 (
6036 binding?.kind === "const" &&
6037 binding.declaration.type === "VariableDeclarator" &&
6038 binding.declaration.init
6039 ) ?
6040 unwrapExpression(binding.declaration.init)
6041 : undefined
6042 if (
6043 typeof name !== "string" ||
6044 init?.type !== "NewExpression" ||
6045 !readsOnlyMembers(binding!)
6046 )
6047 return
6048 const cls = this.instanceClassOf(init.callee, module)
6049 return cls && methodIn(cls[0], name, cls[1])
6050 }
6051
6052 // e.g. `Store` of `class Store {}`, unless the program may change it, or
6053 // one a package exports where the build reads the whole program

Callers 1

calleeOfMethod · 0.95

Calls 7

instanceClassOfMethod · 0.95
unwrapChainFunction · 0.90
unwrapExpressionFunction · 0.90
readsOnlyMembersFunction · 0.85
methodInFunction · 0.85
memberNameOfFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected