latest
twilkinson3421/onexitExit event listeners for Deno
This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers




JSR Score
94%
Published
4 months ago (2.0.0)
OnExit
Exit event listeners for Deno. Listens for unload and unhandledrejection events.
Basic Usage
import { addExitListener } from "<import-path>"; addExitListener(event => console.debug(`Process exit detected\nCause: ${event?.cause}`));
Signals
By default, the exit event will not be dispatched when the process
exits due to a signal (e.g. SIGINT, SIGTERM, SIGKILL, etc.).
To enable this behavior, call the exitOnSignal function
with the signals you want to listen for.
/** * Registers exit event listeners for the specified signals. * * @param {Deno.Signal[]} [signals=["SIGINT", "SIGTERM", "SIGQUIT"]] - The signals to listen for. * @param {boolean} [clear=true] - Whether to clear any previously registered signal listeners. */
import { exitOnSignal } from "<import-path>"; exitOnSignal(["SIGINT"]); // defaults to SIGINT, SIGTERM, SIGQUIT
Signal listeners can also be cleared by calling clearSignalListeners.
Add Package
deno add jsr:@zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";
Import directly with a jsr specifier
import * as onexit from "jsr:@zerm/onexit";
Add Package
pnpm i jsr:@zerm/onexit
pnpm dlx jsr add @zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";
Add Package
yarn add jsr:@zerm/onexit
yarn dlx jsr add @zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";
Add Package
vlt install jsr:@zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";
Add Package
npx jsr add @zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";
Add Package
bunx jsr add @zerm/onexit
Import symbol
import * as onexit from "@zerm/onexit";