当前位置:网站首页>Get the set of parent node IDs from top to bottom
Get the set of parent node IDs from top to bottom
2022-07-16 05:50:00 【Jason show】
Get the parent node from the bottom up id Set , Including its own id
for example : Find according to the West Lake District id Find Zhejiang Province id, hangzhou id, And according to these id Make a collection
Ideas
- Recursively traverses from the root node , Until we find the West Lake District , Save every time you traverse id
Realization
const getParentIds = <T, K>(treeData: T[], key: K): string[] => {
let pids: string[] = [];
const fn = (treeData: T[], key: K, id?: string) => {
if (id) pids.push(id);
treeData.forEach((item: {
[key: string]: any }) => {
if (item.key === key) {
pids.push(item.key);
return;
}
if (item?.children) fn(item.children as T[], key as K, item.key as string);
});
};
fn(treeData, key);
return pids;
};
边栏推荐
- Package management tools
- Intranet penetration notes - Sticky Keys and system command information collection
- electron、electron-builder 镜像源配置(2022-06)
- BUUCTF 数据包中的线索
- BUUCTF 后门查杀
- 千亿参数的广告模型,是怎样炼成的?
- php对接支付宝Web支付-tp5.1框架
- ERR_ PNPM_ PEER_ DEP_ ISSUES Unmet peer dependencies
- 内存取证-Volatility安装使用以及一些CTF比赛题目
- 2. Memory leak and memory overflow
猜你喜欢

Buuctf mysterious Tornado
![[Huang ah code] PHP cooperates with xlwriter to realize infinite header level excel export](/img/42/83660b9b6703881df3370f64a9af78.png)
[Huang ah code] PHP cooperates with xlwriter to realize infinite header level excel export

使用百度轻量服务器LS遇到的一些小问题

Network security emergency response - electronic data forensics technology
![[wustctf2020] plain](/img/48/d8e78424d582b60f238a2625854134.png)
[wustctf2020] plain

Intranet penetration notes - vulnhub intranet course completion penetration
![[Huang ah code] Microsoft Internet Explorer will be retired. Netizens said: what should I do in the future?](/img/38/42fffa40b5db9399ee8c526e0c4439.png)
[Huang ah code] Microsoft Internet Explorer will be retired. Netizens said: what should I do in the future?

网络安全应急响应-终端检测与响应技术

Flag under buuctf mask
![[Huang ah code] Why do I suggest you choose go instead of PHP?](/img/c7/3abe59ba4fb275cdf550467bc2b05d.png)
[Huang ah code] Why do I suggest you choose go instead of PHP?
随机推荐
Svelte official introductory tutorial (1) - Introduction
網絡安全應急響應-電子數據取證技術
内网渗透笔记——:)一个笑脸
Image source configuration of electron and electron Builder (2022-06)
C3&H5&ES6
[ASIS 2019]Unicorn shop
2.内存泄漏与内存溢出
Modularity CMJ & ESM
Handsontable Pro authorization code key generator (JS function) (for learning and communication only)
JS根据二进制数据下载文件
内网渗透笔记——vulnhub内网结课渗透
Network security emergency response - basic skills
js 数字序号 转 字母序号
[ASIS 2019]Unicorn shop
PHP docking wechat payment native TP5 framework
WP of the southwest division of the 15th National College Students Information Security Competition (ciscn) 2022
Tree structure tool -treeutil use
Basic knowledge of network
日志黑名单,真的能帮你省钱!
2022第十五届全国大学生信息安全竞赛(ciscn)西南赛区部分WP