From 4e87195739f2a5d9a05451b48773c8afdc680765 Mon Sep 17 00:00:00 2001 From: akiyamn Date: Sun, 24 Sep 2023 23:22:21 +1000 Subject: Initial commit (by create-cloudflare CLI) --- node_modules/exit-hook/readme.md | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 node_modules/exit-hook/readme.md (limited to 'node_modules/exit-hook/readme.md') diff --git a/node_modules/exit-hook/readme.md b/node_modules/exit-hook/readme.md new file mode 100644 index 0000000..e9eb7a2 --- /dev/null +++ b/node_modules/exit-hook/readme.md @@ -0,0 +1,67 @@ +# exit-hook + +> Run some code when the process exits + +The `process.on('exit')` event doesn't catch all the ways a process can exit. + +This package is useful for cleaning up before exiting. + +## Install + +``` +$ npm install exit-hook +``` + +## Usage + +```js +const exitHook = require('exit-hook'); + +exitHook(() => { + console.log('Exiting'); +}); + +// You can add multiple hooks, even across files +exitHook(() => { + console.log('Exiting 2'); +}); + +throw new Error('🦄'); + +//=> 'Exiting' +//=> 'Exiting 2' +``` + +Removing an exit hook: + +```js +const exitHook = require('exit-hook'); + +const unsubscribe = exitHook(() => {}); + +unsubscribe(); +``` + +## API + +### exitHook(callback) + +Returns a function that removes the hook when called. + +#### callback + +Type: `Function` + +The callback to execute when the process exits. + +--- + +