Comparing version 3.2.0 to 4.0.0
@@ -56,3 +56,3 @@ /** | ||
}, { | ||
minimumWait: 500 | ||
wait: 500 | ||
}); | ||
@@ -65,3 +65,3 @@ | ||
// Removing an exit hook: | ||
const unsubscribe = asyncExitHook(() => {}, {minimumWait: 500}); | ||
const unsubscribe = asyncExitHook(() => {}, {wait: 500}); | ||
@@ -88,3 +88,3 @@ unsubscribe(); | ||
}, { | ||
minimumWait: 500 | ||
wait: 500 | ||
}); | ||
@@ -98,7 +98,7 @@ | ||
export interface Options { | ||
export type Options = { | ||
/** | ||
The amount of time in milliseconds that the `onExit` function is expected to take. | ||
The amount of time in milliseconds that the `onExit` function is expected to take. When multiple async handlers are registered, the longest `wait` time will be used. | ||
*/ | ||
minimumWait: number; | ||
} | ||
readonly wait: number; | ||
}; |
10
index.js
@@ -61,4 +61,4 @@ import process from 'node:process'; | ||
function addHook(options) { | ||
const {onExit, minimumWait, isSynchronous} = options; | ||
const asyncCallbackConfig = [onExit, minimumWait]; | ||
const {onExit, wait, isSynchronous} = options; | ||
const asyncCallbackConfig = [onExit, wait]; | ||
@@ -120,4 +120,4 @@ if (isSynchronous) { | ||
if (!(typeof options.minimumWait === 'number' && options.minimumWait > 0)) { | ||
throw new TypeError('minimumWait must be set to a positive numeric value'); | ||
if (!(typeof options.wait === 'number' && options.wait > 0)) { | ||
throw new TypeError('wait must be set to a positive numeric value'); | ||
} | ||
@@ -127,3 +127,3 @@ | ||
onExit, | ||
minimumWait: options.minimumWait, | ||
wait: options.wait, | ||
isSynchronous: false, | ||
@@ -130,0 +130,0 @@ }); |
{ | ||
"name": "exit-hook", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"description": "Run some code when the process exits", | ||
@@ -14,5 +14,8 @@ "license": "MIT", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
"node": ">=18" | ||
}, | ||
@@ -45,7 +48,7 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"execa": "^5.1.1", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
"ava": "^5.3.1", | ||
"execa": "^8.0.1", | ||
"tsd": "^0.28.1", | ||
"xo": "^0.56.0" | ||
} | ||
} |
@@ -77,7 +77,7 @@ # exit-hook | ||
##### minimumWait | ||
##### wait | ||
Type: `number` | ||
The amount of time in milliseconds that the `onExit` function is expected to take. | ||
The amount of time in milliseconds that the `onExit` function is expected to take. When multiple async handlers are registered, the longest `wait` time will be used. | ||
@@ -90,3 +90,3 @@ ```js | ||
}, { | ||
minimumWait: 300 | ||
wait: 300 | ||
}); | ||
@@ -107,3 +107,3 @@ | ||
}, { | ||
minimumWait: 300 | ||
wait: 300 | ||
}); | ||
@@ -141,2 +141,2 @@ | ||
Asynchronous hooks should make a "best effort" to perform their tasks within the `minimumWait` time, but also be written to assume they may not complete their tasks before termination. | ||
Asynchronous hooks should make a "best effort" to perform their tasks within the `wait` time, but also be written to assume they may not complete their tasks before termination. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11308