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

getAncestor

getAncestor<TMatch>(snapshot, path, options): { node: TMatch; path: Path; } | undefined

Defined in: get-ancestor.ts:17

Find an ancestor of the node at a given path that matches a predicate. Does not check the node at the path itself, only its ancestors.

mode: 'lowest' (default) returns the nearest matching ancestor. mode: 'highest' returns the outermost matching ancestor.

When match is a type predicate, the returned node narrows to that type.

TMatch extends PortableTextBlock

TraversalSnapshot

Path

(node, path) => node is TMatch

"lowest" | "highest"

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

getAncestor(snapshot, path, options): { node: PortableTextBlock; path: Path; } | undefined

Defined in: get-ancestor.ts:28

TraversalSnapshot

Path

(node, path) => boolean

"lowest" | "highest"

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