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

Function functionOfBinding

ark/aot/graph.ts:7340–7355  ·  view source on GitHub ↗
(
	binding: Binding,
	module: SourceModule
)

Source from the content-addressed store, hash-verified

7338 !!staticBodyOf(fn) && !readsArguments(fn)
7339
7340export const functionOfBinding = (
7341 binding: Binding,
7342 module: SourceModule
7343): FunctionNode | undefined => {
7344 if (binding.writes.length) return
7345 const fn =
7346 binding.kind === "function" ? binding.declaration
7347 : (
7348 binding.kind === "const" &&
7349 binding.declaration.type === "VariableDeclarator"
7350 ) ?
7351 binding.declaration.init &&
7352 namedFunctionOf(unwrapExpression(binding.declaration.init), module)
7353 : undefined
7354 return fn && isFunctionNode(fn) ? fn : undefined
7355}
7356
7357// esbuild's keepNames: `__name(fn, "name")` returns `fn`
7358const namedFunctionOf = (node: Node, module: SourceModule): Node => {

Callers 5

quietFunctionsOfMethod · 0.90
checkHelperReadsMethod · 0.90
foldedHelpersOfMethod · 0.90
boundFunctionOfMethod · 0.85
exportedFunctionNameOfFunction · 0.85

Calls 3

unwrapExpressionFunction · 0.90
namedFunctionOfFunction · 0.85
isFunctionNodeFunction · 0.85

Tested by

no test coverage detected