in lib/index.ts [59:72]
export function filterProcessList(rootPid: number, processList: IProcessInfo[], maxDepth: number): IProcessInfo[] {
const rootIndex = processList.findIndex(v => v.pid === rootPid);
if (rootIndex === -1) {
return undefined;
}
if (maxDepth === -1) {
return [];
}
const rootProcess = processList[rootIndex];
const childIndexes = processList.filter(v => v.ppid === rootPid);
return childIndexes.map(c => filterProcessList(c.pid, processList, maxDepth - 1)).reduce((prev, current) => prev.concat(current), [rootProcess]);
}