site/node_modules/d3-hierarchy/src/hierarchy/eachBefore.js
2024-10-14 08:09:33 +02:00

12 lines
334 B
JavaScript

export default function(callback, that) {
var node = this, nodes = [node], children, i, index = -1;
while (node = nodes.pop()) {
callback.call(that, node, ++index, this);
if (children = node.children) {
for (i = children.length - 1; i >= 0; --i) {
nodes.push(children[i]);
}
}
}
return this;
}