@darkobits/adeiu
Advanced tools
Comparing version 0.2.14 to 0.2.15
@@ -6,4 +6,4 @@ "use strict"; | ||
}); | ||
exports.SIGNALS = void 0; | ||
exports.default = adeiu; | ||
exports.SIGNALS = void 0; | ||
@@ -10,0 +10,0 @@ var _chalk = _interopRequireDefault(require("chalk")); |
{ | ||
"name": "@darkobits/adeiu", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"description": "Yet another POSIX signal handler.", | ||
@@ -11,2 +11,22 @@ "license": "WTFPL", | ||
}, | ||
"engines": { | ||
"node": ">= 14.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/adeiu.js", | ||
"scripts": { | ||
"prepare": "nr prepare" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"ow": "^0.27.0" | ||
}, | ||
"devDependencies": { | ||
"@darkobits/eslint-plugin": "^0.2.9", | ||
"@darkobits/ts": "^0.12.4", | ||
"emittery": "^0.9.2", | ||
"p-wait-for": "^3.2.0" | ||
}, | ||
"keywords": [ | ||
@@ -35,22 +55,3 @@ "clean", | ||
"terminate" | ||
], | ||
"engines": { | ||
"node": ">= 14.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/adeiu.js", | ||
"scripts": { | ||
"prepare": "nr prepare" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"ow": "^0.27.0" | ||
}, | ||
"devDependencies": { | ||
"@darkobits/ts": "^0.7.11", | ||
"emittery": "^0.9.2", | ||
"p-wait-for": "^3.2.0" | ||
} | ||
] | ||
} |
@@ -9,2 +9,3 @@ <a href="#top" id="top"> | ||
<a href="https://depfu.com/github/darkobits/adeiu"><img src="https://img.shields.io/depfu/darkobits/adeiu?style=flat-square"></a> | ||
<a href="https://bundlephobia.com/package/@darkobits/adeiu"><img src="https://img.shields.io/bundlephobia/minzip/@darkobits/adeiu?label=size&style=flat-square"></a> | ||
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/static/v1?label=commits&message=conventional&style=flat-square&color=398AFB"></a> | ||
@@ -17,7 +18,9 @@ </p> | ||
* Ensures provided functions are called before any other event listeners and are run concurrently, minimizing shutdown time. | ||
* Ensures provided functions are called before any other event listeners and are run concurrently, | ||
minimizing shutdown time. | ||
* Works with any combination of synchronous and asynchronous functions. | ||
* Ensures a clean exit if all functions resolve/return. | ||
* Exits with an error if any functions reject/throw. | ||
* Ensures processes exit cleanly, even when they have asynchronous shut-down functions and the Node debugger is in use. (See [this issue](https://github.com/nodejs/node/issues/7742)) | ||
* Ensures processes exit cleanly, even when they have asynchronous shut-down functions and the Node | ||
debugger is in use. (See [this issue](https://github.com/nodejs/node/issues/7742)) | ||
@@ -32,2 +35,11 @@ ## Install | ||
Adeiu accepts an asynchronous or synchronous handler function and returns a function that can be invoked | ||
to unregister the handler. By default, the handler will be registered to respond to the following | ||
signals: | ||
* `SIGINT` | ||
* `SIGQUIT` | ||
* `SIGTERM` | ||
* `SIGUSR2` | ||
```ts | ||
@@ -49,5 +61,7 @@ import adeiu from '@darkobits/adeiu'; | ||
## Advanced Usage | ||
## Customizing Signals | ||
Usually, responding to signals dynamically can be accomplished by inspecting the `signal` argument passed to your callback. However, if it is important that listeners are _only_ installed on a particular signal, you may optionally provide a custom array of signals to assign a callback to. | ||
Usually, responding to signals dynamically can be accomplished by inspecting the `signal` argument | ||
passed to your callback. However, if it is important that listeners are _only_ installed on a particular | ||
signal, you may optionally provide a custom array of signals to assign a callback to. | ||
@@ -57,3 +71,3 @@ ```ts | ||
// Register callback that will only be invoked on SIGINT. | ||
// Register callback that will _only_ be invoked on SIGINT. | ||
adeiu(() => { | ||
@@ -65,3 +79,3 @@ // SIGINT cleanup tasks. | ||
```ts | ||
import adeiu, {SIGNALS} from '@darkobits/adeiu'; | ||
import adeiu, { SIGNALS } from '@darkobits/adeiu'; | ||
@@ -68,0 +82,0 @@ // Register callback with the default signals and SIGUSR1. |
Sorry, the diff of this file is not supported yet
16720
12
105
86
4