* Create a new BlockNode 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 {BlockNode} Returns a transformed copy of the node
(callback)
| 94 | * @returns {BlockNode} Returns a transformed copy of the node |
| 95 | */ |
| 96 | map (callback) { |
| 97 | const blocks = [] |
| 98 | for (let i = 0; i < this.blocks.length; i++) { |
| 99 | const block = this.blocks[i] |
| 100 | const node = this._ifNode( |
| 101 | callback(block.node, 'blocks[' + i + '].node', this)) |
| 102 | blocks[i] = { |
| 103 | node, |
| 104 | visible: block.visible |
| 105 | } |
| 106 | } |
| 107 | return new BlockNode(blocks) |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Create a clone of this node, a shallow copy |