Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
walk(node: any, depth: number) {
if (this.itemCount) {
this._old_selectedNode = this.getSelectedItem().node;
assert(this._old_selectedNode);
}
this._index_selectedNode = -1;
this.setItems([]);
if (node.name && depth === 0) {
// root node
node.depth = 0;
this._add(node, true, null);
}
function dumpChildren(this: Tree, node: any, depth: number): void {
if (_.isFunction(node.children)) {
return;
}
node.children = node.children || [];
function toContent(node: any, isLastChild: boolean, parent: any): any {
if (parent) {
const sep = (parent.isLastChild) ? " " : "│";
node.prefix = parent.prefix + sep;
} else {
node.prefix = " ";
}
const s = (isLastChild) ? "└" : "├";
const level = node.depth;
assert(level >= 0 && level < 100);
const hasChildren = node.children && node.children.length > 0;
// [+]
const c = node.expanded ? (hasChildren ? chalk.green("▼ ") : chalk.blue("▼ ")) : "► ";
const str = node.prefix + s + c + node.name;
return str;
}
function dummy(node: any, callback: (err: Error | null, child: any) => void) {
populate_children.call(this, node, (err: Error | null, children: any) => {
if (err) {
return;
}
assert(_.isArray(children));
node.children = children;
node.expanded = true;
this.setData(this.__data);
});
}