nhb-toolbox 4.25.0 → 4.25.4

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
@@ -6,6 +6,11 @@ All notable changes to the package will be documented here.
6
6
 
7
7
  ---
8
8
 
9
+ ## [4.25.1-4] - 2025-11-04
10
+
11
+ - **Added** *alias* for `Chronos` *static method* `use`: `register`.
12
+ - **Updated** *tsdoc* for `Chronos` *static methods* `use` and `register`.
13
+
9
14
  ## [4.25.0] - 2025-11-03
10
15
 
11
16
  - **Added** new `Chronos` method `durationString(...)` and **Fixed** issues with internal *duration normalization logic*.
@@ -1008,6 +1008,9 @@ class Chronos {
1008
1008
  plugin(_a);
1009
1009
  }
1010
1010
  }
1011
+ static register(plugin) {
1012
+ _a.use(plugin);
1013
+ }
1011
1014
  }
1012
1015
  exports.Chronos = Chronos;
1013
1016
  _a = Chronos;
@@ -770,8 +770,25 @@ export declare class Chronos {
770
770
  * @static Injects a plugin into the `Chronos` system.
771
771
  * @param plugin The plugin to inject.
772
772
  *
773
+ * @remarks
774
+ * - Using this (`use`) method in `React` projects may trigger *linter error* like `"React Hooks must be called in a React function component or a custom React Hook function."`
775
+ * - To prevent this incorrect *linter error* in `React` projects, prefer using {@link register} method (alias `use` method).
776
+ *
773
777
  * - **NOTE:** *Once a plugin is injected, all the registered methods for that plugin will be available for the whole project.*
774
778
  * - See {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/plugins#-official-plugins full list of plugins and the methods they register}.
775
779
  */
776
780
  static use(plugin: ChronosPlugin): void;
781
+ /**
782
+ * @static Registers a plugin into the `Chronos` system.
783
+ * @param plugin The plugin to register.
784
+ *
785
+ * @remarks
786
+ * - This is just an alias for {@link use} method.
787
+ * - Using {@link use} method in `React` projects may trigger *linter error* like `"React Hooks must be called in a React function component or a custom React Hook function."`
788
+ * - To prevent this incorrect *linter error* in `React` projects, prefer using this (`register`) method over {@link use} method.
789
+ *
790
+ * - **NOTE:** *Once a plugin is injected, all the registered methods for that plugin will be available for the whole project.*
791
+ * - See {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/plugins#-official-plugins full list of plugins and the methods they register}.
792
+ */
793
+ static register(plugin: ChronosPlugin): void;
777
794
  }
@@ -87,10 +87,27 @@ export interface ChronosStatics {
87
87
  * @static Injects a plugin into the `Chronos` system.
88
88
  * @param plugin The plugin to inject.
89
89
  *
90
+ * @remarks
91
+ * - Using this (`use`) method in `React` projects may trigger *linter error* like `"React Hooks must be called in a React function component or a custom React Hook function."`
92
+ * - To prevent this incorrect *linter error* in `React` projects, prefer using {@link register} method (alias `use` method).
93
+ *
90
94
  * - **NOTE:** *Once a plugin is injected, all the registered methods for that plugin will be available for the whole project.*
91
- * - See full list of plugins and the methods they register {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/plugins#-official-plugins here}.
95
+ * - See {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/plugins#-official-plugins full list of plugins and the methods they register}.
92
96
  */
93
97
  use(plugin: ChronosPlugin): void;
98
+ /**
99
+ * @static Registers a plugin into the `Chronos` system.
100
+ * @param plugin The plugin to register.
101
+ *
102
+ * @remarks
103
+ * - This is just an alias for {@link use} method.
104
+ * - Using {@link use} method in `React` projects may trigger *linter error* like `"React Hooks must be called in a React function component or a custom React Hook function."`
105
+ * - To prevent this incorrect *linter error* in `React` projects, prefer using this (`register`) method over {@link use} method.
106
+ *
107
+ * - **NOTE:** *Once a plugin is injected, all the registered methods for that plugin will be available for the whole project.*
108
+ * - See {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/plugins#-official-plugins full list of plugins and the methods they register}.
109
+ */
110
+ register(plugin: ChronosPlugin): void;
94
111
  /**
95
112
  * * Returns the current date and time in a specified format in local time.
96
113
  * * Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55`
@@ -1005,5 +1005,8 @@ export class Chronos {
1005
1005
  plugin(_a);
1006
1006
  }
1007
1007
  }
1008
+ static register(plugin) {
1009
+ _a.use(plugin);
1010
+ }
1008
1011
  }
1009
1012
  _a = Chronos;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.25.0",
3
+ "version": "4.25.4",
4
4
  "description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -39,12 +39,12 @@
39
39
  },
40
40
  "license": "Apache-2.0",
41
41
  "devDependencies": {
42
- "@eslint/js": "^9.39.0",
42
+ "@eslint/js": "^9.39.1",
43
43
  "@types/jest": "^30.0.0",
44
- "@types/node": "^24.9.2",
45
- "@typescript-eslint/eslint-plugin": "^8.46.2",
46
- "@typescript-eslint/parser": "^8.46.2",
47
- "eslint": "^9.39.0",
44
+ "@types/node": "^24.10.0",
45
+ "@typescript-eslint/eslint-plugin": "^8.46.3",
46
+ "@typescript-eslint/parser": "^8.46.3",
47
+ "eslint": "^9.39.1",
48
48
  "eslint-config-prettier": "^10.1.8",
49
49
  "eslint-plugin-prettier": "^5.5.4",
50
50
  "globals": "^16.5.0",
@@ -56,7 +56,7 @@
56
56
  "ts-jest": "^29.4.5",
57
57
  "ts-node": "^10.9.2",
58
58
  "typescript": "^5.9.3",
59
- "typescript-eslint": "^8.46.2"
59
+ "typescript-eslint": "^8.46.3"
60
60
  },
61
61
  "keywords": [
62
62
  "toolbox",