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

Function functionsAsArrows

ark/aot/flat.ts:2185–2208  ·  view source on GitHub ↗
({ code, program }, s)

Source from the content-addressed store, hash-verified

2183const minLazyText = 12_000
2184
2185const functionsAsArrows: UnitsPass = ({ code, program }, s) => {
2186 for (const statement of program.body as Node[]) {
2187 if (statement.type !== "VariableDeclaration") continue
2188 for (const { init } of statement.declarations) {
2189 if (!init || !isPlainFunction(init)) continue
2190 let readsOwn = false
2191 walk(init, node => {
2192 if (
2193 node.type === "ThisExpression" ||
2194 (node.type === "Identifier" && node.name === "arguments")
2195 )
2196 readsOwn = true
2197 return !readsOwn
2198 })
2199 if (readsOwn) continue
2200 s.overwrite(
2201 init.start,
2202 init.body.start,
2203 `${code.slice(init.start + "function".length, init.body.start).trim()} => `
2204 )
2205 }
2206 }
2207 return true
2208}
2209
2210const applyName = /Apply(?:\$\d+)?$/
2211

Callers

nothing calls this directly

Calls 2

walkFunction · 0.90
isPlainFunctionFunction · 0.85

Tested by

no test coverage detected