@alwatr/exit-hook 5.5.28 → 6.0.0

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/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* 📦 @alwatr/exit-hook v6.0.0 */
2
+ var q=null,y=!1;function D(f){if(q===null)B(),q=[];q.push(f)}function u(f){if(console.log("onExit({signal: %s})",f),y===!0||q===null)return;y=!0;for(let z of q)try{z()}catch(A){console.error("Error in exit hook callback:",A)}if(f==="SIGINT"||f==="SIGTERM")setTimeout(()=>{process.exit(0)})}function B(){process.once("exit",u),process.once("SIGTERM",u),process.once("SIGINT",u)}export{D as exitHook};
3
+
4
+ //# debugId=5F944679885B422C64756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts"],
4
+ "sourcesContent": [
5
+ "/**\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"
6
+ ],
7
+ "mappings": ";AAGA,IAAI,EAAmC,KAKnC,EAAU,GAgBP,SAAS,CAAQ,CAAC,EAA4B,CACnD,GAAI,IAAc,KAChB,EAAmB,EACnB,EAAY,CAAC,EAEf,EAAU,KAAK,CAAQ,EAMzB,SAAS,CAAO,CAAC,EAAuC,CAEtD,GADA,QAAQ,IAAI,uBAAwB,CAAM,EACtC,IAAY,IAAQ,IAAc,KAAM,OAE5C,EAAU,GAEV,QAAW,KAAY,EACrB,GAAI,CACF,EAAS,EAEX,MAAO,EAAO,CACZ,QAAQ,MAAM,+BAAgC,CAAK,EAIvD,GAAI,IAAW,UAAY,IAAW,UACpC,WAAW,IAAM,CACf,QAAQ,KAAK,CAAC,EACf,EAOL,SAAS,CAAkB,EAAS,CAiBlC,QAAQ,KAAK,OAAQ,CAAO,EAO5B,QAAQ,KAAK,UAAW,CAAO,EAO/B,QAAQ,KAAK,SAAU,CAAO",
8
+ "debugId": "5F944679885B422C64756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@alwatr/exit-hook",
3
3
  "description": "A utility for registering exit handlers in Node.js.",
4
- "version": "5.5.28",
4
+ "version": "6.0.0",
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.1",
9
- "@alwatr/prettier-config": "6.0.2",
10
- "@alwatr/tsconfig-base": "6.0.4",
11
- "@types/node": "^24.10.13",
8
+ "@alwatr/nano-build": "7.0.0",
9
+ "@alwatr/prettier-config": "7.0.0",
10
+ "@alwatr/tsconfig-base": "7.0.0",
11
+ "@types/node": "^24.12.0",
12
12
  "typescript": "^5.9.3"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/main.d.ts",
17
- "import": "./dist/main.mjs",
18
- "require": "./dist/main.cjs"
17
+ "default": "./dist/main.js"
19
18
  }
20
19
  },
21
20
  "files": [
22
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
21
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
22
+ "README.md",
23
23
  "LICENSE",
24
24
  "!demo/**/*",
25
25
  "!**/*.test.js"
@@ -44,8 +44,6 @@
44
44
  "utils"
45
45
  ],
46
46
  "license": "MPL-2.0",
47
- "main": "./dist/main.cjs",
48
- "module": "./dist/main.mjs",
49
47
  "prettier": "@alwatr/prettier-config",
50
48
  "publishConfig": {
51
49
  "access": "public"
@@ -56,21 +54,21 @@
56
54
  "directory": "packages/exit-hook"
57
55
  },
