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

Function callsBefore

ark/aot/flat.ts:1880–1892  ·  view source on GitHub ↗
(statement: Node, read: Node, code: string)

Source from the content-addressed store, hash-verified

1878
1879// whether a statement calls something impure before it reads a value there
1880const callsBefore = (statement: Node, read: Node, code: string): boolean => {
1881 let calls = false
1882 walk(statement, node => {
1883 if (
1884 (node.type === "CallExpression" || node.type === "NewExpression") &&
1885 node.end <= read.start &&
1886 !isPureExpression(node, code)
1887 )
1888 calls = true
1889 return !isFunctionExpression(node)
1890 })
1891 return calls
1892}
1893
1894// the last statement's span takes in the `;` and return the pass appends
1895const statementEndIn = (body: string, statement: Node): number =>

Callers 1

writtenWhereReadFunction · 0.85

Calls 3

walkFunction · 0.90
isPureExpressionFunction · 0.85
isFunctionExpressionFunction · 0.85

Tested by

no test coverage detected