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

Function customFunction

test/unit-tests/expression/node/ConditionalNode.test.js:284–292  ·  view source on GitHub ↗
(node, options)

Source from the content-addressed store, hash-verified

282 it('should stringify a ConditionalNode with custom toString', function () {
283 // Also checks if the custom functions get passed on to the children
284 const customFunction = function (node, options) {
285 if (node.type === 'ConditionalNode') {
286 return 'if ' + node.condition.toString(options) +
287 ' then ' + node.trueExpr.toString(options) +
288 ' else ' + node.falseExpr.toString(options)
289 } else if (node.type === 'ConstantNode') {
290 return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')'
291 }
292 }
293
294 const a = new ConstantNode(1)
295 const b = new ConstantNode(2)

Callers

nothing calls this directly

Calls 4

toStringMethod · 0.65
typeOfMethod · 0.65
toHTMLMethod · 0.65
toTexMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…