• split string list data to tree data by char list

    Example

    import { splitStrings2Tree } from "tree-handle-lib";
    const strings = [
    "sql.server_2020_F",
    "sql.server_2020_Ua",
    "sql.server_2021_F",
    ];
    const _result = splitStrings2Tree(strings, [".", "_"]);
    // [
    // {
    // key: "sql.",
    // title: "sql",
    // splitChar: ".",
    // isLastNode: false,
    // children: [
    // {
    // key: "sql.server_",
    // title: "server",
    // splitChar: "_",
    // isLastNode: false,
    // children: [
    // {
    // key: "sql.server_2020_",
    // title: "2020",
    // splitChar: "_",
    // isLastNode: true,
    // children: [
    // { key: "sql.server_2020_F", title: "F", isLeaf: true },
    // { key: "sql.server_2020_Ua", title: "Ua", isLeaf: true },
    // ],
    // },
    // {
    // key: "sql.server_2021_",
    // title: "2021",
    // splitChar: "_",
    // isLastNode: true,
    // children: [{ key: "sql.server_2021_F", title: "F", isLeaf: true }],
    // },
    // ],
    // },
    // ],
    // },
    // ];

    Parameters

    • stringList: string[] = []
    • delimiterList: string[] = []
    • keyName: string = KEY_NAME

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

    • titleName: string = TITLE_NAME

      the attribute key name to filter,default is TITLE_NAME='title'

    • childrenName: string = CHILDREN_NAME

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

    Returns TNode

Generated using TypeDoc