index.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. export interface AdvancedResult {
  10. /**
  11. * PID of the parent.
  12. */
  13. ppid: number;
  14. /**
  15. * PID
  16. */
  17. pid: number;
  18. }
  19. export type Result = number;
  20. }
  21. /**
  22. * Get the list of children pids of the given pid.
  23. * @param pid A PID. If -1 will return all the pids.
  24. * @param callback Called when the list is ready.
  25. */
  26. declare function pidtree(
  27. pid: string | number,
  28. callback: (error: Error | undefined, result: PidTree.Result[]) => void
  29. ): void;
  30. /**
  31. * Get the list of children pids of the given pid.
  32. * @param pid A PID. If -1 will return all the pids.
  33. * @param options Options object.
  34. * @param callback Called when the list is ready.
  35. */
  36. declare function pidtree(
  37. pid: string | number,
  38. options: PidTree.Options,
  39. callback: (error: Error | undefined, result: PidTree.Result[]) => void
  40. ): void;
  41. /**
  42. * Get the list of children pids of the given pid.
  43. * @param pid A PID. If -1 will return all the pids.
  44. * @param options Options object.
  45. * @param callback Called when the list is ready.
  46. */
  47. declare function pidtree(
  48. pid: string | number,
  49. options: PidTree.Options & {advanced: true},
  50. callback: (error: Error | undefined, result: PidTree.AdvancedResult[]) => void
  51. ): void;
  52. /**
  53. * Get the list of children pids of the given pid.
  54. * @param pid A PID. If -1 will return all the pids.
  55. * @param [options] Optional options object.
  56. * @returns A promise containing the list.
  57. */
  58. declare function pidtree(
  59. pid: string | number,
  60. options?: PidTree.Options
  61. ): Promise<PidTree.Result[]>;
  62. /**
  63. * Get the list of children pids of the given pid.
  64. * @param pid A PID. If -1 will return all the pids.
  65. * @param options Options object.
  66. * @returns A promise containing the list.
  67. */
  68. declare function pidtree(
  69. pid: string | number,
  70. options: PidTree.Options & {advanced: true}
  71. ): Promise<PidTree.AdvancedResult[]>;
  72. export = pidtree;