Add broker statistics

This commit is contained in:
Thomas Nordquist
2019-01-22 19:54:36 +01:00
parent a86871b161
commit 37694d38b0
13 changed files with 170 additions and 37 deletions

View File

@@ -148,6 +148,25 @@ export class TreeNode {
return this.cachedChildTopics
}
public findNode (path: String): TreeNode | undefined {
const topics = path.split('/')
return this.findChild(topics)
}
private findChild(edges: string[]): TreeNode | undefined {
if (edges.length === 0) {
return this
}
const nextEdge = this.edges[edges[0]]
if (!nextEdge) {
return undefined
}
return nextEdge.target.findChild(edges.slice(1))
}
private mergeEdges(node: TreeNode) {
const edgeKeys = Object.keys(node.edges)
let edgesDidUpdate = false