diff --git a/src/hierarchies/hierarchy.ts b/src/hierarchies/hierarchy.ts index c880210..7c944b6 100644 --- a/src/hierarchies/hierarchy.ts +++ b/src/hierarchies/hierarchy.ts @@ -39,11 +39,31 @@ export class Hierarchy { return [ ...this.#roots.values() ]; } + /** Get a shallow clone of the root items. */ + public get rootItems() { + return this.roots.map(r => r.item); + } + + /** Get a shallow clone of the root IDs. */ + public get rootIds() { + return this.roots.map(r => this.#identify(r.item)); + } + /** Get a shallow clone of all nodes. */ public get nodes() { return [ ...this.#nodes.values() ]; } + /** Get a shallow clone of all node items. */ + public get nodeItems() { + return this.roots.map(n => n.item); + } + + /** Get a shallow clone of all node IDs. */ + public get nodeIds() { + return this.roots.map(n => this.#identify(n.item)); + } + /** Means of getting an ID for an `item`. */ public get identify() { return this.#identify;