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

Method map

src/expression/node/IndexNode.js:129–137  ·  view source on GitHub ↗

* Create a new IndexNode 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 {IndexNode} Returns a transformed copy of the node

(callback)

Source from the content-addressed store, hash-verified

127 * @returns {IndexNode} Returns a transformed copy of the node
128 */
129 map (callback) {
130 const dimensions = []
131 for (let i = 0; i < this.dimensions.length; i++) {
132 dimensions[i] = this._ifNode(
133 callback(this.dimensions[i], 'dimensions[' + i + ']', this))
134 }
135
136 return new IndexNode(dimensions, this.dotNotation)
137 }
138
139 /**
140 * 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