deep-trails - v3.0.0-beta.3
    Preparing search index...

    Type Alias ParentContext<P, K>

    Describes the context of a parent node during deep iteration.

    Provides metadata about the node's position, ancestry, and traversal state.

    3.0.0-beta.0

    type ParentContext<P extends object, K = unknown> = {
        depth: number;
        index: number;
        key: K | null;
        parentValue: P | null;
        path: string | Readonly<K[]>;
        role: "key" | "value" | "root";
        size: number | undefined;
        value: P;
        visits: number;
    }

    Type Parameters

    • P extends object
    • K = unknown
    Index

    Properties

    depth: number

    Depth of this parent in the tree, starting from root at 0.

    index: number

    The zero-based index of this parent within its own parent. It is -1 for the root node.

    Indicates the discovery order, even for disordered structures.

    key: K | null

    The key identifying this parent within its own parent.

    It is null if this node is the root.

    parentValue: P | null

    A reference to the parent object of this parent, or null if this is the root node.

    Mutating it will affect the source structure.

    path: string | Readonly<K[]>

    Path from the root to this parent node.

    Its type varies depending on the value of "pathType" in the options.

    role: "key" | "value" | "root"

    Indicates whether this parent object is the key or value of its node, or the root node.

    size: number | undefined

    Total number of children that have been counted for this parent object.

    It is undefined if the number of children is not known.

    value: P

    A reference to the object.

    It is the same as the key if the role is "key".

    Mutating it will affect the source structure.

    visits: number

    Number of times this parent object has been visited on the deep iteration.