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

Function startsWithConstant

src/expression/node/OperatorNode.js:23–33  ·  view source on GitHub ↗

* Returns true if the expression starts with a constant, under * the current parenthesization: * @param {Node} expression * @param {string} parenthesis * @return {boolean}

(expr, parenthesis)

Source from the content-addressed store, hash-verified

21 * @return {boolean}
22 */
23 function startsWithConstant (expr, parenthesis) {
24 let curNode = expr
25 if (parenthesis === 'auto') {
26 while (isParenthesisNode(curNode)) curNode = curNode.content
27 }
28 if (isConstantNode(curNode)) return true
29 if (isOperatorNode(curNode)) {
30 return startsWithConstant(curNode.args[0], parenthesis)
31 }
32 return false
33 }
34
35 /**
36 * Calculate which parentheses are necessary. Gets an OperatorNode

Callers 1

Calls 3

isParenthesisNodeFunction · 0.90
isConstantNodeFunction · 0.90
isOperatorNodeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…