index.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /// <reference types="node" />
  2. import { signals } from './signals.js';
  3. export { signals };
  4. /**
  5. * A function that takes an exit code and signal as arguments
  6. *
  7. * In the case of signal exits *only*, a return value of true
  8. * will indicate that the signal is being handled, and we should
  9. * not synthetically exit with the signal we received. Regardless
  10. * of the handler return value, the handler is unloaded when an
  11. * otherwise fatal signal is received, so you get exactly 1 shot
  12. * at it, unless you add another onExit handler at that point.
  13. *
  14. * In the case of numeric code exits, we may already have committed
  15. * to exiting the process, for example via a fatal exception or
  16. * unhandled promise rejection, so it is impossible to stop safely.
  17. */
  18. export type Handler = (code: number | null | undefined, signal: NodeJS.Signals | null) => true | void;
  19. export declare const
  20. /**
  21. * Called when the process is exiting, whether via signal, explicit
  22. * exit, or running out of stuff to do.
  23. *
  24. * If the global process object is not suitable for instrumentation,
  25. * then this will be a no-op.
  26. *
  27. * Returns a function that may be used to unload signal-exit.
  28. */
  29. onExit: (cb: Handler, opts?: {
  30. alwaysLast?: boolean | undefined;
  31. } | undefined) => () => void,
  32. /**
  33. * Load the listeners. Likely you never need to call this, unless
  34. * doing a rather deep integration with signal-exit functionality.
  35. * Mostly exposed for the benefit of testing.
  36. *
  37. * @internal
  38. */
  39. load: () => void,
  40. /**
  41. * Unload the listeners. Likely you never need to call this, unless
  42. * doing a rather deep integration with signal-exit functionality.
  43. * Mostly exposed for the benefit of testing.
  44. *
  45. * @internal
  46. */
  47. unload: () => void;
  48. //# sourceMappingURL=index.d.ts.map