cleankill

  • Version 2.0.0
  • Published
  • No dependencies
  • BSD-3-Clause license

Install

npm i cleankill
yarn add cleankill
pnpm add cleankill

Overview

Hook SIGINT and cleanly shut down your async code

Index

Functions

function close

close: () => Promise<void>;
  • Call all interrupt handlers, and call the callback when they all complete.

    Clears the list of interrupt handlers.

function interrupt

interrupt: () => void;
  • Calls all interrupt handlers, then exits with exit code 0.

    If called more than once it skips waiting for the interrupt handlers to finish and exits with exit code 1. If there are any errors with interrupt handlers, the process exits immediately with exit code 2.

    This function is called when a SIGINT is received.

function onInterrupt

onInterrupt: (handler: Handler) => void;
  • Register a handler to occur on SIGINT. The handler must return a promise if it has any asynchronous work to do. The process will be terminated once all handlers complete. If a handler throws or the promise it returns rejects then the process will be terminated immediately.

function promiseAllStrict

promiseAllStrict: (promises: Promise<any>[]) => Promise<void>;
  • Waits for all promises to settle, then rejects with the first error, if any.

Type Aliases

type Handler

type Handler = () => Promise<void>;
  • The type of a cleankill interrupt handler.

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (1)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/cleankill.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/cleankill)
  • HTML
    <a href="https://www.jsdocs.io/package/cleankill"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>