• Find destination nodes by keys

    Example

    import { findNodesByKeys } from "tree-handle-lib";
    const node = {
    key: "node1",
    children: [
    {
    key: "node2",
    children: [
    { key: "key1", title: "kkk11", children: [] },
    { key: "key2", children: [] },
    ],
    },
    {
    key: "node3",
    children: [
    { key: "key3", children: [] },
    { key: "key4", children: [] },
    ],
    },
    ],
    };
    const result = findNodesByKeys(node, ["key1", "key4"]);

    // console.log(JSON.stringify(result));

    [{ key: "key1", title: "kkk11" }, { key: "key4" }];

    Parameters

    • node: TNode

      the root node of the tree, can be a single node or an array of nodes

    • keys: string[]

      the key list of find the destination nodes

    • childrenName: string = CHILDREN_NAME

      the child key name of the child node in the tree structure,default value is CHILDREN_NAME='children'

    • keyName: string = KEY_NAME

      the key name of the node in the tree structure, default value is KEY_NAME='key'

    Returns TTreeNode[]

    node | null

Generated using TypeDoc