tree-walker
Source: quickjs-tree-walker.c — module exports TreeWalker and TreeIterator
DOM-style traversal over an arbitrary nested JS value (objects/arrays treated as a tree of nodes).
TreeWalker
new TreeWalker(root[, filter, flags]) // length 1Navigation methods (each returns the new current node)
| Method | Args | Description |
|---|---|---|
firstChild() | 0 | Descend to the first child of the current node. |
lastChild() | 0 | Descend to the last child. |
nextNode() | 0 | Advance to the next node in document order. |
nextSibling() | 0 | Move to the next sibling. |
parentNode() | 0 | Move up to the parent. |
previousNode() | 0 | Move to the previous node in document order. |
previousSibling() | 0 | Move to the previous sibling. |
toString() | 0 | String representation of the walker. |
Properties
| Property | Kind | Description |
|---|---|---|
root | getter | The traversal root. |
currentNode | getter | The node currently pointed at. |
currentKey | getter | Key/index of the current node within its parent. |
currentPath | getter | Path from the root to the current node. |
depth | getter | Current nesting depth. |
index | getter/setter | Index of the current node among its siblings. |
length | getter | Number of children of the current node. |
tagMask | getter/setter | Bitmask of node types to visit. |
filter | getter | The node filter (enumerable). |
flags | getter/setter | Traversal flags. |
TreeIterator
new TreeIterator(root[, ...]) // length 1Iterable form of the walker: exposes next(), [Symbol.iterator]() and tags
itself "TreeIterator".
Export list
Generated by utilities/doc-api.js from the tree_walker dump of utilities/api-surface.sh: 58 members. Edit the text above this block, not the block.
TreeIterator
class, constructible
- static values:
FILTER_ACCEPT = 1,FILTER_REJECT = 2,FILTER_SKIP = 3,RETURN_PATH = 16777216,RETURN_VALUE = 0,RETURN_VALUE_PATH = 33554432,TYPE_ALL = 4095,TYPE_BIG_INT = 128,TYPE_BOOL = 4,TYPE_INT = 8,TYPE_NULL = 2,TYPE_OBJECT = 16,TYPE_PRIMITIVE = 1007,TYPE_STRING = 32,TYPE_SYMBOL = 64,TYPE_UNDEFINED = 1 - methods:
next(),[Symbol.iterator]() - properties:
[Symbol.toStringTag]
TreeWalker
class, constructible
- static values:
FILTER_ACCEPT = 1,FILTER_REJECT = 2,FILTER_SKIP = 3,RETURN_PATH = 16777216,RETURN_VALUE = 0,RETURN_VALUE_PATH = 33554432,TYPE_ALL = 4095,TYPE_BIG_INT = 128,TYPE_BOOL = 4,TYPE_INT = 8,TYPE_NULL = 2,TYPE_OBJECT = 16,TYPE_PRIMITIVE = 1007,TYPE_STRING = 32,TYPE_SYMBOL = 64,TYPE_UNDEFINED = 1 - methods:
firstChild(),lastChild(),nextNode(),nextSibling(),parentNode(),previousNode(),previousSibling(),toString() - properties:
currentKey (get),currentNode (get),currentPath (get),depth (get),filter (get),flags (get/set),index (get/set),length (get),root (get),tagMask (get/set),[Symbol.toStringTag]