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

Method constructor

src/expression/node/FunctionNode.js:98–118  ·  view source on GitHub ↗

* @constructor FunctionNode * @extends {./Node} * invoke a list with arguments on a node * @param {./Node | string} fn * Item resolving to a function on which to invoke * the arguments, typically a SymbolNode or AccessorNode * @param {./Node[]} args

(fn, args, optional)

Source from the content-addressed store, hash-verified

96 * @param {./Node[]} args
97 */
98 constructor (fn, args, optional) {
99 super()
100 if (typeof fn === 'string') {
101 fn = new SymbolNode(fn)
102 }
103
104 // validate input
105 if (!isNode(fn)) throw new TypeError('Node expected as parameter "fn"')
106 if (!Array.isArray(args) || !args.every(isNode)) {
107 throw new TypeError(
108 'Array containing Nodes expected for parameter "args"')
109 }
110 const optionalType = typeof optional
111 if (!(optionalType === 'undefined' || optionalType === 'boolean')) {
112 throw new TypeError('optional flag, if specified, must be boolean')
113 }
114
115 this.fn = fn
116 this.args = args || []
117 this.optional = !!optional
118 }
119
120 // readonly property name
121 get name () {

Callers

nothing calls this directly

Calls 1

isNodeFunction · 0.90

Tested by

no test coverage detected