| 137549 | var _iteratorJs = require("./iterator.js"); |
| 137550 | var _iteratorJsDefault = parcelHelpers.interopDefault(_iteratorJs); |
| 137551 | function hierarchy(data, children) { |
| 137552 | if (data instanceof Map) { |
| 137553 | data = [ |
| 137554 | undefined, |
| 137555 | data |
| 137556 | ]; |
| 137557 | if (children === undefined) children = mapChildren; |
| 137558 | } else if (children === undefined) children = objectChildren; |
| 137559 | var root = new Node(data), node, nodes = [ |
| 137560 | root |
| 137561 | ], child, childs, i, n; |
| 137562 | while(node = nodes.pop())if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) { |
| 137563 | node.children = childs; |
| 137564 | for(i = n - 1; i >= 0; --i){ |
| 137565 | nodes.push(child = childs[i] = new Node(childs[i])); |
| 137566 | child.parent = node; |
| 137567 | child.depth = node.depth + 1; |
| 137568 | } |
| 137569 | } |
| 137570 | return root.eachBefore(computeHeight); |
| 137571 | } |
| 137572 | exports.default = hierarchy; |
| 137573 | function node_copy() { |
| 137574 | return hierarchy(this).eachBefore(copyData); |