|
| 1 | +declare namespace PidTree { |
| 2 | + export interface Options { |
| 3 | + /** |
| 4 | + * Include the provided PID in the list. Ignored if -1 is passed as PID. |
| 5 | + * @default false |
| 6 | + */ |
| 7 | + root?: boolean; |
| 8 | + } |
| 9 | + |
| 10 | + export interface AdvancedResult { |
| 11 | + /** |
| 12 | + * PID of the parent. |
| 13 | + */ |
| 14 | + ppid: number; |
| 15 | + /** |
| 16 | + * PID |
| 17 | + */ |
| 18 | + pid: number; |
| 19 | + } |
| 20 | + |
| 21 | + export type Result = number; |
| 22 | +} |
| 23 | + |
| 24 | +/** |
| 25 | + * Get the list of children pids of the given pid. |
| 26 | + * @param pid A PID. If -1 will return all the pids. |
| 27 | + * @param callback Called when the list is ready. |
| 28 | + */ |
| 29 | +declare function pidtree( |
| 30 | + pid: string | number, |
| 31 | + callback: (error: Error | undefined, result: PidTree.Result[]) => void |
| 32 | +): void; |
| 33 | + |
| 34 | +/** |
| 35 | + * Get the list of children pids of the given pid. |
| 36 | + * @param pid A PID. If -1 will return all the pids. |
| 37 | + * @param options Options object. |
| 38 | + * @param callback Called when the list is ready. |
| 39 | + */ |
| 40 | +declare function pidtree( |
| 41 | + pid: string | number, |
| 42 | + options: PidTree.Options, |
| 43 | + callback: (error: Error | undefined, result: PidTree.Result[]) => void |
| 44 | +): void; |
| 45 | + |
| 46 | +/** |
| 47 | + * Get the list of children pids of the given pid. |
| 48 | + * @param pid A PID. If -1 will return all the pids. |
| 49 | + * @param options Options object. |
| 50 | + * @param callback Called when the list is ready. |
| 51 | + */ |
| 52 | +declare function pidtree( |
| 53 | + pid: string | number, |
| 54 | + options: PidTree.Options & {advanced: true}, |
| 55 | + callback: (error: Error | undefined, result: PidTree.AdvancedResult[]) => void |
| 56 | +): void; |
| 57 | + |
| 58 | +/** |
| 59 | + * Get the list of children pids of the given pid. |
| 60 | + * @param pid A PID. If -1 will return all the pids. |
| 61 | + * @param [options] Optional options object. |
| 62 | + * @returns A promise containing the list. |
| 63 | + */ |
| 64 | +declare function pidtree( |
| 65 | + pid: string | number, |
| 66 | + options?: PidTree.Options |
| 67 | +): Promise<PidTree.Result[]>; |
| 68 | + |
| 69 | +/** |
| 70 | + * Get the list of children pids of the given pid. |
| 71 | + * @param pid A PID. If -1 will return all the pids. |
| 72 | + * @param options Options object. |
| 73 | + * @returns A promise containing the list. |
| 74 | + */ |
| 75 | +declare function pidtree( |
| 76 | + pid: string | number, |
| 77 | + options: PidTree.Options & {advanced: true} |
| 78 | +): Promise<PidTree.AdvancedResult[]>; |
| 79 | + |
| 80 | +export = pidtree; |
0 commit comments