getNode
getNode(
snapshot,path): {node:Node;path:Path; } |undefined
Defined in: get-node.ts:32
Get the node at a given path.
The path can be either keyed (KeyedSegment + field name strings) or
indexed (numbers). Keyed segments are resolved by matching _key,
field name strings name a structural descent into the previous
node’s children, and numbers are resolved by index.
The returned path always identifies the returned node: it’s fully
keyed (numeric indices are converted to KeyedSegments) and any
trailing segments in the input that point outside the value tree —
e.g. an object node’s primitive field, or an annotation reached via
'markDefs' on a text block — are stripped so that
getNode(snapshot, entry.path).node === entry.node.
The walk stops when a string segment names a field that isn’t the
current node’s structural child array. Annotations live in
markDefs on a text block, alongside children rather than inside
it, so getNode resolves an annotation path to the enclosing text
block. Use getAnnotation to resolve the annotation itself.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”TraversalSnapshot
Path
Returns
Section titled “Returns”{ node: Node; path: Path; } | undefined