@alwatr/exit-hook 1.0.5 → 1.0.7

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 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
+ ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.6...@alwatr/exit-hook@1.0.7) (2024-01-31)
7
+
8
+ ### Miscellaneous Chores
9
+
10
+ * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @AliMD
11
+
12
+ ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.5...@alwatr/exit-hook@1.0.6) (2024-01-24)
13
+
14
+ **Note:** Version bump only for package @alwatr/exit-hook
15
+
6
16
  ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/exit-hook@1.0.4...@alwatr/exit-hook@1.0.5) (2024-01-20)
7
17
 
8
18
  **Note:** Version bump only for package @alwatr/exit-hook
@@ -23,10 +33,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
23
33
 
24
34
  ### Bug Fixes
25
35
 
26
- * **exit-hook:** typo function name ([e8df52a](https://github.com/Alwatr/nanolib/commit/e8df52a8f527e653025abe6a8bc54719498db83e)) by @njfamirm
36
+ - **exit-hook:** typo function name ([e8df52a](https://github.com/Alwatr/nanolib/commit/e8df52a8f527e653025abe6a8bc54719498db83e)) by @njfamirm
27
37
 
28
38
  # 1.0.0 (2024-01-03)
29
39
 
30
40
  ### Features
31
41
 
32
- * **exit-hook:** new package ([a41b3a0](https://github.com/Alwatr/nanolib/commit/a41b3a01a4e6af595521e506326678eb96491a11)) by @njfamirm
42
+ - **exit-hook:** new package ([a41b3a0](https://github.com/Alwatr/nanolib/commit/a41b3a01a4e6af595521e506326678eb96491a11)) by @njfamirm
package/dist/main.cjs CHANGED
@@ -1,3 +1,3 @@
1
- /* @alwatr/exit-hook v1.0.5 */
1
+ /* @alwatr/exit-hook v1.0.7 */
2
2
  "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var p=(o,e)=>{for(var r in e)n(o,r,{get:e[r],enumerable:!0})},u=(o,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of f(e))!x.call(o,c)&&c!==r&&n(o,c,{get:()=>e[c],enumerable:!(i=a(e,c))||i.enumerable});return o};var k=o=>u(n({},"__esModule",{value:!0}),o);var E={};p(E,{exitHook:()=>b});module.exports=k(E);var s=[],l=!1;function b(o){s.push(o)}function t(){if(l!==!0){l=!0;for(let o of s)try{o()}catch(e){console.error("Error in exit hook callback:",e)}}}process.once("beforeExit",t),process.once("exit",t),process.once("SIGTERM",t),process.once("SIGINT",t);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_() {\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\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 */\nprocess.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.html#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
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_() {\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\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 */\nprocess.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.html#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
5
5
  "mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAMI,EAA4B,CAAC,EAK/BC,EAAU,GAgBP,SAASH,EAASI,EAA4B,CACnDF,EAAU,KAAKE,CAAQ,CACzB,CAKA,SAASC,GAAU,CACjB,GAAIF,IAAY,GAChB,CAAAA,EAAU,GAEV,QAAWC,KAAYF,EACrB,GAAI,CACFE,EAAS,CACX,OACOE,EAAO,CACZ,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,EAEJ,CASA,QAAQ,KAAK,aAAcD,CAAO,EASlC,QAAQ,KAAK,OAAQA,CAAO,EAO5B,QAAQ,KAAK,UAAWA,CAAO,EAO/B,QAAQ,KAAK,SAAUA,CAAO",
6
6
  "names": ["main_exports", "__export", "exitHook", "__toCommonJS", "callbacks", "exiting", "callback", "onExit_", "error"]
7
7
  }
package/dist/main.mjs CHANGED
@@ -1,3 +1,3 @@
1
- /* @alwatr/exit-hook v1.0.5 */
1
+ /* @alwatr/exit-hook v1.0.7 */
2
2
  var c=[],r=!1;function n(e){c.push(e)}function o(){if(r!==!0){r=!0;for(let e of c)try{e()}catch(t){console.error("Error in exit hook callback:",t)}}}process.once("beforeExit",o),process.once("exit",o),process.once("SIGTERM",o),process.once("SIGINT",o);export{n 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_() {\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\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 */\nprocess.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.html#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
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_() {\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\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 */\nprocess.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.html#signal-events\n */\nprocess.once('SIGINT', onExit_);\n"],
5
5
  "mappings": ";AAGA,IAAMA,EAA4B,CAAC,EAK/BC,EAAU,GAgBP,SAASC,EAASC,EAA4B,CACnDH,EAAU,KAAKG,CAAQ,CACzB,CAKA,SAASC,GAAU,CACjB,GAAIH,IAAY,GAChB,CAAAA,EAAU,GAEV,QAAWE,KAAYH,EACrB,GAAI,CACFG,EAAS,CACX,OACOE,EAAO,CACZ,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,EAEJ,CASA,QAAQ,KAAK,aAAcD,CAAO,EASlC,QAAQ,KAAK,OAAQA,CAAO,EAO5B,QAAQ,KAAK,UAAWA,CAAO,EAO/B,QAAQ,KAAK,SAAUA,CAAO",
6
6
  "names": ["callbacks", "exiting", "exitHook", "callback", "onExit_", "error"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/exit-hook",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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,11 @@
65
65
  "clean": "rm -rfv dist *.tsbuildinfo"
66
66
  },
67
67
  "devDependencies": {
68
- "@alwatr/nano-build": "^1.3.1",
68
+ "@alwatr/nano-build": "^1.3.3",
69
69
  "@alwatr/prettier-config": "^1.0.4",
70
- "@alwatr/tsconfig-base": "^1.1.1",
71
- "@types/node": "^20.11.5",
70
+ "@alwatr/tsconfig-base": "^1.1.2",
71
+ "@types/node": "^20.11.13",
72
72
  "typescript": "^5.3.3"
73
73
  },
74
- "gitHead": "86f36bc089c81a22d5ca27b0745db65ec2f1eca3"
74
+ "gitHead": "54726b7ac06d4a6ffb42731b58e8d976de1211bd"
75
75
  }