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 3.1.4 to 3.2.0

17

index.d.ts
/**
@callback onExit
@param {number} signal - The exit code.
*/
/**
Run some code when the process exits.

@@ -8,3 +13,3 @@

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

@@ -16,4 +21,4 @@

exitHook(() => {
console.log('Exiting');
exitHook(signal => {
console.log(`Exiting with signal: ${signal}`);
});

@@ -37,3 +42,3 @@

*/
export default function exitHook(onExit: () => void): () => void;
export default function exitHook(onExit: (signal: number) => void): () => void;

@@ -44,3 +49,3 @@ /**

@see https://github.com/sindresorhus/exit-hook/blob/main/readme.md#asynchronous-exit-notes
@param onExit - The callback function to execute when the process exits via `gracefulExit`, and will be wrapped in `Promise.resolve`.
@param {onExit} onExit - The callback function to execute when the process exits via `gracefulExit`, and will be wrapped in `Promise.resolve`.
@returns A function that removes the hook when called.

@@ -68,3 +73,3 @@

*/
export function asyncExitHook(onExit: () => (void | Promise<void>), options: Options): () => void;
export function asyncExitHook(onExit: (signal: number) => (void | Promise<void>), options: Options): () => void;

@@ -71,0 +76,0 @@ /**

@@ -26,5 +26,7 @@ import process from 'node:process';

const exitCode = 128 + signal;
const done = (force = false) => {
if (force === true || shouldManuallyExit === true) {
process.exit(128 + signal); // eslint-disable-line unicorn/no-process-exit
process.exit(exitCode); // eslint-disable-line unicorn/no-process-exit
}

@@ -34,3 +36,3 @@ };

for (const callback of callbacks) {
callback();
callback(exitCode);
}

@@ -47,3 +49,3 @@

forceAfter = Math.max(forceAfter, wait);
promises.push(Promise.resolve(callback()));
promises.push(Promise.resolve(callback(exitCode)));
}

@@ -50,0 +52,0 @@

{
"name": "exit-hook",
"version": "3.1.4",
"version": "3.2.0",
"description": "Run some code when the process exits",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -20,4 +20,4 @@ # exit-hook

exitHook(() => {
console.log('Exiting');
exitHook(signal => {
console.log(`Exiting with signal: ${signal}`);
});

@@ -56,3 +56,3 @@

Type: `() => void`
Type: `(signal: number) => void`

@@ -71,3 +71,3 @@ The callback function to execute when the process exits.

Type: `() => (void | Promise<void>)`
Type: `(signal: number) => (void | Promise<void>)`

@@ -74,0 +74,0 @@ The callback function to execute when the process exits via `gracefulExit`, and will be wrapped in `Promise.resolve`.

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