API
Node Types
Node
15min
node docid\ wkipeevzdbh8w05 f6qlonode docid\ wkipeevzdbh8w05 f6qlonode docid\ wkipeevzdbh8w05 f6qlonode docid\ wkipeevzdbh8w05 f6qlo static methods retrieval methods node ancestor(root node, path path) => ancestor get the node at a specific path , asserting that it is an ancestor node if the specified node is not an ancestor node, throw an error node ancestors(root node, path path, options?) => generator\<nodeentry\<ancestor>> return a generator of all the ancestor nodes above a specific path by default, the order is bottom up, from lowest to highest ancestor in the tree, but you can pass the reverse true option to go top down options {reverse? boolean} node child(root node, index number) => descendant get the child of a node at the specified index node children(root node, path path, options?) => generator\<nodeentry\<descendant>> iterate over the children of a node at a specific path options {reverse? boolean} node common(root node, path path, another path) => nodeentry get an entry for the common ancestor node of two paths node descendant(root node, path path) => descendant get the node at a specific path, asserting that it's a descendant node node descendants(root node, options?) => generator\<nodeentry\<descendant>> return a generator of all the descendant node entries inside a root node each iteration will return a nodeentry tuple consisting of \[node, path] options {from? path, to? path, reverse? boolean, pass? (node nodeentry => boolean)} node elements(root node, options?) => generator\<elemententry> return a generator of all the element nodes inside a root node each iteration will return an elemententry tuple consisting of \[element, path] if the root node is an element, it will be included in the iteration as well options {from? path, to? path, reverse? boolean, pass? (node nodeentry => boolean)} node first(root node, path path) => nodeentry get the first node entry in a root node from a path node fragment(root node, range range) => descendant\[] get the sliced fragment represented by the range node get(root node, path path) => node get the descendant node referred to by a specific path if the path is an empty array, get the root node itself node last(root node, path path) => nodeentry get the last node entry in a root node at a specific path node leaf(root node, path path) => text get the node at a specific path , ensuring it's a leaf text node if the node is not a leaf text node, throw an error node levels(root node, path path, options?) => generator\<nodeentry> return a generator of the nodes in a branch of the tree, from a specific path by default, the order is top down, from the lowest to the highest node in the tree, but you can pass the reverse true option to go bottom up options {reverse? boolean} node nodes(root node, options?) => generator\<nodeentry> return a generator of all the node entries of a root node each entry is returned as a \[node, path] tuple, with the path referring to the node's position inside the root node options {from? path, to? path, reverse? boolean, pass? (node nodeentry => boolean)} node parent(root node, path path) => ancestor get the parent of a node at a specific path text methods methods related to text node string(root node) => string get the concatenated text string of a node's content note that this will not include spaces or line breaks between block nodes this is not intended as a user facing string, but as a string for performing offset related computations for a node node texts(root node, options?) => generator\<nodeentry\<text>> return a generator of all leaf text nodes in a root node options {from? path, to? path, reverse? boolean, pass? (node nodeentry => boolean)} check methods methods used to check some attribute of a node node has(root node, path path) => boolean check if a descendant node exists at a specific path node isnode(value any) => value is node check if a value implements the node interface node isnodelist(value any) => value is node\[] check if a value is a list of node objects node matches(root node, props partial\<node>) => boolean check if a node matches a set of props
🤔
Have a question?
Our super-smart AI,knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.