UNPKG

1.2 kBTypeScriptView Raw
1import SymbolTree = require("./SymbolTree");
2
3declare namespace TreeIterator {
4 /**
5 * The iteration function to use.
6 *
7 * - `1`: Iterate previous sibling nodes.
8 * - `2`: Iterate next sibling nodes.
9 * - `3`: Iterate ancestor nodes.
10 * - `4`: Iterate all tree-inclusive preceding nodes.
11 * - `5`: Iterate all tree-inclusive following nodes.
12 */
13 type IterateFunction = 1 | 2 | 3 | 4 | 5;
14
15 interface TreeIteratorResult<T> {
16 done: boolean;
17 value: T;
18 }
19}
20
21declare class TreeIterator<T extends object = any> implements IterableIterator<T> {
22 constructor(tree: SymbolTree, root: T, firstResult: T, iterateFunction: TreeIterator.IterateFunction);
23
24 next(): TreeIterator.TreeIteratorResult<T>;
25
26 [Symbol.iterator](): this;
27
28 /** Iterate previous sibling nodes. */
29 static readonly PREV: 1;
30
31 /** Iterate next sibling nodes. */
32 static readonly NEXT: 2;
33
34 /** Iterate ancestor nodes. */
35 static readonly PARENT: 3;
36
37 /** Iterate all tree-inclusive preceding nodes. */
38 static readonly PRECEDING: 4;
39
40 /** Iterate all tree-inclusive following nodes. */
41 static readonly FOLLOWING: 5;
42}
43
44export = TreeIterator;