58
56
  "scripts": {
59
- "b": "yarn run build",
60
- "build": "yarn run build:ts && yarn run build:es",
61
- "build:es": "nano-build --preset=module",
57
+ "b": "bun run build",
58
+ "build": "bun run build:ts && bun run build:es",
59
+ "build:es": "nano-build --preset=module src/main.ts",
62
60
  "build:ts": "tsc --build",
63
- "c": "yarn run clean",
64
- "cb": "yarn run clean && yarn run build",
61
+ "c": "bun run clean",
62
+ "cb": "bun run clean && bun run build",
65
63
  "clean": "rm -rfv dist *.tsbuildinfo",
66
- "d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
67
- "w": "yarn run watch",
68
- "watch": "yarn run watch:ts & yarn run watch:es",
69
- "watch:es": "yarn run build:es --watch",
70
- "watch:ts": "yarn run build:ts --watch --preserveWatchOutput"
64
+ "d": "bun run build:es && bun",
65
+ "w": "bun run watch",
66
+ "watch": "bun run watch:ts & bun run watch:es",
67
+ "watch:es": "bun run build:es --watch",
68
+ "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
71
69
  },
72
70
  "sideEffects": false,
73
71
  "type": "module",
74
72
  "types": "./dist/main.d.ts",
75
- "gitHead": "f9f9ba54b319ce8ccc6968059b222e89f4b5d149"
73
+ "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
76
74
  }
