@types/death
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Installation

npm install --save @types/death

Summary

This package contains type definitions for death (https://github.com/jprichardson/node-death).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/death.

index.d.ts

type Signal = "SIGINT" | "SIGTERM" | "SIGQUIT";

/**
 * Invokes a callback when a SIGINT, SIGTERM, or SIGQUIT is detected
 * on the current node process.
 * @param callback The callback to invoke
 * @returns A function to unsubscribe and prevent the callback from being invoked
 * @example
 *  ON_DEATH((signal) => {
 *    console.log('Oh no!');
 *  });
 * @example
 *  const OFF_DEATH = ON_DEATH((signal) => {
 *    console.log('Oh no!');
 *  });
 *  // later
 *  OFF_DEATH();
 */
declare function ON_DEATH(callback: (arg: Signal) => void): () => void;

/**
 * Invokes a callback when a SIGINT, SIGTERM, or SIGQUIT is detected
 * on the current node process. Configurable by the provided options.
 *
 * @param options
 * @returns A function to subscribe to the configured death detection
 * @example
 *  ON_DEATH({
 *    debug: true,
 *  })((signal) => {
 *    console.log('Oh no!');
 *  });
 * @example
 *  const OFF_DEATH = ON_DEATH({
 *    debug: true,
 *  })((signal) => {
 *    console.log('Oh no!');
 *  });
 *  // later
 *  OFF_DEATH();
 */
declare function ON_DEATH(options: {
    debug?: boolean | undefined;
    SIGINT?: boolean | undefined;
    SIGTERM?: boolean | undefined;
    SIGQUIT?: boolean | undefined;
    uncaughtException?: false | undefined;
}): (callback: (signal: Signal) => void) => () => void;

/**
 * Invokes a callback when a SIGINT, SIGTERM, or SIGQUIT is detected
 * on the current node process. Configurable by the provided options.
 *
 * @param options
 * @returns A function to subscribe to the configured death detection
 * @example
 *  ON_DEATH({
 *    debug: true,
 *    uncaughtException: true,
 *  })((signal) => {
 *    console.log('Oh no!');
 *  });
 * @example
 *  const OFF_DEATH = ON_DEATH({
 *    debug: true,
 *    uncaughtException: true,
 *  })((signal) => {
 *    console.log('Oh no!');
 *  });
 *  // later
 *  OFF_DEATH();
 */
declare function ON_DEATH(options: {
    debug?: boolean | undefined;
    SIGINT?: boolean | undefined;
    SIGTERM?: boolean | undefined;
    SIGQUIT?: boolean | undefined;
    uncaughtException: true;
}): (callback: (signalOrErr: Signal | Error, origin?: string) => void) => () => void;

export = ON_DEATH;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Cameron Knight, and Pranay Prakash.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/death

Weekly Downloads

13,467

Version

1.1.5

License

MIT

Unpacked Size

7.09 kB

Total Files

5

Last publish

Collaborators

  • types