@alwatr/exit-hook 5.5.28 → 5.5.29
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 +10 -0
- package/dist/main.cjs +1 -2
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +1 -2
- package/dist/main.mjs.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [5.5.29](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.28...@alwatr/exit-hook@5.5.29) (2026-03-16)
|
|
7
|
+
|
|
8
|
+
### 🔨 Code Refactoring
|
|
9
|
+
|
|
10
|
+
* migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
|
|
11
|
+
|
|
12
|
+
### 🔗 Dependencies update
|
|
13
|
+
|
|
14
|
+
* bump the npm-dependencies group with 10 updates ([c48d9ba](https://github.com/Alwatr/nanolib/commit/c48d9baa1cd7c2dc144b3e01e0fda60bf87c074c))
|
|
15
|
+
|
|
6
16
|
## [5.5.28](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.27...@alwatr/exit-hook@5.5.28) (2026-02-18)
|
|
7
17
|
|
|
8
18
|
### 🔗 Dependencies update
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** 📦 @alwatr/exit-hook v5.5.
|
|
2
|
-
__dev_mode__: console.debug("📦 @alwatr/exit-hook v5.5.28");
|
|
1
|
+
/** 📦 @alwatr/exit-hook v5.5.29 */
|
|
3
2
|
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{exitHook:()=>exitHook});module.exports=__toCommonJS(main_exports);var callbacks=null;var exiting=false;function exitHook(callback){if(callbacks===null){registerExitEvents();callbacks=[]}callbacks.push(callback)}function onExit_(signal){console.log("onExit({signal: %s})",signal);if(exiting===true||callbacks===null)return;exiting=true;for(const callback of callbacks){try{callback()}catch(error){console.error("Error in exit hook callback:",error)}}if(signal==="SIGINT"||signal==="SIGTERM"){setTimeout(()=>{process.exit(0)})}}function registerExitEvents(){process.once("exit",onExit_);process.once("SIGTERM",onExit_);process.once("SIGINT",onExit_)}0&&(module.exports={exitHook});
|
|
4
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Array of callback functions to be called when the process is exiting.\n */\nlet callbacks: (() => void)[] | null = null;\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 if (callbacks === null) {\n registerExitEvents();\n callbacks = [];\n }\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 if (exiting === true || callbacks === null) return;\n\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 * Register process exit events.\n */\nfunction registerExitEvents(): void {\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 */\n process.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 */\n process.once('SIGTERM', onExit_);\n\n /**\n * This event is emitted when `Ctrl+C` is pressed.\n *\n * @see https://nodejs.org/api/process.html#signal-events\n */\n process.once('SIGINT', onExit_);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";qqBAAA,6GAGA,IAAI,UAAmC,KAKvC,IAAI,QAAU,MAgBP,SAAS,SAAS,SAA4B,CACnD,GAAI,YAAc,KAAM,CACtB,mBAAmB,EACnB,UAAY,CAAC,CACf,CACA,UAAU,KAAK,QAAQ,CACzB,CAKA,SAAS,QAAQ,OAAuC,CACtD,QAAQ,IAAI,uBAAwB,MAAM,EAC1C,GAAI,UAAY,MAAQ,YAAc,KAAM,OAE5C,QAAU,KAEV,UAAW,YAAY,UAAW,CAChC,GAAI,CACF,SAAS,CACX,OACO,MAAO,CACZ,QAAQ,MAAM,+BAAgC,KAAK,CACrD,CACF,CAEA,GAAI,SAAW,UAAY,SAAW,UAAW,CAC/C,WAAW,IAAM,CACf,QAAQ,KAAK,CAAC,CAChB,CAAC,CACH,CACF,CAKA,SAAS,oBAA2B,CAiBlC,QAAQ,KAAK,OAAQ,OAAO,EAO5B,QAAQ,KAAK,UAAW,OAAO,EAO/B,QAAQ,KAAK,SAAU,OAAO,CAChC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** 📦 @alwatr/exit-hook v5.5.
|
|
2
|
-
__dev_mode__: console.debug("📦 @alwatr/exit-hook v5.5.28");
|
|
1
|
+
/** 📦 @alwatr/exit-hook v5.5.29 */
|
|
3
2
|
var callbacks=null;var exiting=false;function exitHook(callback){if(callbacks===null){registerExitEvents();callbacks=[]}callbacks.push(callback)}function onExit_(signal){console.log("onExit({signal: %s})",signal);if(exiting===true||callbacks===null)return;exiting=true;for(const callback of callbacks){try{callback()}catch(error){console.error("Error in exit hook callback:",error)}}if(signal==="SIGINT"||signal==="SIGTERM"){setTimeout(()=>{process.exit(0)})}}function registerExitEvents(){process.once("exit",onExit_);process.once("SIGTERM",onExit_);process.once("SIGINT",onExit_)}export{exitHook};
|
|
4
3
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Array of callback functions to be called when the process is exiting.\n */\nlet callbacks: (() => void)[] | null = null;\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 if (callbacks === null) {\n registerExitEvents();\n callbacks = [];\n }\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 if (exiting === true || callbacks === null) return;\n\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 * Register process exit events.\n */\nfunction registerExitEvents(): void {\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 */\n process.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 */\n process.once('SIGTERM', onExit_);\n\n /**\n * This event is emitted when `Ctrl+C` is pressed.\n *\n * @see https://nodejs.org/api/process.html#signal-events\n */\n process.once('SIGINT', onExit_);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,IAAI,UAAmC,KAKvC,IAAI,QAAU,MAgBP,SAAS,SAAS,SAA4B,CACnD,GAAI,YAAc,KAAM,CACtB,mBAAmB,EACnB,UAAY,CAAC,CACf,CACA,UAAU,KAAK,QAAQ,CACzB,CAKA,SAAS,QAAQ,OAAuC,CACtD,QAAQ,IAAI,uBAAwB,MAAM,EAC1C,GAAI,UAAY,MAAQ,YAAc,KAAM,OAE5C,QAAU,KAEV,UAAW,YAAY,UAAW,CAChC,GAAI,CACF,SAAS,CACX,OACO,MAAO,CACZ,QAAQ,MAAM,+BAAgC,KAAK,CACrD,CACF,CAEA,GAAI,SAAW,UAAY,SAAW,UAAW,CAC/C,WAAW,IAAM,CACf,QAAQ,KAAK,CAAC,CAChB,CAAC,CACH,CACF,CAKA,SAAS,oBAA2B,CAiBlC,QAAQ,KAAK,OAAQ,OAAO,EAO5B,QAAQ,KAAK,UAAW,OAAO,EAO/B,QAAQ,KAAK,SAAU,OAAO,CAChC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/exit-hook",
|
|
3
3
|
"description": "A utility for registering exit handlers in Node.js.",
|
|
4
|
-
"version": "5.5.
|
|
4
|
+
"version": "5.5.29",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Alwatr/nanolib/issues",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@alwatr/nano-build": "6.4.
|
|
8
|
+
"@alwatr/nano-build": "6.4.2",
|
|
9
9
|
"@alwatr/prettier-config": "6.0.2",
|
|
10
10
|
"@alwatr/tsconfig-base": "6.0.4",
|
|
11
|
-
"@types/node": "^24.
|
|
11
|
+
"@types/node": "^24.12.0",
|
|
12
12
|
"typescript": "^5.9.3"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
@@ -56,21 +56,21 @@
|
|
|
56
56
|
"directory": "packages/exit-hook"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"b": "
|
|
60
|
-
"build": "
|
|
59
|
+
"b": "bun run build",
|
|
60
|
+
"build": "bun run build:ts && bun run build:es",
|
|
61
61
|
"build:es": "nano-build --preset=module",
|
|
62
62
|
"build:ts": "tsc --build",
|
|
63
|
-
"c": "
|
|
64
|
-
"cb": "
|
|
63
|
+
"c": "bun run clean",
|
|
64
|
+
"cb": "bun run clean && bun run build",
|
|
65
65
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
66
|
-
"d": "
|
|
67
|
-
"w": "
|
|
68
|
-
"watch": "
|
|
69
|
-
"watch:es": "
|
|
70
|
-
"watch:ts": "
|
|
66
|
+
"d": "bun run build:es && bun --enable-source-maps --trace-warnings",
|
|
67
|
+
"w": "bun run watch",
|
|
68
|
+
"watch": "bun run watch:ts & bun run watch:es",
|
|
69
|
+
"watch:es": "bun run build:es --watch",
|
|
70
|
+
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"type": "module",
|
|
74
74
|
"types": "./dist/main.d.ts",
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "c3889e3756b0a0f9b935a1b702a1373ac52cb379"
|
|
76
76
|
}
|