summaryrefslogtreecommitdiff
path: root/node_modules/exit-hook/index.d.ts
diff options
context:
space:
mode:
authorakiyamn2023-09-24 23:22:21 +1000
committerakiyamn2023-09-24 23:22:21 +1000
commit4e87195739f2a5d9a05451b48773c8afdc680765 (patch)
tree9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/exit-hook/index.d.ts
downloadprice-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz
price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/exit-hook/index.d.ts')
-rw-r--r--node_modules/exit-hook/index.d.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/node_modules/exit-hook/index.d.ts b/node_modules/exit-hook/index.d.ts
new file mode 100644
index 0000000..f7aed97
--- /dev/null
+++ b/node_modules/exit-hook/index.d.ts
@@ -0,0 +1,37 @@
+/**
+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.
+
+@param callback - The callback to execute when the process exits.
+@returns A function that removes the hook when called.
+
+@example
+```
+import 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:
+const unsubscribe = exitHook(() => {});
+
+unsubscribe();
+```
+*/
+declare function exitHook(callback: () => void): () => void;
+
+export = exitHook;