Some refactorings

This commit is contained in:
Henning Dieterichs
2019-07-31 20:16:48 +02:00
parent 922eb0b845
commit e4e17c69b6
28 changed files with 6021 additions and 5952 deletions

View File

@@ -0,0 +1,29 @@
import { TreeViewModel, TreeNodeViewModel } from "./Views";
import { TreeNodeData } from "@hediet/debug-visualizer-data-extraction";
export function createTreeViewModelFromTreeNodeData(
root: TreeNodeData["root"]
): TreeViewModel {
const m = new TreeViewModel();
m.root = recurse(root, m);
return m;
function recurse(
root: TreeNodeData["root"],
viewModel: TreeViewModel
): TreeNodeViewModel {
const children: TreeNodeViewModel[] = root.children.map(c =>
recurse(c, viewModel)
);
const model = new TreeNodeViewModel(
viewModel,
root.id,
root.name,
children
);
for (const c of children) {
c.parent = model;
}
return model;
}
}