Socket
Socket
Sign inDemoInstall

exit-hook

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exit-hook - npm Package Compare versions

Comparing version 2.2.1 to 3.0.0

8

index.d.ts

@@ -8,3 +8,3 @@ /**

@param callback - The callback to execute when the process exits.
@param onExit - The callback function to execute when the process exits.
@returns A function that removes the hook when called.

@@ -14,3 +14,3 @@

```
import exitHook = require('exit-hook');
import exitHook from 'exit-hook';

@@ -37,4 +37,2 @@ exitHook(() => {

*/
declare function exitHook(callback: () => void): () => void;
export = exitHook;
export default function exitHook(onExit: () => void): () => void;

@@ -1,2 +0,2 @@

'use strict';
import process from 'node:process';

@@ -7,3 +7,3 @@ const callbacks = new Set();

function exit(exit, signal) {
function exit(shouldManuallyExit, signal) {
if (isCalled) {

@@ -19,3 +19,3 @@ return;

if (exit === true) {
if (shouldManuallyExit === true) {
process.exit(128 + signal); // eslint-disable-line unicorn/no-process-exit

@@ -25,4 +25,4 @@ }

module.exports = callback => {
callbacks.add(callback);
export default function exitHook(onExit) {
callbacks.add(onExit);

@@ -33,4 +33,4 @@ if (!isRegistered) {

process.once('exit', exit);
process.once('SIGINT', exit.bind(null, true, 2));
process.once('SIGTERM', exit.bind(null, true, 15));
process.once('SIGINT', exit.bind(undefined, true, 2));
process.once('SIGTERM', exit.bind(undefined, true, 15));

@@ -48,4 +48,4 @@ // PM2 Cluster shutdown message. Caught to support async handlers with pm2, needed because

return () => {
callbacks.delete(callback);
callbacks.delete(onExit);
};
};
}
{
"name": "exit-hook",
"version": "2.2.1",
"version": "3.0.0",
"description": "Run some code when the process exits",

@@ -13,4 +13,6 @@ "license": "MIT",

},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=6"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -41,7 +43,7 @@ "scripts": {

"devDependencies": {
"ava": "^1.4.1",
"execa": "^1.0.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"execa": "^5.1.1",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

@@ -18,3 +18,3 @@ # exit-hook

```js
const exitHook = require('exit-hook');
import exitHook from 'exit-hook';

@@ -39,3 +39,3 @@ exitHook(() => {

```js
const exitHook = require('exit-hook');
import exitHook from 'exit-hook';

@@ -49,11 +49,11 @@ const unsubscribe = exitHook(() => {});

### exitHook(callback)
### exitHook(onExit)
Returns a function that removes the hook when called.
#### callback
#### onExit
Type: `Function`
The callback to execute when the process exits.
The callback function to execute when the process exits.

@@ -60,0 +60,0 @@ ---

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc