Skip to content

Commit

Permalink
feat: add children to EditableTreeNode
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 9, 2023
1 parent 47b4aed commit 2eef836
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/extendRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ export class EditableTreeNode {
return this.node.fullPath
}

/**
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method
* **only returns direct children**.
*/
get children(): EditableTreeNode[] {
return [...this.node.children.values()].map(node => new EditableTreeNode(node))
}

/**
* DFS traversal of the tree.
* @example
Expand Down

0 comments on commit 2eef836

Please sign in to comment.