toolbox-x 1.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.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { zn as LooseLiteral } from "./object-B0TV3eHx.mjs";
18
+ import { n as HTTP_STATUS_DATA } from "./constants-CLS_bgKD.mjs";
19
+
20
+ //#region src/types/http-status.d.ts
21
+ /** Mapped type of HTTP status entries */
22
+ type $HttpStatusMap = (typeof HTTP_STATUS_DATA)[number];
23
+ /** HTTP status name variants: `name` or `readableName` */
24
+ type $StatusNameVar = 'name' | 'readableName';
25
+ /** * Categories of HTTP status codes: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */
26
+ type StatusCategory = $HttpStatusMap['category'];
27
+ /** - Extracts standard HTTP status codes by the given `Category` name. Defaults to all {@link StatusCategory categories}. */
28
+ type HttpStatusCode<Category extends StatusCategory = StatusCategory> = $HttpStatusMap extends infer Target ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target['code'] : never : never : never;
29
+ /** Standard HTTP Status Code, e.g. `404`, `500` etc. + any number */
30
+ type StatusCode = LooseLiteral<HttpStatusCode>;
31
+ /**
32
+ * - Extracts standard HTTP status names filtered by {@link $StatusNameVar variant} and {@link StatusCategory category}.
33
+ * - Defaults to all `variants` and `categories`.
34
+ *
35
+ * @remarks
36
+ * - `Name` selects either the `name` (CONSTANT_CASE) or `readableName` (Title Case).
37
+ * - `Category` restricts results to the chosen HTTP status {@link StatusCategory category}.
38
+ * - Produces a union of all matching literal status name values.
39
+ */
40
+ type HttpStatusName<Name extends $StatusNameVar = $StatusNameVar, Category extends StatusCategory = StatusCategory> = $HttpStatusMap extends infer Target ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target[Name] : never : never : never;
41
+ /** Standard HTTP status name in `CONSTANT_CASE`, e.g. `"INTERNAL_SERVER_ERROR"` + any string */
42
+ type StatusName = LooseLiteral<HttpStatusName>;
43
+ /** HTTP status name (`CONSTANT_CASE`) in {@link StatusEntry} interface */
44
+ type EntryStatusName = LooseLiteral<HttpStatusName<'name'>>;
45
+ /** HTTP status name (`Title Case`) in {@link StatusEntry} interface */
46
+ type EntryReadableName = LooseLiteral<HttpStatusName<'readableName'>>;
47
+ /** * Shape of an HTTP status entry. */
48
+ interface StatusEntry {
49
+ /** HTTP Status Code, e.g. `404`, `500` etc. */
50
+ code: StatusCode;
51
+ /** HTTP status name in `CONSTANT_CASE`, e.g. `"NOT_FOUND"`, `"INTERNAL_SERVER_ERROR"` */
52
+ name: EntryStatusName;
53
+ /** HTTP status name in `Title Case` form, e.g. `"Not Found"`, `"Internal Server Error"` */
54
+ readableName: EntryReadableName;
55
+ /** Link to full `MDN` Docs if available */
56
+ link?: string;
57
+ /** Short message, Can override using `httpStatus.setMessage` method */
58
+ message: string;
59
+ /** A brief description of the status code */
60
+ description: string;
61
+ /** The type of HTTP Status: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */
62
+ category: StatusCategory;
63
+ }
64
+ //#endregion
65
+ export { HttpStatusCode as a, StatusCode as c, EntryStatusName as i, StatusEntry as l, $StatusNameVar as n, HttpStatusName as o, EntryReadableName as r, StatusCategory as s, $HttpStatusMap as t, StatusName as u };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { zn as LooseLiteral } from "./object-Blq0Amdv.cjs";
18
+ import { n as HTTP_STATUS_DATA } from "./constants-qm8FafmD.cjs";
19
+
20
+ //#region src/types/http-status.d.ts
21
+ /** Mapped type of HTTP status entries */
22
+ type $HttpStatusMap = (typeof HTTP_STATUS_DATA)[number];
23
+ /** HTTP status name variants: `name` or `readableName` */
24
+ type $StatusNameVar = 'name' | 'readableName';
25
+ /** * Categories of HTTP status codes: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */
26
+ type StatusCategory = $HttpStatusMap['category'];
27
+ /** - Extracts standard HTTP status codes by the given `Category` name. Defaults to all {@link StatusCategory categories}. */
28
+ type HttpStatusCode<Category extends StatusCategory = StatusCategory> = $HttpStatusMap extends infer Target ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target['code'] : never : never : never;
29
+ /** Standard HTTP Status Code, e.g. `404`, `500` etc. + any number */
30
+ type StatusCode = LooseLiteral<HttpStatusCode>;
31
+ /**
32
+ * - Extracts standard HTTP status names filtered by {@link $StatusNameVar variant} and {@link StatusCategory category}.
33
+ * - Defaults to all `variants` and `categories`.
34
+ *
35
+ * @remarks
36
+ * - `Name` selects either the `name` (CONSTANT_CASE) or `readableName` (Title Case).
37
+ * - `Category` restricts results to the chosen HTTP status {@link StatusCategory category}.
38
+ * - Produces a union of all matching literal status name values.
39
+ */
40
+ type HttpStatusName<Name extends $StatusNameVar = $StatusNameVar, Category extends StatusCategory = StatusCategory> = $HttpStatusMap extends infer Target ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target[Name] : never : never : never;
41
+ /** Standard HTTP status name in `CONSTANT_CASE`, e.g. `"INTERNAL_SERVER_ERROR"` + any string */
42
+ type StatusName = LooseLiteral<HttpStatusName>;
43
+ /** HTTP status name (`CONSTANT_CASE`) in {@link StatusEntry} interface */
44
+ type EntryStatusName = LooseLiteral<HttpStatusName<'name'>>;
45
+ /** HTTP status name (`Title Case`) in {@link StatusEntry} interface */
46
+ type EntryReadableName = LooseLiteral<HttpStatusName<'readableName'>>;
47
+ /** * Shape of an HTTP status entry. */
48
+ interface StatusEntry {
49
+ /** HTTP Status Code, e.g. `404`, `500` etc. */
50
+ code: StatusCode;
51
+ /** HTTP status name in `CONSTANT_CASE`, e.g. `"NOT_FOUND"`, `"INTERNAL_SERVER_ERROR"` */
52
+ name: EntryStatusName;
53
+ /** HTTP status name in `Title Case` form, e.g. `"Not Found"`, `"Internal Server Error"` */
54
+ readableName: EntryReadableName;
55
+ /** Link to full `MDN` Docs if available */
56
+ link?: string;
57
+ /** Short message, Can override using `httpStatus.setMessage` method */
58
+ message: string;
59
+ /** A brief description of the status code */
60
+ description: string;
61
+ /** The type of HTTP Status: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */
62
+ category: StatusCategory;
63
+ }
64
+ //#endregion
65
+ export { HttpStatusCode as a, StatusCode as c, EntryStatusName as i, StatusEntry as l, $StatusNameVar as n, HttpStatusName as o, EntryReadableName as r, StatusCategory as s, $HttpStatusMap as t, StatusName as u };
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_constants = require('./constants-BIBDKY1u.cjs');
19
+
20
+ //#region src/http-status/HttpStatus.ts
21
+ /**
22
+ * @class Utility class for retrieving and managing HTTP status codes with rich MDN-based metadata.
23
+ *
24
+ * @remarks
25
+ * - Supports lookup by code or name (both `SOME_NAME` and `Some Name` formats).
26
+ * - Allows adding custom codes and overriding messages for existing ones.
27
+ * - Provides pre-grouped categories for quick filtering (see {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus#groups-static-property HttpStatus.Groups}).
28
+ * - Intended to be reusable — create multiple instances if you want separate registries.
29
+ *
30
+ * @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/misc/httpStatus httpStatus} for the default preloaded singleton instance.
31
+ *
32
+ * @example
33
+ * // Using the class directly
34
+ * const customStatus = new HttpStatus();
35
+ * customStatus.addCode({
36
+ * code: 799,
37
+ * name: 'CUSTOM_ERROR',
38
+ * readableName: 'Custom Error',
39
+ * message: 'Something custom happened',
40
+ * description: 'This is an example of a user-defined HTTP status.',
41
+ * category: 'clientError'
42
+ * });
43
+ *
44
+ * console.log(customStatus.getByCode(799)?.readableName);
45
+ * // "Custom Error"
46
+ *
47
+ * console.log(customStatus.getByCode(404)?.name);
48
+ * // "NOT_FOUND"
49
+ *
50
+ * console.log(customStatus.getByCode(404)?.message);
51
+ * // "Not Found"
52
+ */
53
+ var HttpStatus = class HttpStatus {
54
+ #codesByNumber;
55
+ #codesByName;
56
+ /**
57
+ * * Static category groups for quick reference.
58
+ * @remarks Populated at runtime from default and the provided data.
59
+ */
60
+ static Groups = {
61
+ informational: [],
62
+ success: [],
63
+ redirection: [],
64
+ clientError: [],
65
+ serverError: []
66
+ };
67
+ constructor() {
68
+ this.#codesByNumber = /* @__PURE__ */ new Map();
69
+ this.#codesByName = /* @__PURE__ */ new Map();
70
+ for (const entry of require_constants.HTTP_STATUS_DATA) {
71
+ this.#storeEntry(entry);
72
+ HttpStatus.Groups[entry.category].push(entry.code);
73
+ }
74
+ }
75
+ /** * Get status entry by numeric HTTP code. */
76
+ getByCode(code) {
77
+ return this.#codesByNumber.get(code);
78
+ }
79
+ /** * Get status entry by name (either as `SOME_NAME` or `Some Name`). */
80
+ getByName(name) {
81
+ return this.#codesByName.get(name);
82
+ }
83
+ /**
84
+ * * Override the short message of an existing code.
85
+ * @param code HTTP status code.
86
+ * @param newMessage Custom message.
87
+ * @returns `true` if updated, `false` if code not found.
88
+ */
89
+ setMessage(code, newMessage) {
90
+ const entry = this.#codesByNumber.get(code);
91
+ if (!entry) return false;
92
+ else {
93
+ entry.message = newMessage;
94
+ return true;
95
+ }
96
+ }
97
+ /**
98
+ * * Add one or more new HTTP status code entries.
99
+ *
100
+ * @remarks
101
+ * - New entries are compared **by their `code` value** to determine uniqueness.
102
+ * - If a code already exists, it will be skipped and not overwritten.
103
+ * - Returns `true` if at least one code was successfully added.
104
+ * - Returns `false` if all provided codes already exist.
105
+ *
106
+ * @param entries One or more status entries to add.
107
+ * @returns `true` if at least one code was added, otherwise `false`.
108
+ */
109
+ addCode(...entries) {
110
+ let added = false;
111
+ for (const entry of entries) if (!this.#codesByNumber.has(entry.code)) {
112
+ this.#storeEntry(entry);
113
+ HttpStatus.Groups[entry.category].push(entry.code);
114
+ added = true;
115
+ }
116
+ return added;
117
+ }
118
+ /**
119
+ * * Add/override one or more HTTP status code entries.
120
+ *
121
+ * @remarks New entries use their `code` value as the comparison key and will overwrite existing ones.
122
+ *
123
+ * @param entries One or more status entries to add/override.
124
+ * @returns The modified instance with the newly added/updated entries.
125
+ */
126
+ addOrOverrideCode(...entries) {
127
+ for (const entry of entries) {
128
+ this.#storeEntry(entry);
129
+ HttpStatus.Groups[entry.category].push(entry.code);
130
+ }
131
+ return this;
132
+ }
133
+ /**
134
+ * * List all codes, optionally filtered by category.
135
+ * @param category Optional category filter.
136
+ * @returns Array of status entries.
137
+ */
138
+ list(category) {
139
+ const entries = [...this.#codesByNumber.values()];
140
+ if (!category) return entries;
141
+ else return entries.filter((entry) => entry.category === category);
142
+ }
143
+ /** * Internal helper to store an entry in all lookup maps. */
144
+ #storeEntry(entry) {
145
+ this.#codesByNumber.set(entry.code, { ...entry });
146
+ this.#codesByName.set(entry.name, { ...entry });
147
+ this.#codesByName.set(entry.readableName, { ...entry });
148
+ }
149
+ };
150
+ /**
151
+ * * Default singleton instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus HttpStatus} class.
152
+ *
153
+ * @remarks
154
+ * - Preloaded with all MDN-based HTTP status codes.
155
+ * - Useful when you do not need multiple independent registries.
156
+ * - Provides immediate access to lookups, category groupings, and
157
+ * mutation methods without manual instantiation.
158
+ *
159
+ * @example
160
+ * import { httpStatus } from 'nhb-toolbox';
161
+ *
162
+ * console.log(httpStatus.getByCode(404)?.readableName);
163
+ * // "Not Found"
164
+ *
165
+ * httpStatus.setMessage(404, 'This page is gone');
166
+ * console.log(httpStatus.getByCode(404)?.message);
167
+ * // "This page is gone"
168
+ */
169
+ const httpStatus = new HttpStatus();
170
+
171
+ //#endregion
172
+ exports.HttpStatus = HttpStatus;
173
+ exports.httpStatus = httpStatus;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { $ as Maybe } from "./object-Blq0Amdv.cjs";
18
+ import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "./http-status-U_3MtoGb.cjs";
19
+
20
+ //#region src/http-status/HttpStatus.d.ts
21
+ /**
22
+ * @class Utility class for retrieving and managing HTTP status codes with rich MDN-based metadata.
23
+ *
24
+ * @remarks
25
+ * - Supports lookup by code or name (both `SOME_NAME` and `Some Name` formats).
26
+ * - Allows adding custom codes and overriding messages for existing ones.
27
+ * - Provides pre-grouped categories for quick filtering (see {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus#groups-static-property HttpStatus.Groups}).
28
+ * - Intended to be reusable — create multiple instances if you want separate registries.
29
+ *
30
+ * @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/misc/httpStatus httpStatus} for the default preloaded singleton instance.
31
+ *
32
+ * @example
33
+ * // Using the class directly
34
+ * const customStatus = new HttpStatus();
35
+ * customStatus.addCode({
36
+ * code: 799,
37
+ * name: 'CUSTOM_ERROR',
38
+ * readableName: 'Custom Error',
39
+ * message: 'Something custom happened',
40
+ * description: 'This is an example of a user-defined HTTP status.',
41
+ * category: 'clientError'
42
+ * });
43
+ *
44
+ * console.log(customStatus.getByCode(799)?.readableName);
45
+ * // "Custom Error"
46
+ *
47
+ * console.log(customStatus.getByCode(404)?.name);
48
+ * // "NOT_FOUND"
49
+ *
50
+ * console.log(customStatus.getByCode(404)?.message);
51
+ * // "Not Found"
52
+ */
53
+ declare class HttpStatus {
54
+ #private;
55
+ /**
56
+ * * Static category groups for quick reference.
57
+ * @remarks Populated at runtime from default and the provided data.
58
+ */
59
+ static Groups: Record<StatusCategory, StatusCode[]>;
60
+ constructor();
61
+ /**
62
+ * * Get status entry by standard numeric HTTP code.
63
+ * @param code Standard HTTP status code.
64
+ * @returns Matching standard status entry.
65
+ */
66
+ getByCode(code: HttpStatusCode): StatusEntry;
67
+ /**
68
+ * * Get status entry by numeric HTTP code.
69
+ * @param code HTTP status code.
70
+ * @returns Matching status entry or `undefined` if not found.
71
+ */
72
+ getByCode(code: StatusCode): Maybe<StatusEntry>;
73
+ /**
74
+ * * Get status entry by standard name (either as `SOME_NAME` or `Some Name`).
75
+ * @param name Standard status name either as `SOME_NAME` or `Some Name`.
76
+ * @returns Matching standard status entry.
77
+ */
78
+ getByName(name: HttpStatusName): StatusEntry;
79
+ /**
80
+ * * Get status entry by name (either as `SOME_NAME` or `Some Name`).
81
+ * @param name Status name either as `SOME_NAME` or `Some Name`.
82
+ * @returns Matching status entry or `undefined` if not found.
83
+ */
84
+ getByName(name: StatusName): Maybe<StatusEntry>;
85
+ /**
86
+ * * Override the short message of an existing code.
87
+ * @param code HTTP status code.
88
+ * @param newMessage Custom message.
89
+ * @returns `true` if updated, `false` if code not found.
90
+ */
91
+ setMessage(code: StatusCode, newMessage: string): boolean;
92
+ /**
93
+ * * Add one or more new HTTP status code entries.
94
+ *
95
+ * @remarks
96
+ * - New entries are compared **by their `code` value** to determine uniqueness.
97
+ * - If a code already exists, it will be skipped and not overwritten.
98
+ * - Returns `true` if at least one code was successfully added.
99
+ * - Returns `false` if all provided codes already exist.
100
+ *
101
+ * @param entries One or more status entries to add.
102
+ * @returns `true` if at least one code was added, otherwise `false`.
103
+ */
104
+ addCode(...entries: StatusEntry[]): boolean;
105
+ /**
106
+ * * Add/override one or more HTTP status code entries.
107
+ *
108
+ * @remarks New entries use their `code` value as the comparison key and will overwrite existing ones.
109
+ *
110
+ * @param entries One or more status entries to add/override.
111
+ * @returns The modified instance with the newly added/updated entries.
112
+ */
113
+ addOrOverrideCode(...entries: StatusEntry[]): HttpStatus;
114
+ /**
115
+ * * List all codes, optionally filtered by category.
116
+ * @param category Optional category filter.
117
+ * @returns Array of status entries.
118
+ */
119
+ list(category?: StatusCategory): StatusEntry[];
120
+ }
121
+ /**
122
+ * * Default singleton instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus HttpStatus} class.
123
+ *
124
+ * @remarks
125
+ * - Preloaded with all MDN-based HTTP status codes.
126
+ * - Useful when you do not need multiple independent registries.
127
+ * - Provides immediate access to lookups, category groupings, and
128
+ * mutation methods without manual instantiation.
129
+ *
130
+ * @example
131
+ * import { httpStatus } from 'nhb-toolbox';
132
+ *
133
+ * console.log(httpStatus.getByCode(404)?.readableName);
134
+ * // "Not Found"
135
+ *
136
+ * httpStatus.setMessage(404, 'This page is gone');
137
+ * console.log(httpStatus.getByCode(404)?.message);
138
+ * // "This page is gone"
139
+ */
140
+ declare const httpStatus: HttpStatus;
141
+ //#endregion
142
+ export { HttpStatus, httpStatus };
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { $ as Maybe } from "./object-B0TV3eHx.mjs";
18
+ import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "./http-status-BAZdtr7-.mjs";
19
+
20
+ //#region src/http-status/HttpStatus.d.ts
21
+ /**
22
+ * @class Utility class for retrieving and managing HTTP status codes with rich MDN-based metadata.
23
+ *
24
+ * @remarks
25
+ * - Supports lookup by code or name (both `SOME_NAME` and `Some Name` formats).
26
+ * - Allows adding custom codes and overriding messages for existing ones.
27
+ * - Provides pre-grouped categories for quick filtering (see {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus#groups-static-property HttpStatus.Groups}).
28
+ * - Intended to be reusable — create multiple instances if you want separate registries.
29
+ *
30
+ * @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/misc/httpStatus httpStatus} for the default preloaded singleton instance.
31
+ *
32
+ * @example
33
+ * // Using the class directly
34
+ * const customStatus = new HttpStatus();
35
+ * customStatus.addCode({
36
+ * code: 799,
37
+ * name: 'CUSTOM_ERROR',
38
+ * readableName: 'Custom Error',
39
+ * message: 'Something custom happened',
40
+ * description: 'This is an example of a user-defined HTTP status.',
41
+ * category: 'clientError'
42
+ * });
43
+ *
44
+ * console.log(customStatus.getByCode(799)?.readableName);
45
+ * // "Custom Error"
46
+ *
47
+ * console.log(customStatus.getByCode(404)?.name);
48
+ * // "NOT_FOUND"
49
+ *
50
+ * console.log(customStatus.getByCode(404)?.message);
51
+ * // "Not Found"
52
+ */
53
+ declare class HttpStatus {
54
+ #private;
55
+ /**
56
+ * * Static category groups for quick reference.
57
+ * @remarks Populated at runtime from default and the provided data.
58
+ */
59
+ static Groups: Record<StatusCategory, StatusCode[]>;
60
+ constructor();
61
+ /**
62
+ * * Get status entry by standard numeric HTTP code.
63
+ * @param code Standard HTTP status code.
64
+ * @returns Matching standard status entry.
65
+ */
66
+ getByCode(code: HttpStatusCode): StatusEntry;
67
+ /**
68
+ * * Get status entry by numeric HTTP code.
69
+ * @param code HTTP status code.
70
+ * @returns Matching status entry or `undefined` if not found.
71
+ */
72
+ getByCode(code: StatusCode): Maybe<StatusEntry>;
73
+ /**
74
+ * * Get status entry by standard name (either as `SOME_NAME` or `Some Name`).
75
+ * @param name Standard status name either as `SOME_NAME` or `Some Name`.
76
+ * @returns Matching standard status entry.
77
+ */
78
+ getByName(name: HttpStatusName): StatusEntry;
79
+ /**
80
+ * * Get status entry by name (either as `SOME_NAME` or `Some Name`).
81
+ * @param name Status name either as `SOME_NAME` or `Some Name`.
82
+ * @returns Matching status entry or `undefined` if not found.
83
+ */
84
+ getByName(name: StatusName): Maybe<StatusEntry>;
85
+ /**
86
+ * * Override the short message of an existing code.
87
+ * @param code HTTP status code.
88
+ * @param newMessage Custom message.
89
+ * @returns `true` if updated, `false` if code not found.
90
+ */
91
+ setMessage(code: StatusCode, newMessage: string): boolean;
92
+ /**
93
+ * * Add one or more new HTTP status code entries.
94
+ *
95
+ * @remarks
96
+ * - New entries are compared **by their `code` value** to determine uniqueness.
97
+ * - If a code already exists, it will be skipped and not overwritten.
98
+ * - Returns `true` if at least one code was successfully added.
99
+ * - Returns `false` if all provided codes already exist.
100
+ *
101
+ * @param entries One or more status entries to add.
102
+ * @returns `true` if at least one code was added, otherwise `false`.
103
+ */
104
+ addCode(...entries: StatusEntry[]): boolean;
105
+ /**
106
+ * * Add/override one or more HTTP status code entries.
107
+ *
108
+ * @remarks New entries use their `code` value as the comparison key and will overwrite existing ones.
109
+ *
110
+ * @param entries One or more status entries to add/override.
111
+ * @returns The modified instance with the newly added/updated entries.
112
+ */
113
+ addOrOverrideCode(...entries: StatusEntry[]): HttpStatus;
114
+ /**
115
+ * * List all codes, optionally filtered by category.
116
+ * @param category Optional category filter.
117
+ * @returns Array of status entries.
118
+ */
119
+ list(category?: StatusCategory): StatusEntry[];
120
+ }
121
+ /**
122
+ * * Default singleton instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/HttpStatus HttpStatus} class.
123
+ *
124
+ * @remarks
125
+ * - Preloaded with all MDN-based HTTP status codes.
126
+ * - Useful when you do not need multiple independent registries.
127
+ * - Provides immediate access to lookups, category groupings, and
128
+ * mutation methods without manual instantiation.
129
+ *
130
+ * @example
131
+ * import { httpStatus } from 'nhb-toolbox';
132
+ *
133
+ * console.log(httpStatus.getByCode(404)?.readableName);
134
+ * // "Not Found"
135
+ *
136
+ * httpStatus.setMessage(404, 'This page is gone');
137
+ * console.log(httpStatus.getByCode(404)?.message);
138
+ * // "This page is gone"
139
+ */
140
+ declare const httpStatus: HttpStatus;
141
+ //#endregion
142
+ export { HttpStatus, httpStatus };