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

Function runsOnceAtLoad

ark/aot/scope.ts:1011–1025  ·  view source on GitHub ↗
(call: Node)

Source from the content-addressed store, hash-verified

1009
1010// e.g. `export default configure(...)`
1011export const runsOnceAtLoad = (call: Node): boolean => {
1012 let statement = operatorOf(call)[1]
1013 if (statement?.type === "UnaryExpression" && statement.operator === "void")
1014 statement = operatorOf(statement)[1]
1015 if (statement?.type === "VariableDeclarator") statement = statement.parent
1016 if (statement?.parent?.type === "ExportNamedDeclaration")
1017 statement = statement.parent
1018 return (
1019 statement?.parent?.type === "Program" &&
1020 (statement.type === "ExpressionStatement" ||
1021 statement.type === "VariableDeclaration" ||
1022 statement.type === "ExportNamedDeclaration" ||
1023 statement.type === "ExportDefaultDeclaration")
1024 )
1025}
1026
1027// e.g. "./a.ts" for `import("./a.ts")`, `require("./a.ts")` or `import a = require("./a.ts")`
1028export const loadedSpecifierOf = (node: Node): unknown => {

Callers 1

evaluateConfigurationMethod · 0.90

Calls 1

operatorOfFunction · 0.85

Tested by

no test coverage detected