{"version":3,"sources":["../src/tree/getById.ts"],"names":["getById","treeObj","nodeId","options","result","opts","DefaultTreeOptions","idKey","forEachTreeByDfs","node","ABORT"],"mappings":";;;;AAiBO,SAASA,CAAAA,CAA0EC,EAAsBC,CAAmBC,CAAAA,CAAAA,CAAqC,CACpK,IAAIC,CAAAA,CAAqB,KACnBC,CAAO,CAAA,MAAA,CAAO,OAAO,EAAC,CAAGC,EAAoBH,CAAW,EAAA,EAAE,CAC1D,CAAA,CAAE,MAAAI,CAAM,CAAA,CAAIF,EAClB,OAAAG,GAAAA,CAAuBP,EAAQ,CAAC,CAAC,KAAAQ,CAAI,CAAA,GAAI,CACrC,GAAGA,CAAAA,CAAKF,CAAK,CAAKL,EAAAA,CAAAA,CACd,OAAAE,CAASK,CAAAA,CAAAA,CACFC,GAEf,CAAEL,CAAAA,CAAI,EACCD,CACX","file":"chunk-4YDGIL3P.mjs","sourcesContent":["/**\n * \n * 根据路径获取节点对象\n * getByPath(treedata,\"a/b\")\n * \n * getByPath(treedata,\"a/b\",{pathKey:\"name\"})\n * \n */\n\nimport { ABORT } from \"../object\";\nimport { DefaultTreeOptions } from \"./consts\";\nimport { forEachTreeByDfs } from \"./forEachTreeByDfs\";\nimport { TreeNode, TreeNodeBase, TreeNodeOptions } from \"./types\";\n\n \nexport interface GetByIdOptions extends TreeNodeOptions{}\n\nexport function getById<Node extends TreeNodeBase = TreeNode,IdKey extends string = \"id\">(treeObj:Node | Node[],nodeId:Node[IdKey],options?:GetByIdOptions):Node | null {\n    let result:Node | null = null;\n    const opts = Object.assign({}, DefaultTreeOptions ,options || {}) as Required<GetByIdOptions>     \n    const { idKey } = opts\n    forEachTreeByDfs<Node>(treeObj,({node})=>{\n        if(node[idKey] == nodeId){\n            result = node\n            return ABORT    \n        }\n    },opts) \n    return result\n}\n"]}