/** * A node in a tree structure. */ export declare abstract class Node { /** * Returns the ID of this node. */ abstract identity(): string; /** * Attach this node as a child of the given parent node. * One node can only have one parent. * @param parent another node */ abstract attach(parent: this): void; /** * Detach this node from its current parent. * @throws Error if no parent. */ abstract detach(): void; /** * Append a child node to this node. * @param child */ abstract appendChild(child: this): void; /** * Remove a child node from this node. * Do nothing if the given node is not a child. * @param child */ abstract removeChild(child: this): void; /** * Return the parent node of this projection node. */ abstract parent(): this | null; /** * Return the child nodes of this projection node. */ abstract children(): ReadonlySet; /** * Dispose this node and all its children. * Must be invoked when the node is no longer needed. * Duplicate invocations have no effect. */ abstract dispose(): void; /** * Traverse down the node tree starting from this node, inclusive, depth-first. * * @param consumer invoked on each node, including this node, * where a `false` return value will stop the traversal of children. * Note that returning false will not stop the traversal of siblings. * * @example * Since the consumer is always invoked on the current node first, * the following code allows you to get the actual node instance * from a proxy. * ```ts * let actual!: Node; * proxy.traverse(node => { * actual = node; * return false; * }) * ``` */ abstract traverse(consumer: (node: this) => void | boolean): void; /** * Track the path from the this node to the root. * @returns an iterable object, where the first value is parent of the current node * and the last value is the root node. */ abstract track(): Iterable; } export declare class BasicNode implements Node { #private; constructor(id: string); identity(): string; attach(parent: this): void; detach(): void; appendChild(child: this): void; removeChild(child: this): void; parent(): this | null; children(): ReadonlySet; dispose(): void; traverse(consumer: (node: this) => void | boolean): void; track(): Iterable; } //# sourceMappingURL=node.d.ts.map