Function getParentPath

  • If the node has a parent it will return:

    {
    parent: parentObject,
    path: "propertyName",
    }

    If it has no parent (root node) it will return undefined.

    Note that this function will throw if the passed object is not a node.

    Type Parameters

    • TParent extends object

      Parent object type.

    Parameters

    • node: object

      Node to get the parent path from.

    Returns undefined | ParentPath<TParent>

    Parent path or undefined if there's no parent.