climb() works.

folders
Rick Carlino 2019-11-26 16:00:07 -06:00
parent 7f5759382a
commit d07dd5eb15
1 changed files with 8 additions and 12 deletions

View File

@ -20,19 +20,15 @@ function visit(p: VisitorProps) {
if (!p.state.active) { return; }
callback(node, halt);
const children: FolderUnion[] = (node.children);
return p.state.active && children.map(nextNode => {
if (nextNode.kind != "terminal") {
p.state.active && visit({ ...p, node: nextNode });
} else {
p.state.active && callback(nextNode, p.halt);
}
});
switch (node.kind) {
case "initial":
case "medial":
const children: FolderUnion[] = (node.children);
return p.state.active && children.map(nextNode => {
if (nextNode.kind == "medial") {
visit({ ...p, node: nextNode });
}
});
default:
return;
}
}
export const climb = (t: RootFolderNode, callback: TreeClimber) => {