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

Function customFunction

test/unit-tests/expression/node/FunctionNode.test.js:424–435  ·  view source on GitHub ↗
(node, options)

Source from the content-addressed store, hash-verified

422 it('should stringify a FunctionNode with custom toString', function () {
423 // Also checks if the custom functions get passed on to the children
424 const customFunction = function (node, options) {
425 if (node.type === 'FunctionNode') {
426 let string = '[' + node.name + ']('
427 node.args.forEach(function (arg) {
428 string += arg.toString(options) + ', '
429 })
430 string += ')'
431 return string
432 } else if (node.type === 'ConstantNode') {
433 return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')'
434 }
435 }
436
437 const a = new ConstantNode(1)
438 const b = new ConstantNode(2)

Callers

nothing calls this directly

Calls 5

forEachMethod · 0.65
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…