package/src/main.ts ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Array of callback functions to be called when the process is exiting.
3
+ */
4
+ let callbacks: (() => void)[] | null = null;
5
+
6
+ /**
7
+ * True whether the process is exiting to prevent calling the callbacks more than once.
8
+ */
9
+ let exiting = false;
10
+
11
+ /**
12
+ * Add a callback function to be called when the process is exiting.
13
+ *
14
+ * @param callback The callback function to be called when the process is exiting.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const saveAllData = () => {
19
+ * // save all data
20
+ * };
21
+ *
22
+ * existHook(saveAllData);
23
+ * ```
24
+ */
25
+ export function exitHook(callback: () => void): void {
26
+ if (callbacks === null) {
27
+ registerExitEvents();
28
+ callbacks = [];
29
+ }
30
+ callbacks.push(callback);
31
+ }
32
+
33
+ /**
34
+ * A once callback to be called on process exit event.
35
+ */
36
+ function onExit_(signal: number | 'SIGINT' | 'SIGTERM') {
37
+ console.log('onExit({signal: %s})', signal);
38
+ if (exiting === true || callbacks === null) return;
39
+
40
+ exiting = true;
41
+
42
+ for (const callback of callbacks) {
43
+ try {
44
+ callback();
45
+ }
46
+ catch (error) {
47
+ console.error('Error in exit hook callback:', error);
48
+ }
49
+ }
50
+
51
+ if (signal === 'SIGINT' || signal === 'SIGTERM') {
52
+ setTimeout(() => {
53
+ process.exit(0);
54
+ });
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Register process exit events.
60
+ */
61
+ function registerExitEvents(): void {
62
+ /**
63
+ * This event emitted when Node.js empties its event loop and has no additional work to schedule.
64
+ * Normally, the Node.js process will exit when there is no work scheduled,
65
+ * but a listener registered on the 'beforeExit' event can make **asynchronous calls**, and thereby cause the Node.js process to continue.
66
+ *
67
+ * @see https://nodejs.org/api/process.html#event-beforeexit
68
+ */
69
+ // process.once('beforeExit', onExit_);
70
+
71
+ /**
72
+ * This event is emitted when the Node.js process is about to exit as a result of either:
73
+ * 1- The `process.exit()` method being called explicitly.
74
+ * 2- The Node.js event loop no longer having any additional work to perform.
75
+ *
76
+ * @see https://nodejs.org/api/process.html#event-exit
77
+ */
78
+ process.once('exit', onExit_);
79
+
80
+ /**
81
+ * This event is emitted in terminal mode before exiting with code 128 + signal number.
82
+ *
83
+ * @see https://nodejs.org/api/process.html#signal-events
84
+ */
85
+ process.once('SIGTERM', onExit_);
86
+
87
+ /**
88
+ * This event is emitted when `Ctrl+C` is pressed.
89
+ *
90
+ * @see https://nodejs.org/api/process.html#signal-events
91
+ */
92
+ process.once('SIGINT', onExit_);
93
+ }
package/CHANGELOG.md DELETED
@@ -1,443 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [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
-
8
- ### 🔗 Dependencies update
9
-
10
- * update @types/node to version 24.10.13 across multiple packages ([4c6d2a3](https://github.com/Alwatr/nanolib/commit/4c6d2a37ab26b1c86812b2aa38b2eca4ee097cb6))
11
-
12
- ## [5.5.27](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.26...@alwatr/exit-hook@5.5.27) (2025-12-23)
13
-
14
- ### 🔗 Dependencies update
15
-
16
- * upgrade @types/node to version 24.10.4 and update related dependencies ([acf04df](https://github.com/Alwatr/nanolib/commit/acf04df71647f5a401ef5e6bbfffcc478e4326d2))
17
-
18
- ## [5.5.26](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.25...@alwatr/exit-hook@5.5.26) (2025-12-13)
19
-
20
- ### 🔗 Dependencies update
21
-
22
- * update `@types/node` and `[@lerna-lite](https://github.com/lerna-lite)` dependencies. ([8daa8fd](https://github.com/Alwatr/nanolib/commit/8daa8fd023d5414c9f95feb4319353c6ea34be31))
23
-
24
- ## [5.5.25](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.24...@alwatr/exit-hook@5.5.25) (2025-12-10)
25
-
26
- ### 🔗 Dependencies update
27
-
28
- * Upgrade lerna-lite, prettier, types/node, and yarn dependencies. ([42a7fca](https://github.com/Alwatr/nanolib/commit/42a7fca15430aca2ac1eaa19496c2a2ebfc8c470))
29
-
30
- ## [5.5.24](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.23...@alwatr/exit-hook@5.5.24) (2025-11-18)
31
-
32
- ### 🔨 Code Refactoring
33
-
34
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
35
-
36
- ## [5.5.23](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.22...@alwatr/exit-hook@5.5.23) (2025-11-15)
37
-
38
- ### 🔗 Dependencies update
39
-
40
- * bump the npm-dependencies group with 2 updates ([a80b84d](https://github.com/Alwatr/nanolib/commit/a80b84dada6c09b5e5621e7487c8ec13fff3c23a))
41
-
42
- ## [5.5.22](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.21...@alwatr/exit-hook@5.5.22) (2025-11-15)
43
-
44
- **Note:** Version bump only for package @alwatr/exit-hook
45
-
46
- ## [5.5.21](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.20...@alwatr/exit-hook@5.5.21) (2025-11-04)
47
-
48
- ### 🔗 Dependencies update
49
-
50
- * bump the npm-dependencies group across 1 directory with 9 updates ([fdf29d5](https://github.com/Alwatr/nanolib/commit/fdf29d5aa89983cb06f79d42650a364521f5c4b9))
51
- * update @types/node from ^22.18.12 to ^24.10.0 across multiple packages ([1169a86](https://github.com/Alwatr/nanolib/commit/1169a86001da2abfbe99a7da33c8e92183f553f6))
52
-
53
- ## [5.5.20](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.19...@alwatr/exit-hook@5.5.20) (2025-10-06)
54
-
55
- ### 🔗 Dependencies update
56
-
57
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
58
-
59
- ## [5.5.19](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.18...@alwatr/exit-hook@5.5.19) (2025-09-27)
60
-
61
- ### 🧹 Miscellaneous Chores
62
-
63
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
64
-
65
- ## [5.5.18](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.17...@alwatr/exit-hook@5.5.18) (2025-09-22)
66
-
67
- **Note:** Version bump only for package @alwatr/exit-hook
68
-
69
- ## [5.5.17](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.16...@alwatr/exit-hook@5.5.17) (2025-09-22)
70
-
71
- **Note:** Version bump only for package @alwatr/exit-hook
72
-
73
- ## [5.5.16](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.15...@alwatr/exit-hook@5.5.16) (2025-09-21)
74
-
75
- **Note:** Version bump only for package @alwatr/exit-hook
76
-
77
- ## [5.5.15](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.14...@alwatr/exit-hook@5.5.15) (2025-09-20)
78
-
79
- ### 🐛 Bug Fixes
80
-
81
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
82
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
83
-
84
- ### 🧹 Miscellaneous Chores
85
-
86
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
87
-
88
- ## [5.5.14](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.13...@alwatr/exit-hook@5.5.14) (2025-09-19)
89
-
90
- **Note:** Version bump only for package @alwatr/exit-hook
91
-
92
- ## [5.5.13](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.12...@alwatr/exit-hook@5.5.13) (2025-09-15)
93
-
94
- **Note:** Version bump only for package @alwatr/exit-hook
95
-
96
- ## [5.5.12](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.11...@alwatr/exit-hook@5.5.12) (2025-09-13)
97
-
98
- ### 🔗 Dependencies update
99
-
100
- * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
101
-
102
- ## [5.5.11](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.10...@alwatr/exit-hook@5.5.11) (2025-09-13)
103
-
104
- ### 🧹 Miscellaneous Chores
105
-
106
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
107
-
108
- ## [5.5.10](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.9...@alwatr/exit-hook@5.5.10) (2025-09-09)
109
-
110
- ### 🧹 Miscellaneous Chores
111
-
112
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
113
-
114
- ## [5.5.9](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.8...@alwatr/exit-hook@5.5.9) (2025-09-06)
115
-
116
- **Note:** Version bump only for package @alwatr/exit-hook
117
-
118
- ## [5.5.8](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.7...@alwatr/exit-hook@5.5.8) (2025-09-05)
119
-
120
- ### 🔗 Dependencies update
121
-
122
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
123
-
124
- ## [5.5.7](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.6...@alwatr/exit-hook@5.5.7) (2025-09-01)
125
-
126
- ### 🔗 Dependencies update
127
-
128
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
129
-
130
- ## [5.5.6](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.5...@alwatr/exit-hook@5.5.6) (2025-08-23)
131
-
132
- **Note:** Version bump only for package @alwatr/exit-hook
133
-
134
- ## [5.5.5](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.3...@alwatr/exit-hook@5.5.5) (2025-08-23)
135
-
136
- ### 🐛 Bug Fixes
137
-
138
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
139
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
140
-
141
- ### 🔨 Code Refactoring
142
-
143
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
144
-
145
- ### 🧹 Miscellaneous Chores
146
-
147
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
148
-
149
- ### 🔗 Dependencies update
150
-
151
- * revert @types/node version to ^22.17.2 (LTS) ([49f8101](https://github.com/Alwatr/nanolib/commit/49f8101eac5c41aa7684112f4308254dbfab9787))
152
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
153
-
154
- ## [5.5.4](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.3...@alwatr/exit-hook@5.5.4) (2025-08-23)
155
-
156
- ### Code Refactoring
157
-
158
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
159
-
160
- ## <small>5.5.3 (2025-04-15)</small>
161
-
162
- **Note:** Version bump only for package @alwatr/exit-hook
163
-
164
- ## [5.5.2](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.1...@alwatr/exit-hook@5.5.2) (2025-04-01)
165
-
166
- ### Dependencies update
167
-
168
- * bump the development-dependencies group across 1 directory with 2 updates ([c1320b4](https://github.com/Alwatr/nanolib/commit/c1320b447a492c5e720e25ad71e9df81eeea3670)) by @dependabot[bot]
169
-
170
- ## [5.5.1](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.5.0...@alwatr/exit-hook@5.5.1) (2025-03-18)
171
-
172
- ### Dependencies update
173
-
174
- * bump the development-dependencies group with 9 updates ([7290aa3](https://github.com/Alwatr/nanolib/commit/7290aa3b52ce66ca237d2a12d28a7687b113f83d)) by @dependabot[bot]
175
-
176
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@5.4.0...@alwatr/exit-hook@5.5.0) (2025-03-06)
177
-
178
- ### Miscellaneous Chores
179
-
180
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
181
-
182
- ### Dependencies update
183
-
184
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
185
-
186
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.8...@alwatr/exit-hook@5.4.0) (2025-02-18)
187
-
188
- ### Dependencies update
189
-
190
- * bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 ([b9a8399](https://github.com/Alwatr/nanolib/commit/b9a8399add39509e90bfdc589fb5e2321718029d)) by @
191
-
192
- ## 5.3.0 (2025-02-03)
193
-
194
- ### Miscellaneous Chores
195
-
196
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
197
-
198
- ### Dependencies update
199
-
200
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
201
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
202
-
203
- ## 5.0.0 (2024-11-02)
204
-
205
- ### ⚠ BREAKING CHANGES
206
-
207
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
208
-
209
- ### Code Refactoring
210
-
211
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
212
-
213
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
214
-
215
- ### Miscellaneous Chores
216
-
217
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
218
-
219
- ### Dependencies update
220
-
221
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
222
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
223
-
224
- ## 5.0.0 (2024-11-02)
225
-
226
- ### ⚠ BREAKING CHANGES
227
-
228
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
229
-
230
- ### Features
231
-
232
- * **exit-hook:** new package ([a41b3a0](https://github.com/Alwatr/nanolib/commit/a41b3a01a4e6af595521e506326678eb96491a11)) by @
233
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
234
-
235
- ### Bug Fixes
236
-
237
- * all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @
238
- * **exit-hook:** define package using @alwatr/dedupe to prevent duplicates ([e16638c](https://github.com/Alwatr/nanolib/commit/e16638cb69639f1c7c1316d72db8032fef617d00)) by @
239
- * **exit-hook:** disable beforeExit event and get exit signal from process.exitCode ([2dbed18](https://github.com/Alwatr/nanolib/commit/2dbed18455ab252f686c7af58b9c5bf39f818f0d)) by @
240
- * **exit-hook:** exit after listener called ([70c9f62](https://github.com/Alwatr/nanolib/commit/70c9f624899f87bb417f189792144aa05fca99ba)) by @
241
- * **exit-hook:** Refactor exitHook function to prevent automatically register process exit events ([32d7e29](https://github.com/Alwatr/nanolib/commit/32d7e29dcd89dd4b7dc1a57da391ba8e70f5021d)) by @
242
- * **exit-hook:** show error properly and safe exit on SIGTERM ([b0a27b8](https://github.com/Alwatr/nanolib/commit/b0a27b8c89945069c98637269f976b5e9f3618c0)) by @
243
- * **exit-hook:** typo function name ([e8df52a](https://github.com/Alwatr/nanolib/commit/e8df52a8f527e653025abe6a8bc54719498db83e)) by @
244
-
245
- ### Code Refactoring
246
-
247
- * **exit-hook:** dosen't use `dedupe` anymore ([e6c3ce9](https://github.com/Alwatr/nanolib/commit/e6c3ce91be0a42d5d1f857eca824a200eacc911c)) by @
248
- * **exit-hook:** use new dedupe api ([185aced](https://github.com/Alwatr/nanolib/commit/185aced6566ba986062fbc0d936fb8090430f681)) by @
249
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
250
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
251
-
252
- ### Miscellaneous Chores
253
-
254
- * **deps-dev:** bump the development-dependencies group with 3 updates ([0e0ec0f](https://github.com/Alwatr/nanolib/commit/0e0ec0f7c66c849727563cabe0e88606aee49035)) by @
255
- * **deps:** upd ([b6dd6dd](https://github.com/Alwatr/nanolib/commit/b6dd6dd8173d9788c179d57091402e693fa2024a)) by @
256
- * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @
257
- * **deps:** update ([8e70dff](https://github.com/Alwatr/nanolib/commit/8e70dffb1e751496ef2e72d6cffd685f1fea44e3)) by @
258
- * **deps:** update ([f0b60d2](https://github.com/Alwatr/nanolib/commit/f0b60d24c9fae6190940baf95167a1175360d4b3)) by @
259
- * **exit-hook:** change the license to AGPL-3.0 ([74e89a1](https://github.com/Alwatr/nanolib/commit/74e89a18044831c225649494734d284bb95d4629)) by @
260
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
261
- * rename logger env ([38443ad](https://github.com/Alwatr/nanolib/commit/38443ade4677e857b5ebd4be417f5f2eb1818c87)) by @
262
- * Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @
263
- * Update debug command in package.json ([be8403d](https://github.com/Alwatr/nanolib/commit/be8403dec754f2117259bb915b110ea386596401)) by @
264
- * Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
265
-
266
- ### Dependencies update
267
-
268
- * bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @
269
- * bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @
270
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @
271
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
272
- * bump the development-dependencies group with 2 updates ([be5d6c2](https://github.com/Alwatr/nanolib/commit/be5d6c2d86b937f32cebc6848aaff85af07055dd)) by @
273
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @
274
- * upd ([451d025](https://github.com/Alwatr/nanolib/commit/451d0255ba96ed55f897a6f44f62cf4e6d2b12be)) by @
275
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @
276
- * update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @
277
- * update all ([53342f6](https://github.com/Alwatr/nanolib/commit/53342f67a8a013127f073540bc11929f1813c05c)) by @
278
- * update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @
279
- * update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
280
- * upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @
281
-
282
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.7...@alwatr/exit-hook@1.1.8) (2024-11-02)
283
-
284
- ### Dependencies update
285
-
286
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @alimd
287
-
288
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.6...@alwatr/exit-hook@1.1.7) (2024-10-25)
289
-
290
- ### Dependencies update
291
-
292
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @dependabot[bot]
293
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @dependabot[bot]
294
-
295
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.5...@alwatr/exit-hook@1.1.6) (2024-10-12)
296
-
297
- **Note:** Version bump only for package @alwatr/exit-hook
298
-
299
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.4...@alwatr/exit-hook@1.1.5) (2024-10-11)
300
-
301
- ### Code Refactoring
302
-
303
- - **exit-hook:** dosen't use `dedupe` anymore ([e6c3ce9](https://github.com/Alwatr/nanolib/commit/e6c3ce91be0a42d5d1f857eca824a200eacc911c)) by @mohammadhonarvar
304
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
305
-
306
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.3...@alwatr/exit-hook@1.1.4) (2024-10-11)
307
-
308
- ### Miscellaneous Chores
309
-
310
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
311
-
312
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.2...@alwatr/exit-hook@1.1.3) (2024-10-11)
313
-
314
- ### Bug Fixes
315
-
316
- - **exit-hook:** Refactor exitHook function to prevent automatically register process exit events ([32d7e29](https://github.com/Alwatr/nanolib/commit/32d7e29dcd89dd4b7dc1a57da391ba8e70f5021d)) by @alimd
317
-
318
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.1...@alwatr/exit-hook@1.1.2) (2024-10-10)
319
-
320
- ### Dependencies update
321
-
322
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
323
-
324
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.1.0...@alwatr/exit-hook@1.1.1) (2024-10-08)
325
-
326
- **Note:** Version bump only for package @alwatr/exit-hook
327
-
328
- ## [1.1.0](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.16...@alwatr/exit-hook@1.1.0) (2024-09-29)
329
-
330
- ### Features
331
-
332
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
333
-
334
- ### Bug Fixes
335
-
336
- - all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @mohammadhonarvar
337
-
338
- ### Code Refactoring
339
-
340
- - **exit-hook:** use new dedupe api ([185aced](https://github.com/Alwatr/nanolib/commit/185aced6566ba986062fbc0d936fb8090430f681)) by @alimd
341
-
342
- ### Miscellaneous Chores
343
-
344
- - **exit-hook:** change the license to AGPL-3.0 ([74e89a1](https://github.com/Alwatr/nanolib/commit/74e89a18044831c225649494734d284bb95d4629)) by @ArmanAsadian
345
- - Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @alimd
346
-
347
- ### Dependencies update
348
-
349
- - bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @dependabot[bot]
350
-
351
- ## [1.0.16](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.15...@alwatr/exit-hook@1.0.16) (2024-09-21)
352
-
353
- **Note:** Version bump only for package @alwatr/exit-hook
354
-
355
- ## [1.0.15](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.14...@alwatr/exit-hook@1.0.15) (2024-09-15)
356
-
357
- ### Dependencies update
358
-
359
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
360
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
361
-
362
- ## [1.0.14](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.13...@alwatr/exit-hook@1.0.14) (2024-08-31)
363
-
364
- ### Miscellaneous Chores
365
-
366
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
367
-
368
- ## [1.0.13](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.12...@alwatr/exit-hook@1.0.13) (2024-08-31)
369
-
370
- ### Bug Fixes
371
-
372
- - **exit-hook:** define package using @alwatr/dedupe to prevent duplicates ([e16638c](https://github.com/Alwatr/nanolib/commit/e16638cb69639f1c7c1316d72db8032fef617d00)) by @alimd
373
-
374
- ## [1.0.12](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.11...@alwatr/exit-hook@1.0.12) (2024-08-31)
375
-
376
- ### Dependencies update
377
-
378
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
379
-
380
- ## [1.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.10...@alwatr/exit-hook@1.0.11) (2024-07-04)
381
-
382
- ### Dependencies update
383
-
384
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
385
-
386
- ## [1.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.9...@alwatr/exit-hook@1.0.10) (2024-05-12)
387
-
388
- ### Bug Fixes
389
-
390
- - **exit-hook:** show error properly and safe exit on SIGTERM ([b0a27b8](https://github.com/Alwatr/nanolib/commit/b0a27b8c89945069c98637269f976b5e9f3618c0)) by @alimd
391
-
392
- ### Dependencies update
393
-
394
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
395
-
396
- ## [1.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.8...@alwatr/exit-hook@1.0.9) (2024-04-25)
397
-
398
- ### Bug Fixes
399
-
400
- - **exit-hook:** disable beforeExit event and get exit signal from process.exitCode ([2dbed18](https://github.com/Alwatr/nanolib/commit/2dbed18455ab252f686c7af58b9c5bf39f818f0d)) by @njfamirm
401
- - **exit-hook:** exit after listener called ([70c9f62](https://github.com/Alwatr/nanolib/commit/70c9f624899f87bb417f189792144aa05fca99ba)) by @njfamirm
402
-
403
- ## [1.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.7...@alwatr/exit-hook@1.0.8) (2024-03-28)
404
-
405
- **Note:** Version bump only for package @alwatr/exit-hook
406
-
407
- ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.6...@alwatr/exit-hook@1.0.7) (2024-01-31)
408
-
409
- ### Miscellaneous Chores
410
-
411
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
412
-
413
- ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.5...@alwatr/exit-hook@1.0.6) (2024-01-24)
414
-
415
- **Note:** Version bump only for package @alwatr/exit-hook
416
-
417
- ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.4...@alwatr/exit-hook@1.0.5) (2024-01-20)
418
-
419
- **Note:** Version bump only for package @alwatr/exit-hook
420
-
421
- ## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.3...@alwatr/exit-hook@1.0.4) (2024-01-16)
422
-
423
- **Note:** Version bump only for package @alwatr/exit-hook
424
-
425
- ## [1.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.2...@alwatr/exit-hook@1.0.3) (2024-01-08)
426
-
427
- **Note:** Version bump only for package @alwatr/exit-hook
428
-
429
- ## [1.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.1...@alwatr/exit-hook@1.0.2) (2024-01-03)
430
-
431
- **Note:** Version bump only for package @alwatr/exit-hook
432
-
433
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.0...@alwatr/exit-hook@1.0.1) (2024-01-03)
434
-
435
- ### Bug Fixes
436
-
437
- - **exit-hook:** typo function name ([e8df52a](https://github.com/Alwatr/nanolib/commit/e8df52a8f527e653025abe6a8bc54719498db83e)) by @njfamirm
438
-
439
- # 1.0.0 (2024-01-03)
440
-
441
- ### Features
442
-
443
- - **exit-hook:** new package ([a41b3a0](https://github.com/Alwatr/nanolib/commit/a41b3a01a4e6af595521e506326678eb96491a11)) by @njfamirm
package/dist/main.cjs DELETED
@@ -1,4 +0,0 @@
1
- /** 📦 @alwatr/exit-hook v5.5.28 */
2
- __dev_mode__: console.debug("📦 @alwatr/exit-hook v5.5.28");
3
- "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
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
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": ";;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
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,4 +0,0 @@
1
- /** 📦 @alwatr/exit-hook v5.5.28 */
2
- __dev_mode__: console.debug("📦 @alwatr/exit-hook v5.5.28");
3
- 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
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
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": ";;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
- "names": []
7
- }