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

Method map

src/expression/node/FunctionNode.js:325–332  ·  view source on GitHub ↗

* Create a new FunctionNode whose children are the results of calling * the provided callback function for each child of the original node. * @param {function(child: Node, path: string, parent: Node): Node} callback * @returns {FunctionNode} Returns a transformed copy of the node

(callback)

Source from the content-addressed store, hash-verified

323 * @returns {FunctionNode} Returns a transformed copy of the node
324 */
325 map (callback) {
326 const fn = this._ifNode(callback(this.fn, 'fn', this))
327 const args = []
328 for (let i = 0; i < this.args.length; i++) {
329 args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this))
330 }
331 return new FunctionNode(fn, args)
332 }
333
334 /**
335 * Create a clone of this node, a shallow copy

Callers

nothing calls this directly

Calls 2

_ifNodeMethod · 0.80
callbackFunction · 0.50

Tested by

no test coverage detected