MCPcopy
hub / github.com/josdejong/mathjs / _compile

Method _compile

src/expression/node/BlockNode.js:58–78  ·  view source on GitHub ↗

* Compile a node into a JavaScript function. * This basically pre-calculates as much as possible and only leaves open * calculations which depend on a dynamic scope with variables. * @param {Object} math Math.js namespace with functions and constants. * @param {Object} argNam

(math, argNames)

Source from the content-addressed store, hash-verified

56 * evalNode(scope: Object, args: Object, context: *)
57 */
58 _compile (math, argNames) {
59 const evalBlocks = map(this.blocks, function (block) {
60 return {
61 evaluate: block.node._compile(math, argNames),
62 visible: block.visible
63 }
64 })
65
66 return function evalBlockNodes (scope, args, context) {
67 const results = []
68
69 forEach(evalBlocks, function evalBlockNode (block) {
70 const result = block.evaluate(scope, args, context)
71 if (block.visible) {
72 results.push(result)
73 }
74 })
75
76 return new ResultSet(results)
77 }
78 }
79
80 /**
81 * Execute a callback for each of the child blocks of this node

Callers

nothing calls this directly

Calls 3

mapFunction · 0.90
forEachFunction · 0.90
evaluateMethod · 0.65

Tested by

no test coverage detected