Constructor
new NodeRecursiveIterator(node)
An iterator to run recursively through a tree of nodes
Parameters:
Name | Type | Description |
---|---|---|
node |
- Since
- 1.26.0
- Copyright
- schukai GmbH
- License
- AGPLv3
Example
import {Node} from '@schukai/monster/source/types/node.mjs';
import {NodeRecursiveIterator} from '@schukai/monster/source/types/noderecursiveiterator.mjs';
const node = new Node('1')
// 1
// 2
// ├ 2.1
// ├ 2.2
// └ 2.3
// 3
// 4
// ├ 4.1
// └ 4.2
node.appendChild(
(new Node('2'))
.appendChild(new Node('2.1'))
.appendChild(new Node('2.2'))
.appendChild(new Node('2.3')))
.appendChild(new Node('3'))
.appendChild(new Node('4')
.appendChild(new Node('4.1'))
.appendChild(new Node('4.2')));
const iterator = new NodeRecursiveIterator(node);
const result = [];
for (const n of iterator) {
result.push(n.value);
}
// ↦ ['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']
Extends
- Base
Methods
forEach(callback) → {Monster.Types.NodeRecursiveIterator}
Parameters:
Name | Type | Description |
---|---|---|
callback | function |
Returns: