MCPcopy Index your code
hub / github.com/josdejong/mathjs / _compile

Method _compile

src/expression/node/ArrayNode.js:45–65  ·  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

43 * evalNode(scope: Object, args: Object, context: *)
44 */
45 _compile (math, argNames) {
46 const evalItems = map(this.items, function (item) {
47 return item._compile(math, argNames)
48 })
49
50 const asMatrix = (math.config.matrix !== 'Array')
51 if (asMatrix) {
52 const matrix = math.matrix
53 return function evalArrayNode (scope, args, context) {
54 return matrix(map(evalItems, function (evalItem) {
55 return evalItem(scope, args, context)
56 }))
57 }
58 } else {
59 return function evalArrayNode (scope, args, context) {
60 return map(evalItems, function (evalItem) {
61 return evalItem(scope, args, context)
62 })
63 }
64 }
65 }
66
67 /**
68 * Execute a callback for each of the child nodes of this node

Callers

nothing calls this directly

Calls 1

mapFunction · 0.90

Tested by

no test coverage detected