@alwatr/exit-hook 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/main.cjs +2 -2
- package/dist/main.cjs.map +3 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.mjs +2 -2
- package/dist/main.mjs.map +3 -3
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.13](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.12...@alwatr/exit-hook@1.0.13) (2024-08-31)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **exit-hook:** define package using @alwatr/dedupe to prevent duplicates ([e16638c](https://github.com/Alwatr/nanolib/commit/e16638cb69639f1c7c1316d72db8032fef617d00)) by @AliMD
|
|
11
|
+
|
|
12
|
+
## [1.0.12](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.11...@alwatr/exit-hook@1.0.12) (2024-08-31)
|
|
13
|
+
|
|
14
|
+
### Dependencies update
|
|
15
|
+
|
|
16
|
+
* update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @AliMD
|
|
17
|
+
|
|
6
18
|
## [1.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.10...@alwatr/exit-hook@1.0.11) (2024-07-04)
|
|
7
19
|
|
|
8
20
|
### Dependencies update
|
package/dist/main.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/exit-hook v1.0.
|
|
2
|
-
"use strict";var t=Object.defineProperty;var
|
|
1
|
+
/* @alwatr/exit-hook v1.0.13 */
|
|
2
|
+
"use strict";var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var k=(o,e)=>{for(var r in e)t(o,r,{get:e[r],enumerable:!0})},p=(o,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of x(e))!I.call(o,c)&&c!==r&&t(o,c,{get:()=>e[c],enumerable:!(n=f(e,c))||n.enumerable});return o};var u=o=>p(t({},"__esModule",{value:!0}),o);var E={};k(E,{exitHook:()=>T});module.exports=u(E);var l=require("@alwatr/dedupe");(0,l.definePackage)("@alwatr/exit-hook","1.0.13");var s=[],a=!1;function T(o){s.push(o)}function i(o){if(console.log("onExit({signal: %s})",o),a!==!0){a=!0;for(let e of s)try{e()}catch(r){console.error("Error in exit hook callback:",r)}(o==="SIGINT"||o==="SIGTERM")&&setTimeout(()=>{process.exit(0)})}}process.once("exit",i),process.once("SIGTERM",i),process.once("SIGINT",i);0&&(module.exports={exitHook});
|
|
3
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Array of callback functions to be called when the process is exiting.\n */\nconst callbacks: (() => void)[] = [];\n\n/**\n * True whether the process is exiting to prevent calling the callbacks more than once.\n */\nlet exiting = false;\n\n/**\n * Add a callback function to be called when the process is exiting.\n *\n * @param callback The callback function to be called when the process is exiting.\n *\n * @example\n * ```typescript\n * const saveAllData = () => {\n * // save all data\n * };\n *\n * existHook(saveAllData);\n * ```\n */\nexport function exitHook(callback: () => void): void {\n callbacks.push(callback);\n}\n\n/**\n * A once callback to be called on process exit event.\n */\nfunction onExit_(signal: number | 'SIGINT' | 'SIGTERM') {\n console.log('onExit({signal: %s
|
|
5
|
-
"mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["main_exports", "__export", "exitHook", "__toCommonJS", "callbacks", "exiting", "callback", "onExit_", "signal", "error"]
|
|
4
|
+
"sourcesContent": ["import {definePackage} from '@alwatr/dedupe';\n\ndefinePackage('@alwatr/exit-hook', __package_version__);\n\n/**\n * Array of callback functions to be called when the process is exiting.\n */\nconst callbacks: (() => void)[] = [];\n\n/**\n * True whether the process is exiting to prevent calling the callbacks more than once.\n */\nlet exiting = false;\n\n/**\n * Add a callback function to be called when the process is exiting.\n *\n * @param callback The callback function to be called when the process is exiting.\n *\n * @example\n * ```typescript\n * const saveAllData = () => {\n * // save all data\n * };\n *\n * existHook(saveAllData);\n * ```\n */\nexport function exitHook(callback: () => void): void {\n callbacks.push(callback);\n}\n\n/**\n * A once callback to be called on process exit event.\n */\nfunction onExit_(signal: number | 'SIGINT' | 'SIGTERM') {\n console.log('onExit({signal: %s})', signal);\n\n if (exiting === true) return;\n exiting = true;\n\n for (const callback of callbacks) {\n try {\n callback();\n }\n catch (error) {\n console.error('Error in exit hook callback:', error);\n }\n }\n\n if (signal === 'SIGINT' || signal === 'SIGTERM') {\n setTimeout(() => {\n process.exit(0);\n });\n }\n}\n\n/**\n * This event emitted when Node.js empties its event loop and has no additional work to schedule.\n * Normally, the Node.js process will exit when there is no work scheduled,\n * but a listener registered on the 'beforeExit' event can make **asynchronous calls**, and thereby cause the Node.js process to continue.\n *\n * @see https://nodejs.org/api/process.html#event-beforeexit\n */\n// process.once('beforeExit', onExit_);\n\n/**\n * This event is emitted when the Node.js process is about to exit as a result of either:\n * 1- The `process.exit()` method being called explicitly.\n * 2- The Node.js event loop no longer having any additional work to perform.\n *\n * @see https://nodejs.org/api/process.html#event-exit\n */\nprocess.once('exit', onExit_);\n\n/**\n * This event is emitted in terminal mode before exiting with code 128 + signal number.\n *\n * @see https://nodejs.org/api/process.html#signal-events\n */\nprocess.once('SIGTERM', onExit_);\n\n/**\n * This event is emitted when `Ctrl+C` is pressed.\n *\n * @see https://nodejs.org/api/process.htm l#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
|
|
5
|
+
"mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,6BAE5B,iBAAc,oBAAqB,QAAmB,EAKtD,IAAMC,EAA4B,CAAC,EAK/BC,EAAU,GAgBP,SAASJ,EAASK,EAA4B,CACnDF,EAAU,KAAKE,CAAQ,CACzB,CAKA,SAASC,EAAQC,EAAuC,CAGtD,GAFA,QAAQ,IAAI,uBAAwBA,CAAM,EAEtCH,IAAY,GAChB,CAAAA,EAAU,GAEV,QAAWC,KAAYF,EACrB,GAAI,CACFE,EAAS,CACX,OACOG,EAAO,CACZ,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,EAGED,IAAW,UAAYA,IAAW,YACpC,WAAW,IAAM,CACf,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEL,CAkBA,QAAQ,KAAK,OAAQD,CAAO,EAO5B,QAAQ,KAAK,UAAWA,CAAO,EAO/B,QAAQ,KAAK,SAAUA,CAAO",
|
|
6
|
+
"names": ["main_exports", "__export", "exitHook", "__toCommonJS", "import_dedupe", "callbacks", "exiting", "callback", "onExit_", "signal", "error"]
|
|
7
7
|
}
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEnD"}
|
package/dist/main.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/exit-hook v1.0.
|
|
2
|
-
var
|
|
1
|
+
/* @alwatr/exit-hook v1.0.13 */
|
|
2
|
+
import{definePackage as n}from"@alwatr/dedupe";n("@alwatr/exit-hook","1.0.13");var r=[],c=!1;function a(o){r.push(o)}function e(o){if(console.log("onExit({signal: %s})",o),c!==!0){c=!0;for(let t of r)try{t()}catch(i){console.error("Error in exit hook callback:",i)}(o==="SIGINT"||o==="SIGTERM")&&setTimeout(()=>{process.exit(0)})}}process.once("exit",e),process.once("SIGTERM",e),process.once("SIGINT",e);export{a as exitHook};
|
|
3
3
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Array of callback functions to be called when the process is exiting.\n */\nconst callbacks: (() => void)[] = [];\n\n/**\n * True whether the process is exiting to prevent calling the callbacks more than once.\n */\nlet exiting = false;\n\n/**\n * Add a callback function to be called when the process is exiting.\n *\n * @param callback The callback function to be called when the process is exiting.\n *\n * @example\n * ```typescript\n * const saveAllData = () => {\n * // save all data\n * };\n *\n * existHook(saveAllData);\n * ```\n */\nexport function exitHook(callback: () => void): void {\n callbacks.push(callback);\n}\n\n/**\n * A once callback to be called on process exit event.\n */\nfunction onExit_(signal: number | 'SIGINT' | 'SIGTERM') {\n console.log('onExit({signal: %s
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["callbacks", "exiting", "exitHook", "callback", "onExit_", "signal", "error"]
|
|
4
|
+
"sourcesContent": ["import {definePackage} from '@alwatr/dedupe';\n\ndefinePackage('@alwatr/exit-hook', __package_version__);\n\n/**\n * Array of callback functions to be called when the process is exiting.\n */\nconst callbacks: (() => void)[] = [];\n\n/**\n * True whether the process is exiting to prevent calling the callbacks more than once.\n */\nlet exiting = false;\n\n/**\n * Add a callback function to be called when the process is exiting.\n *\n * @param callback The callback function to be called when the process is exiting.\n *\n * @example\n * ```typescript\n * const saveAllData = () => {\n * // save all data\n * };\n *\n * existHook(saveAllData);\n * ```\n */\nexport function exitHook(callback: () => void): void {\n callbacks.push(callback);\n}\n\n/**\n * A once callback to be called on process exit event.\n */\nfunction onExit_(signal: number | 'SIGINT' | 'SIGTERM') {\n console.log('onExit({signal: %s})', signal);\n\n if (exiting === true) return;\n exiting = true;\n\n for (const callback of callbacks) {\n try {\n callback();\n }\n catch (error) {\n console.error('Error in exit hook callback:', error);\n }\n }\n\n if (signal === 'SIGINT' || signal === 'SIGTERM') {\n setTimeout(() => {\n process.exit(0);\n });\n }\n}\n\n/**\n * This event emitted when Node.js empties its event loop and has no additional work to schedule.\n * Normally, the Node.js process will exit when there is no work scheduled,\n * but a listener registered on the 'beforeExit' event can make **asynchronous calls**, and thereby cause the Node.js process to continue.\n *\n * @see https://nodejs.org/api/process.html#event-beforeexit\n */\n// process.once('beforeExit', onExit_);\n\n/**\n * This event is emitted when the Node.js process is about to exit as a result of either:\n * 1- The `process.exit()` method being called explicitly.\n * 2- The Node.js event loop no longer having any additional work to perform.\n *\n * @see https://nodejs.org/api/process.html#event-exit\n */\nprocess.once('exit', onExit_);\n\n/**\n * This event is emitted in terminal mode before exiting with code 128 + signal number.\n *\n * @see https://nodejs.org/api/process.html#signal-events\n */\nprocess.once('SIGTERM', onExit_);\n\n/**\n * This event is emitted when `Ctrl+C` is pressed.\n *\n * @see https://nodejs.org/api/process.htm l#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAQ,iBAAAA,MAAoB,iBAE5BA,EAAc,oBAAqB,QAAmB,EAKtD,IAAMC,EAA4B,CAAC,EAK/BC,EAAU,GAgBP,SAASC,EAASC,EAA4B,CACnDH,EAAU,KAAKG,CAAQ,CACzB,CAKA,SAASC,EAAQC,EAAuC,CAGtD,GAFA,QAAQ,IAAI,uBAAwBA,CAAM,EAEtCJ,IAAY,GAChB,CAAAA,EAAU,GAEV,QAAWE,KAAYH,EACrB,GAAI,CACFG,EAAS,CACX,OACOG,EAAO,CACZ,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,EAGED,IAAW,UAAYA,IAAW,YACpC,WAAW,IAAM,CACf,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEL,CAkBA,QAAQ,KAAK,OAAQD,CAAO,EAO5B,QAAQ,KAAK,UAAWA,CAAO,EAO/B,QAAQ,KAAK,SAAUA,CAAO",
|
|
6
|
+
"names": ["definePackage", "callbacks", "exiting", "exitHook", "callback", "onExit_", "signal", "error"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/exit-hook",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "A utility for registering exit handlers in Node.js.",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -65,11 +65,14 @@
|
|
|
65
65
|
"clean": "rm -rfv dist *.tsbuildinfo"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@alwatr/nano-build": "^1.3.
|
|
68
|
+
"@alwatr/nano-build": "^1.3.8",
|
|
69
69
|
"@alwatr/prettier-config": "^1.0.4",
|
|
70
70
|
"@alwatr/tsconfig-base": "^1.2.0",
|
|
71
|
-
"@types/node": "^
|
|
72
|
-
"typescript": "^5.5.
|
|
71
|
+
"@types/node": "^22.5.1",
|
|
72
|
+
"typescript": "^5.5.4"
|
|
73
73
|
},
|
|
74
|
-
"
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@alwatr/dedupe": "^1.0.11"
|
|
76
|
+
},
|
|
77
|
+
"gitHead": "369275b8713f7f8ae1e44fdfddacd5053e38c95c"
|
|
75
78
|
}
|