Skip to content
This page is available as Markdown at /api/traversal/functions/getnode.md. For the full documentation index, see /llms.txt, or the complete corpus at /llms-full.txt.

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.

TraversalSnapshot

Path

{ node: Node; path: Path; } | undefined