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

Function customFunction

test/unit-tests/expression/node/AccessorNode.test.js:528–539  ·  view source on GitHub ↗
(node, options)

Source from the content-addressed store, hash-verified

526 it('should stringify an AccessorNode with custom toString', function () {
527 // Also checks if the custom functions get passed on to the children
528 const customFunction = function (node, options) {
529 if (node.type === 'AccessorNode') {
530 let string = node.object.toString(options) + ' at '
531 node.index.dimensions.forEach(function (range) {
532 string += range.toString(options) + ', '
533 })
534
535 return string
536 } else if (node.type === 'ConstantNode') {
537 return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')'
538 }
539 }
540
541 const a = new SymbolNode('a')
542 const b = new ConstantNode(1)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…