MCPcopy Create free account
hub / github.com/chakra-ui/panda / evaluateNode

Function evaluateNode

packages/extractor/src/evaluate-node.ts:14–41  ·  view source on GitHub ↗
(node: Expression, stack: Node[], ctx: BoxContext)

Source from the content-addressed store, hash-verified

12 * @see https://github.com/wessberg/ts-evaluator#setting-up-policies
13 */
14export const evaluateNode = (node: Expression, stack: Node[], ctx: BoxContext) => {
15 if (ctx.flags?.skipEvaluate) return
16 if (ctx.canEval && !ctx.canEval?.(node, stack)) return
17
18 if (cacheMap.has(node)) {
19 return cacheMap.get(node)
20 }
21
22 const result = evaluate({
23 policy: {
24 deterministic: true,
25 network: false,
26 console: false,
27 maxOps: Number.POSITIVE_INFINITY,
28 maxOpDuration: 1000,
29 io: { read: true, write: false },
30 process: { exit: false, spawnChild: false },
31 },
32 ...ctx.getEvaluateOptions?.(node, stack),
33 node: node.compilerNode as any,
34 typescript: ts as any,
35 })
36
37 const expr = result.success ? result.value : TsEvalError
38 cacheMap.set(node, expr)
39
40 return expr
41}
42
43export const safeEvaluateNode = <T>(node: Expression, stack: Node[], ctx: BoxContext) => {
44 const result = evaluateNode(node, stack, ctx)

Callers 1

safeEvaluateNodeFunction · 0.85

Calls 3

hasMethod · 0.80
getMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected