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

Method map

src/expression/node/ArrayNode.js:84–90  ·  view source on GitHub ↗

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

(callback)

Source from the content-addressed store, hash-verified

82 * @returns {ArrayNode} Returns a transformed copy of the node
83 */
84 map (callback) {
85 const items = []
86 for (let i = 0; i < this.items.length; i++) {
87 items[i] = this._ifNode(callback(this.items[i], 'items[' + i + ']', this))
88 }
89 return new ArrayNode(items)
90 }
91
92 /**
93 * 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