|
| 1 | +// Type definitions for pidtree 0.3 |
| 2 | +// Project: https://github.com/simonepri/pidtree |
| 3 | +// Definitions by: Silas Rech <https://github.com/lenovouser> |
| 4 | +// Definitions: https://github.com/simonepri/pidtree |
| 5 | +// TypeScript Version: 3.4 |
| 6 | + |
| 7 | +declare namespace pidtree { |
| 8 | + export interface Options { |
| 9 | + /** |
| 10 | + Include the provided PID in the list. Ignored if -1 is passed as PID. |
| 11 | +
|
| 12 | + @default false |
| 13 | + */ |
| 14 | + root?: boolean; |
| 15 | + } |
| 16 | + |
| 17 | + export interface AdvancedResult { |
| 18 | + /** |
| 19 | + PID of the parent. |
| 20 | + */ |
| 21 | + ppid: number, |
| 22 | + /** |
| 23 | + PID |
| 24 | + */ |
| 25 | + pid: number, |
| 26 | + } |
| 27 | + |
| 28 | + export type Result = number; |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | +Get the list of children and grandchildren pids of the given PID. |
| 33 | +
|
| 34 | +@param pid The PID |
| 35 | +
|
| 36 | +@example |
| 37 | +``` |
| 38 | +import * as pidtree from 'pidtree'; |
| 39 | +(async => { |
| 40 | + const result = await pidtree(1, { advanced: true }); |
| 41 | + //=> [{ppid: 1, pid: 530}, {ppid: 1, pid: 42}, ..., {ppid: 1, pid: 41241}] |
| 42 | +})(); |
| 43 | +``` |
| 44 | +*/ |
| 45 | +declare function pidtree(pid: string | number, callback: (error: Error | undefined, result: pidtree.Result[]) => void): void; |
| 46 | +declare function pidtree(pid: string | number, options: pidtree.Options, callback: (error: Error | undefined, result: pidtree.Result[]) => void): void; |
| 47 | +declare function pidtree(pid: string | number, options: pidtree.Options & { advanced: true }, callback: (error: Error | undefined, result: pidtree.AdvancedResult[]) => void): void; |
| 48 | +declare function pidtree(pid: string | number): Promise<pidtree.Result[]>; |
| 49 | +declare function pidtree(pid: string | number, options: pidtree.Options): Promise<pidtree.Result[]>; |
| 50 | +declare function pidtree(pid: string | number, options: pidtree.Options & { advanced: true }): Promise<pidtree.AdvancedResult[]>; |
| 51 | + |
| 52 | +export = pidtree; |
0 commit comments