@rzl-zone/utils-js 3.0.2-beta.2 → 3.1.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 (198) hide show
  1. package/README.md +56 -27
  2. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
  3. package/dist/any-BmdI8UbK.d.ts +56 -56
  4. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
  5. package/dist/assertions/index.cjs +1 -1
  6. package/dist/assertions/index.d.ts +398 -418
  7. package/dist/assertions/index.js +1 -1
  8. package/dist/chunk-26XIKDJI.cjs +1 -0
  9. package/dist/chunk-2NWHDDM5.js +1 -0
  10. package/dist/chunk-2UIRWYE3.js +1 -0
  11. package/dist/chunk-3KBHD3BS.cjs +1 -0
  12. package/dist/chunk-4HD2O5A4.js +1 -0
  13. package/dist/chunk-5C2SMIGX.cjs +1 -0
  14. package/dist/chunk-5I2B5DOG.js +1 -0
  15. package/dist/chunk-6HQDHIOD.js +1 -0
  16. package/dist/chunk-735HJXBT.cjs +1 -0
  17. package/dist/chunk-7BXIZM57.cjs +1 -0
  18. package/dist/chunk-7KJBDGEP.js +1 -0
  19. package/dist/chunk-7U44T63D.cjs +1 -0
  20. package/dist/chunk-AJ65QFV2.js +1 -0
  21. package/dist/chunk-APHDUCVQ.js +1 -0
  22. package/dist/chunk-BSVZRN7C.js +1 -0
  23. package/dist/chunk-C6JFHUR2.cjs +1 -0
  24. package/dist/chunk-CPLBRGST.js +1 -0
  25. package/dist/chunk-CTBRLEOG.js +1 -0
  26. package/dist/chunk-DUK2K4FB.js +1 -0
  27. package/dist/chunk-DVMHRLKP.cjs +1 -0
  28. package/dist/chunk-E63WVPZE.cjs +1 -0
  29. package/dist/chunk-EBMHQW7X.cjs +1 -0
  30. package/dist/chunk-EGNZCW4K.js +1 -0
  31. package/dist/chunk-FEKDB32T.js +1 -0
  32. package/dist/chunk-FIAAX3UE.js +1 -0
  33. package/dist/chunk-FUS3DVLB.cjs +1 -0
  34. package/dist/chunk-GGRMHIFJ.cjs +1 -0
  35. package/dist/chunk-HQ5GQTEE.js +1 -0
  36. package/dist/chunk-I5X5IN4H.js +1 -0
  37. package/dist/chunk-I7YGXQPI.cjs +1 -0
  38. package/dist/chunk-INUFZJLX.cjs +1 -0
  39. package/dist/chunk-IREHUBF7.js +1 -0
  40. package/dist/chunk-J2RGTPGK.cjs +1 -0
  41. package/dist/chunk-KHO2SBNA.cjs +1 -0
  42. package/dist/chunk-KXIXXSWX.cjs +1 -0
  43. package/dist/chunk-LBMEEJWA.js +1 -0
  44. package/dist/chunk-MC3LXMCQ.js +1 -0
  45. package/dist/chunk-MMSYCIJ2.cjs +1 -1
  46. package/dist/chunk-NU3N4WHD.cjs +1 -0
  47. package/dist/chunk-ODZQXH7E.cjs +1 -0
  48. package/dist/chunk-ONZFBJVW.js +1 -0
  49. package/dist/chunk-PXDRHFIE.js +1 -0
  50. package/dist/chunk-Q6NHYWVX.js +1 -0
  51. package/dist/chunk-QNKGP5DY.js +1 -0
  52. package/dist/chunk-S6Z6I2EG.cjs +1 -0
  53. package/dist/chunk-SMADKXZE.js +1 -0
  54. package/dist/chunk-TSLYDPBJ.js +1 -0
  55. package/dist/chunk-TVXADXCC.cjs +1 -0
  56. package/dist/chunk-UDA26MCU.cjs +1 -0
  57. package/dist/chunk-UET567YM.cjs +1 -0
  58. package/dist/chunk-VEYMQ3UA.js +1 -0
  59. package/dist/chunk-W2W3L2M5.js +1 -0
  60. package/dist/chunk-WBWTXKMC.cjs +1 -0
  61. package/dist/chunk-WVSPXFTY.js +1 -0
  62. package/dist/chunk-XC2PYCT4.cjs +1 -0
  63. package/dist/chunk-XIXA5KDF.cjs +1 -0
  64. package/dist/chunk-Y4O5KZF6.cjs +1 -0
  65. package/dist/chunk-YRM7IJLX.js +1 -0
  66. package/dist/chunk-YT3MSZKK.cjs +1 -0
  67. package/dist/chunk-YXHCULSO.cjs +1 -0
  68. package/dist/chunk-YZR5OGJA.cjs +1 -0
  69. package/dist/chunk-Z4DXK7A6.cjs +1 -0
  70. package/dist/chunk-ZXIWDFEQ.js +1 -0
  71. package/dist/conversions/index.cjs +1 -1
  72. package/dist/conversions/index.d.ts +1368 -1515
  73. package/dist/conversions/index.js +1 -1
  74. package/dist/env/index.cjs +1 -1
  75. package/dist/env/index.d.ts +14 -17
  76. package/dist/env/index.js +1 -1
  77. package/dist/events/index.cjs +1 -1
  78. package/dist/events/index.d.ts +111 -108
  79. package/dist/events/index.js +1 -1
  80. package/dist/extends-Bk_SBGdT.d.ts +367 -0
  81. package/dist/formatting/index.cjs +1 -1
  82. package/dist/formatting/index.d.ts +878 -840
  83. package/dist/formatting/index.js +1 -1
  84. package/dist/generator/index.cjs +1 -1
  85. package/dist/generator/index.d.ts +173 -150
  86. package/dist/generator/index.js +1 -1
  87. package/dist/if-CvT4R7Kh.d.ts +16 -16
  88. package/dist/is-array-Cymwrsmm.d.ts +1119 -0
  89. package/dist/isPlainObject-BVhBAPHX.d.ts +169 -0
  90. package/dist/never-BfayMBF9.d.ts +64 -64
  91. package/dist/next/index.cjs +1 -8
  92. package/dist/next/index.d.ts +196 -176
  93. package/dist/next/index.js +1 -8
  94. package/dist/next/server/index.cjs +1 -2
  95. package/dist/next/server/index.d.ts +26 -40
  96. package/dist/next/server/index.js +1 -2
  97. package/dist/nils-DMz3kU7M.d.ts +155 -155
  98. package/dist/omit-VvmIsZmX.d.ts +25 -25
  99. package/dist/operations/index.cjs +1 -1
  100. package/dist/operations/index.d.ts +121 -176
  101. package/dist/operations/index.js +1 -1
  102. package/dist/or-DyZCRvaU.d.ts +89 -0
  103. package/dist/parsers/index.cjs +1 -1
  104. package/dist/parsers/index.d.ts +35 -36
  105. package/dist/parsers/index.js +1 -1
  106. package/dist/predicates/index.cjs +1 -1
  107. package/dist/predicates/index.d.ts +1797 -1677
  108. package/dist/predicates/index.js +1 -1
  109. package/dist/prettify-C4xLcYOP.d.ts +328 -328
  110. package/dist/promise/index.cjs +1 -1
  111. package/dist/promise/index.d.ts +29 -38
  112. package/dist/promise/index.js +1 -1
  113. package/dist/rzl-utils.global.js +1 -4
  114. package/dist/string-XA-til3C.d.ts +351 -0
  115. package/dist/strings/index.cjs +1 -1
  116. package/dist/strings/index.d.ts +712 -787
  117. package/dist/strings/index.js +1 -1
  118. package/dist/tailwind/index.cjs +1 -0
  119. package/dist/tailwind/index.d.ts +565 -0
  120. package/dist/tailwind/index.js +1 -0
  121. package/dist/type-data-DDs-u2kq.d.ts +241 -241
  122. package/dist/types/index.d.ts +3266 -3266
  123. package/dist/urls/index.cjs +1 -1
  124. package/dist/urls/index.d.ts +384 -409
  125. package/dist/urls/index.js +1 -1
  126. package/package.json +61 -18
  127. package/dist/array-CIZRbqTF.d.ts +0 -223
  128. package/dist/chunk-2TRAPBZ7.cjs +0 -1
  129. package/dist/chunk-3D74QO5D.cjs +0 -1
  130. package/dist/chunk-4DK3RCC4.js +0 -2
  131. package/dist/chunk-4JOQ45HL.js +0 -1
  132. package/dist/chunk-55CZALRS.js +0 -1
  133. package/dist/chunk-56QBKKRE.js +0 -1
  134. package/dist/chunk-5JFV3GDE.cjs +0 -4
  135. package/dist/chunk-5SZUSNGZ.js +0 -1
  136. package/dist/chunk-62HX5Z45.cjs +0 -1
  137. package/dist/chunk-7NA6DUHR.cjs +0 -2
  138. package/dist/chunk-7YWAQOA4.cjs +0 -1
  139. package/dist/chunk-BVPMMWDL.cjs +0 -1
  140. package/dist/chunk-BYZAD3XN.cjs +0 -1
  141. package/dist/chunk-CEFYHEM4.cjs +0 -1
  142. package/dist/chunk-CN53M4QZ.cjs +0 -1
  143. package/dist/chunk-D47MHBSD.cjs +0 -1
  144. package/dist/chunk-DGH75GJD.js +0 -1
  145. package/dist/chunk-E5NUI7PN.js +0 -1
  146. package/dist/chunk-ELDDNERR.js +0 -1
  147. package/dist/chunk-EXZ47NOW.js +0 -1
  148. package/dist/chunk-FDITZ5C6.cjs +0 -1
  149. package/dist/chunk-FF76ISQ2.js +0 -1
  150. package/dist/chunk-FIEZKTAZ.cjs +0 -1
  151. package/dist/chunk-FSSV24W7.cjs +0 -1
  152. package/dist/chunk-GCGU2WB7.js +0 -1
  153. package/dist/chunk-GECI2YBP.js +0 -1
  154. package/dist/chunk-GQE4OVHC.cjs +0 -1
  155. package/dist/chunk-GRVZXQXL.cjs +0 -1
  156. package/dist/chunk-I4AVNHPA.cjs +0 -1
  157. package/dist/chunk-JFRL7NKU.js +0 -4
  158. package/dist/chunk-JWHM3WZQ.cjs +0 -1
  159. package/dist/chunk-KCQDDZJE.cjs +0 -1
  160. package/dist/chunk-L54ZPSYJ.js +0 -1
  161. package/dist/chunk-LVKAYEZ4.js +0 -1
  162. package/dist/chunk-MBDWTK54.cjs +0 -1
  163. package/dist/chunk-MNGGDB2G.js +0 -1
  164. package/dist/chunk-MY7BA4GI.cjs +0 -1
  165. package/dist/chunk-N2IJPIND.cjs +0 -1
  166. package/dist/chunk-NIMNTEGV.js +0 -1
  167. package/dist/chunk-NNM7QCNB.js +0 -1
  168. package/dist/chunk-PUQXRLZH.cjs +0 -1
  169. package/dist/chunk-PVJF2JHM.js +0 -1
  170. package/dist/chunk-QCFXEUKL.js +0 -1
  171. package/dist/chunk-QFCGBBSY.js +0 -1
  172. package/dist/chunk-QQYAUPSK.cjs +0 -1
  173. package/dist/chunk-RN3TP3S3.js +0 -1
  174. package/dist/chunk-RV2VULM7.cjs +0 -1
  175. package/dist/chunk-SW6HYEW7.cjs +0 -1
  176. package/dist/chunk-SYJC7UAW.js +0 -1
  177. package/dist/chunk-TC4VBE4Y.cjs +0 -1
  178. package/dist/chunk-TUXDINHF.cjs +0 -1
  179. package/dist/chunk-U5Y2FXMN.cjs +0 -1
  180. package/dist/chunk-UUPQI6ND.cjs +0 -1
  181. package/dist/chunk-VYCGZ2S6.js +0 -1
  182. package/dist/chunk-W5EDKJK3.js +0 -1
  183. package/dist/chunk-WHAVUFEU.js +0 -1
  184. package/dist/chunk-XCFIOTCV.js +0 -1
  185. package/dist/chunk-XE27XPJR.js +0 -1
  186. package/dist/chunk-XH6MCRLP.js +0 -1
  187. package/dist/chunk-XVB3ZZEB.js +0 -1
  188. package/dist/chunk-ZBSIGJFO.cjs +0 -1
  189. package/dist/chunk-ZYAML74V.js +0 -1
  190. package/dist/extends-Mp81Hq9-.d.ts +0 -145
  191. package/dist/index.cjs +0 -1
  192. package/dist/index.d.ts +0 -1
  193. package/dist/index.js +0 -1
  194. package/dist/is-array-Ckm_47hw.d.ts +0 -1557
  195. package/dist/isPlainObject-BKYaI6a8.d.ts +0 -182
  196. package/dist/stylings/index.cjs +0 -1
  197. package/dist/stylings/index.d.ts +0 -49
  198. package/dist/stylings/index.js +0 -1
@@ -0,0 +1,169 @@
1
+ import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';
2
+ /** Types for **{@link getPreciseType}**. */
3
+ type GetPreciseTypeOptions={
4
+ /** -------------------------------------------------------
5
+ * * ***Specifies the format in which the returned string type should be transformed.***
6
+ * -------------------------------------------------------
7
+ *
8
+ * ℹ️ For special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`), which will remain unchanged.
9
+ * @default "toLowerCase"
10
+ *
11
+ * @description
12
+ * Supported formats:
13
+ * - `"toLowerCase"` (default) — converts all letters to lowercase.
14
+ * - ➔ `"result example type"`
15
+ * - `"toDotCase"` — words separated by dots.
16
+ * - ➔ `"result.example.type"`
17
+ * - `"toCamelCase"` — first word lowercase, subsequent words capitalized.
18
+ * - ➔ `"resultExampleType"`
19
+ * - `"toKebabCase"` — words separated by hyphens.
20
+ * - ➔ `"result-example-type"`
21
+ * - `"toSnakeCase"` — words separated by underscores.
22
+ * - ➔ `"result_example_type"`
23
+ * - `"toPascalCase"` — all words capitalized, no spaces.
24
+ * - ➔ `"ResultExampleType"`
25
+ * - `"toPascalCaseSpace"` — all words capitalized with spaces between words.
26
+ * - ➔ `"Result Example Type"`
27
+ * - `"slugify"` — URL-friendly slug (lowercase with hyphens).
28
+ * - ➔ `"result-example-type"`
29
+ *
30
+ * @note
31
+ * ⚠️ If an invalid value is provided, the function will automatically fallback to the default `"toLowerCase"`.
32
+ */
33
+ formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"|"toLowerCase";};
34
+ /** ----------------------------------------------------------
35
+ * * ***Utility-Predicate: `getPreciseType`.***
36
+ * ----------------------------------------------------------
37
+ * **Returns a detailed and normalized type string for the given value.**
38
+ * @description
39
+ * The returned string is human-readable _**toLowerCase**_ with spaces _***(by default)***_ or formatted according to the `options.formatCase` setting.
40
+ * - **Handles:**
41
+ * - Primitives (`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`)
42
+ * - Built-in objects (`Array`, `Map`, `Set`, `Error subclasses`, `Typed Arrays`, `etc`)
43
+ * - Objects created with `Object.create(null)`
44
+ * - Generator instances
45
+ * - Node.js `Buffer` instances
46
+ * - Proxy detection (returns `"Proxy"` if detected; detection is not 100% accurate)
47
+ * - Uses cached mapping table (`FIXES`) for known types to provide consistent naming
48
+ * - Falls back to constructor name or `Object.prototype.toString` tag
49
+ * @param {*} value - The value to detect the precise type of
50
+ * @param {GetPreciseTypeOptions} [options] - Optional configuration
51
+ * @param {GetPreciseTypeOptions["formatCase"]} [options.formatCase="toLowerCase"]
52
+ * Specifies how the returned type string should be formatted.
53
+ * - ⚠️ Special string literals in `SPECIAL_CASES`
54
+ * (`"-Infinity" | "Infinity" | "NaN"`) will remain
55
+ * unchanged even if a different `formatCase` is applied.
56
+ * @returns {string} The normalized and formatted type string
57
+ * @example
58
+ * getPreciseType(123); // ➔ "number"
59
+ * getPreciseType(null); // ➔ "null"
60
+ * getPreciseType(/regex/,{ formatCase: "toKebabCase" });
61
+ * // ➔ "reg-exp"
62
+ * getPreciseType(function* () {}, { formatCase: "toCamelCase" });
63
+ * // ➔ "generatorFunction"
64
+ * getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" });
65
+ * // ➔ "Async Function"
66
+ * getPreciseType(NaN, { formatCase: "toKebabCase" });
67
+ * // ➔ "NaN" (SPECIAL_CASES remain)
68
+ */
69
+ declare const getPreciseType:(value:unknown,options?:GetPreciseTypeOptions)=>string;type IsNumberOptions={
70
+ /** If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.
71
+ *
72
+ * @default false
73
+ */
74
+ includeNaN?:boolean;};
75
+ /** ---------------------------------------------------------
76
+ * * ***Type guard: `isNumber`.***
77
+ * ----------------------------------------------------------
78
+ * **Checks if a value is of type **`number`**.**
79
+ * - **Behavior:**
80
+ * - Uses `typeof value === "number"`.
81
+ * - By default, excludes **`NaN`**.
82
+ * - If `options.includeNaN` is `true`, then **`NaN`** is also considered valid.
83
+ * - Still considers `Infinity` and `-Infinity` as **numbers** (consistent with JavaScript).
84
+ * - **ℹ️ Note:**
85
+ * - To exclude `Infinity` and `-Infinity`, use **{@link isFinite | `isFinite`}** instead.
86
+ * @param {*} value - The value to check.
87
+ * @param {IsNumberOptions} [options] - Optional settings.
88
+ * @param {boolean} [options.includeNaN=false] If `true`, `NaN` will be considered a valid number, defaults to `false`, which excludes `NaN`.
89
+ * @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded).
90
+ * @example
91
+ * isNumber(42);
92
+ * // ➔ true
93
+ * isNumber(Infinity);
94
+ * // ➔ true
95
+ * isNumber(-Infinity);
96
+ * // ➔ true
97
+ * isNumber(NaN);
98
+ * // ➔ false (default)
99
+ * isNumber(NaN, { includeNaN: true });
100
+ * // ➔ true
101
+ * isNumber("42");
102
+ * // ➔ false
103
+ */
104
+ declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number;type HasKeys<T>=keyof T extends never?false:true;
105
+ /** ----------------------------------------------------------
106
+ * * ***Utility type: `IsPlainObjectResult`.***
107
+ * ----------------------------------------------------------
108
+ * **Represents the inferred type after asserting a value is a **plain object**.**
109
+ * - **Behavior:**
110
+ * - If `T` is `unknown`, the resulting type is `Record<PropertyKey, unknown> & T`.
111
+ * - If `T` is an object:
112
+ * - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`.
113
+ * - If it has no keys (`HasKeys<T>` checked by **{@link HasKeys}** is false), the result is `Record<PropertyKey, unknown> & T`.
114
+ * - Otherwise, the result is `T` itself.
115
+ * - For any other types, the result is `never`.
116
+ * @template T - The input type to be asserted as a plain object.
117
+ * @example
118
+ * ```ts
119
+ * type A = IsPlainObjectResult<unknown>;
120
+ * // ➔ Record<PropertyKey, unknown> & unknown
121
+ * type B = IsPlainObjectResult<{}>;
122
+ * // ➔ Record<PropertyKey, unknown> & {}
123
+ * type C = IsPlainObjectResult<{ foo: string }>;
124
+ * // ➔ { foo: string }
125
+ * type D = IsPlainObjectResult<Date>;
126
+ * // ➔ never
127
+ * ```
128
+ */
129
+ type IsPlainObjectResult<T>=unknown extends T?Record<PropertyKey,unknown>& T:T extends object?T extends NonPlainObject?never:HasKeys<T>extends false?Record<PropertyKey,unknown>& T:T:Extract<T,Record<PropertyKey,unknown>>;
130
+ /** ----------------------------------------------------------
131
+ * * ***Type guard: `isPlainObject`.***
132
+ * ----------------------------------------------------------
133
+ * **Checks if a value is a **plain-object**.**
134
+ * - **A plain object is:**
135
+ * - Created by the `Object` constructor, or
136
+ * - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
137
+ * - **✅ Returns `true` for:**
138
+ * - Empty object literals: `{}`
139
+ * - Objects with null prototype: `Object.create(null)`
140
+ * - **❌ Returns `false` for:**
141
+ * - Arrays (`[]`, `new Array()`)
142
+ * - Functions (regular, arrow, or class constructors)
143
+ * - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
144
+ * - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
145
+ * - `null` or `undefined`
146
+ * - Symbols
147
+ * - Class instances
148
+ * @template T - The type of the value being checked.
149
+ * @param {*} value - The value to check.
150
+ * @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`.
151
+ * @example
152
+ * isPlainObject({});
153
+ * // ➔ true
154
+ * isPlainObject(Object.create(null));
155
+ * // ➔ true
156
+ * isPlainObject(null);
157
+ * // ➔ false
158
+ * isPlainObject(() => {});
159
+ * // ➔ false
160
+ * isPlainObject([1, 2, 3]);
161
+ * // ➔ false
162
+ * isPlainObject(new Date());
163
+ * // ➔ false
164
+ * isPlainObject(new MyClass());
165
+ * // ➔ false
166
+ * isPlainObject(new String("x"));
167
+ * // ➔ false
168
+ */
169
+ declare function isPlainObject<T>(value:T):value is IsPlainObjectResult<T>;declare function isPlainObject<T>(value:T):value is NonNullable<Extract<T,Record<PropertyKey,unknown>>>;export{type GetPreciseTypeOptions as G,type IsNumberOptions as I,type IsPlainObjectResult as a,isPlainObject as b,getPreciseType as g,isNumber as i};
@@ -1,75 +1,75 @@
1
1
  import{I as If}from'./if-CvT4R7Kh.js';
2
2
  /** -------------------------------------------------------
3
- * * ***IsNever.***
4
- * -------------------------------------------------------
5
- * **Conditional**: returns `true` if `T` is `never`, otherwise `false`.
6
- *
7
- * @template T - Type to check.
8
- * @example
9
- * ```ts
10
- * type A = IsNever<never>; // ➔ true
11
- * type B = IsNever<true>; // ➔ false
12
- * ```
13
- */
3
+ * * ***IsNever.***
4
+ * -------------------------------------------------------
5
+ * **Conditional**: returns `true` if `T` is `never`, otherwise `false`.
6
+ *
7
+ * @template T - Type to check.
8
+ * @example
9
+ * ```ts
10
+ * type A = IsNever<never>; // ➔ true
11
+ * type B = IsNever<true>; // ➔ false
12
+ * ```
13
+ */
14
14
  type IsNever<T>=[T] extends [never]?true:false;
15
15
  /** -------------------------------------------------------
16
- * * ***IfNever.***
17
- * -------------------------------------------------------
18
- * **Conditional**: Selects one of two branches depending on whether `T` is `never`.
19
- * - Defaults: `IfTrue = true`, `IfFalse = false`.
20
- *
21
- * @template T - Type to check.
22
- * @template IfTrue - The branch type if `T` is `never`, (default: `true`).
23
- * @template IfFalse - The branch type if `T` is not `never`, (default: `false`).
24
- * @example
25
- * ```ts
26
- * type A = IfNever<never>;
27
- * // ➔ true
28
- * type B = IfNever<string>;
29
- * // ➔ false
30
- * type C = IfNever<never, 'valid', 'no'>;
31
- * // ➔ 'valid'
32
- * type D = IfNever<string, 'valid', 'no'>;
33
- * // ➔ 'no'
34
- * ```
35
- */
16
+ * * ***IfNever.***
17
+ * -------------------------------------------------------
18
+ * **Conditional**: Selects one of two branches depending on whether `T` is `never`.
19
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
20
+ *
21
+ * @template T - Type to check.
22
+ * @template IfTrue - The branch type if `T` is `never`, (default: `true`).
23
+ * @template IfFalse - The branch type if `T` is not `never`, (default: `false`).
24
+ * @example
25
+ * ```ts
26
+ * type A = IfNever<never>;
27
+ * // ➔ true
28
+ * type B = IfNever<string>;
29
+ * // ➔ false
30
+ * type C = IfNever<never, 'valid', 'no'>;
31
+ * // ➔ 'valid'
32
+ * type D = IfNever<string, 'valid', 'no'>;
33
+ * // ➔ 'no'
34
+ * ```
35
+ */
36
36
  type IfNever<T,IfTrue=true,IfFalse=false>=If<IsNever<T>,IfTrue,IfFalse>;
37
37
  /** -------------------------------------------------------
38
- * * ***NeverifyPropertiesOptions.***
39
- * -------------------------------------------------------
40
- * Configuration options for the ***{@link NeverifyProperties}*** type utility.
41
- *
42
- * @property makeOptional - Whether to make all properties optional.
43
- * - If `true`, resulting properties will be optional (`?`).
44
- * - Default: `false`.
45
- *
46
- * @example
47
- * ```ts
48
- * type Opt1 = NeverifyPropertiesOptions;
49
- * // ➔ { makeOptional: boolean }
50
- * ```
51
- */
38
+ * * ***NeverifyPropertiesOptions.***
39
+ * -------------------------------------------------------
40
+ * Configuration options for the ***{@link NeverifyProperties}*** type utility.
41
+ *
42
+ * @property makeOptional - Whether to make all properties optional.
43
+ * - If `true`, resulting properties will be optional (`?`).
44
+ * - Default: `false`.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * type Opt1 = NeverifyPropertiesOptions;
49
+ * // ➔ { makeOptional: boolean }
50
+ * ```
51
+ */
52
52
  type NeverifyPropertiesOptions={
53
53
  /** Whether to make all properties optional, defaultValue: `false`.
54
- *
55
- * @default false
56
- */
54
+ *
55
+ * @default false
56
+ */
57
57
  makeOptional:boolean;};
58
58
  /** -------------------------------------------------------
59
- * * ***NeverifyProperties.***
60
- * -------------------------------------------------------
61
- * Turns all properties of an object to type `never`.
62
- * - If `Options["makeOptional"]` is `true`, properties will be optional.
63
- *
64
- * @template T - Object type to transform.
65
- * @template Options - Configuration options (default: `{ makeOptional: false }`).
66
- * @example
67
- * ```ts
68
- * type A = NeverifyProperties<{ a: string; b: string }>;
69
- * // ➔ { a: never; b: never }
70
- *
71
- * type B = NeverifyProperties<{ a: string; b: string }, { makeOptional: true }>;
72
- * // ➔ { a?: never; b?: never }
73
- * ```
74
- */
59
+ * * ***NeverifyProperties.***
60
+ * -------------------------------------------------------
61
+ * Turns all properties of an object to type `never`.
62
+ * - If `Options["makeOptional"]` is `true`, properties will be optional.
63
+ *
64
+ * @template T - Object type to transform.
65
+ * @template Options - Configuration options (default: `{ makeOptional: false }`).
66
+ * @example
67
+ * ```ts
68
+ * type A = NeverifyProperties<{ a: string; b: string }>;
69
+ * // ➔ { a: never; b: never }
70
+ *
71
+ * type B = NeverifyProperties<{ a: string; b: string }, { makeOptional: true }>;
72
+ * // ➔ { a?: never; b?: never }
73
+ * ```
74
+ */
75
75
  type NeverifyProperties<T extends object,Options extends NeverifyPropertiesOptions={makeOptional:false;}>={[K in keyof T]:never;}extends infer Result?If<Options["makeOptional"],Partial<Result>,Result>:never;export type{IsNever as I,NeverifyProperties as N,IfNever as a,NeverifyPropertiesOptions as b};
@@ -1,8 +1 @@
1
- 'use strict';var chunk5JFV3GDE_cjs=require('../chunk-5JFV3GDE.cjs'),chunkN2IJPIND_cjs=require('../chunk-N2IJPIND.cjs'),chunk2TRAPBZ7_cjs=require('../chunk-2TRAPBZ7.cjs'),chunkBVPMMWDL_cjs=require('../chunk-BVPMMWDL.cjs');require('../chunk-PUQXRLZH.cjs');var chunkU5Y2FXMN_cjs=require('../chunk-U5Y2FXMN.cjs');require('../chunk-7YWAQOA4.cjs');var chunkCN53M4QZ_cjs=require('../chunk-CN53M4QZ.cjs');function C(e,t){if(!chunkCN53M4QZ_cjs.h(e)||chunk2TRAPBZ7_cjs.a(e))throw new TypeError(`\u274C 'generateRoute' Failed:
2
- - Invalid 'route' value.
3
- - Must be of type \`string\` and non-empty string, but received: "${chunkCN53M4QZ_cjs.E(e)}": \`${chunkU5Y2FXMN_cjs.c(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(chunkCN53M4QZ_cjs.m(t,{message:({validType:o})=>`\u274C 'generateRoute' Failed cause in route "${e}":
4
- - Missing or invalid parameters \`${o}\` for route: "${e}", must be of type \`${o}\` mapping parameters.`}),chunkCN53M4QZ_cjs.c(t))throw new TypeError(`\u274C 'generateRoute' Failed cause in route "${e}":
5
- - Missing parameters \`plain-object\` for route: "${e}".`);let n=["?","&","#","=","/","'",'"',"(",")","+",";","%","@",":"],r=[],s=Array.from(e.matchAll(/\[(\w+)\]/g)).map(o=>o[1]);for(let o of s){let i=t[o];if(!chunkCN53M4QZ_cjs.h(i)){r.push(`- Invalid parameter: "${o}" must be of type \`string\`, but received: \`${chunkCN53M4QZ_cjs.E(i)}\`.`);continue}if(chunk2TRAPBZ7_cjs.a(i)){r.push(`- Parameter "${o}" cannot be empty string.`);continue}let p=n.filter(g=>i.includes(g));if(/\s/.test(i)&&p.push("white-space(s)"),p.length>0){let g=p.map(a=>a==="`"?"backtick - (`)":`\`${a}\``);n.includes("white-space(s)")||n.push("white-space(s)");let c=n.map(a=>a==="`"?"backtick - (`)":`\`${a}\``);r.push(`- Parameter "${o}" contains invalid characters (${g.join(", ")}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters: (${c.join(", ")}).`);}}if(chunkCN53M4QZ_cjs.r(r))throw new Error(`\u274C 'generateRoute' Failed cause in route "${e}":
6
- ${r.join(`
7
- `)}.`);return e.replace(/\[(\w+)\]/g,(o,i)=>(chunkCN53M4QZ_cjs.p(t[i])?t[i]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")}var M=(e="",t)=>{try{let p=function(c,a){return `${c.replace(/\/+$/,"")}/${a.replace(/^\/+/,"")}`};var n=p;chunkBVPMMWDL_cjs.a(e,{message({currentType:c,validType:a}){return `First parameter \`pathname\` must be of type \`${a}\`, but received: \`${c}\`.`}}),chunkCN53M4QZ_cjs.f(t)||(t={});let{prefix:r="/api",withOrigin:s=!0}=t;if(!chunkCN53M4QZ_cjs.k(r)&&!chunkCN53M4QZ_cjs.h(r))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ${chunkCN53M4QZ_cjs.E(r)}.`);chunkCN53M4QZ_cjs.G(s,{message:({currentType:c,validType:a})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${a}\`, but received: \`${c}\`.`}),e=chunk5JFV3GDE_cjs.c(e),r=chunk5JFV3GDE_cjs.c(r);let o=r.endsWith("/")?r:r+"/";(e===r||e===r+"/"||e.startsWith(o))&&(e=e.slice(r.length),e=chunk5JFV3GDE_cjs.c(e));let i=U({suffix:r});return p(s?i:new URL(i).pathname,e).replace(/\/+$/,"")}catch(r){throw new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error:"+r)}};var U=({suffix:e="/"}={})=>{chunkBVPMMWDL_cjs.a(e,{message({currentType:t,validType:n}){return `Parameter \`suffix\` property of the first parameter must be of type \`${n}\`, but received: \`${t}\`.`}});try{let t=process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();if(t){t=chunkN2IJPIND_cjs.c(t);let s=new URL(t);!!!s.port&&process.env.NEXT_PUBLIC_PORT_BE&&(t=s.origin+chunk5JFV3GDE_cjs.d(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}));}else t="http://localhost"+chunk5JFV3GDE_cjs.d(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});e=chunkN2IJPIND_cjs.c(e).length?chunkN2IJPIND_cjs.c(e):"/";let n=new URL(t.replace(/\/+$/,"")).origin,r=e==="/"?"/":`${e.startsWith("/")?"":"/"}${e.replace(/\/+$/,"")}`;return `${n}${r}`}catch(t){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:"+t)}};var Z=()=>{try{let e=process.env.NEXT_PUBLIC_BASE_URL?.trim(),t=process.env.NEXT_PUBLIC_PORT_FE?.trim(),n=e||"http://localhost";n=chunkN2IJPIND_cjs.c(n).replace(/\/+$/,"");let r=/:\/\/[^/]+:\d+/.test(n);!r&&t?n+=chunk5JFV3GDE_cjs.d(t,{prefixColon:!0}):!r&&!e&&(n+=":3000");let s=new URL(n);return `${s.protocol}//${s.hostname}${s.port?`:${s.port}`:""}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:"+e)}};
8
- exports.createBeApiUrl=M;exports.generateRoute=C;exports.getBaseUrl=Z;exports.getBeApiUrl=U;
1
+ "use strict";var e=require("../chunk-S6Z6I2EG.cjs"),r=require("../chunk-XC2PYCT4.cjs"),t=require("../chunk-EBMHQW7X.cjs"),n=require("../chunk-Y4O5KZF6.cjs");require("../chunk-DVMHRLKP.cjs");var s=require("../chunk-E63WVPZE.cjs");require("../chunk-UDA26MCU.cjs");var i=require("../chunk-INUFZJLX.cjs");var a=({suffix:t="/"}={})=>{var s;n.assertIsString(t,{message:({currentType:e,validType:r})=>`Parameter \`suffix\` property of the first parameter must be of type \`${r}\`, but received: \`${e}\`.`});try{let n=null==(s=process.env.NEXT_PUBLIC_BACKEND_API_URL)?void 0:s.trim();if(n){n=r.removeSpaces(n);const t=new URL(n);!!!t.port&&process.env.NEXT_PUBLIC_PORT_BE&&(n=t.origin+e.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}))}else n="http://localhost"+e.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});t=r.removeSpaces(t).length?r.removeSpaces(t):"/";const i=new URL(n.replace(/\/+$/,"")).origin;return`${i}${"/"===t?"/":`${t.startsWith("/")?"":"/"}${t.replace(/\/+$/,"")}`}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:"+e)}};exports.createBeApiUrl=(r,t={})=>{try{let s=function(e,r){return`${e.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`};n.assertIsString(i.isNil(r)?"":r,{message:({currentType:e,validType:r})=>`First parameter (\`pathname\`) must be of type \`${r}\`, but received: \`${e}\`.`}),i.isPlainObject(t)||(t={});let{prefix:o="/api",withOrigin:c=!0}=t;if(!i.isUndefined(o)&&!i.isString(o))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${i.getPreciseType(o)}\`.`);i.assertIsBoolean(c,{message:({currentType:e,validType:r})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${r}\`, but received: \`${e}\`.`}),r=e.normalizePathname(r),o=e.normalizePathname(o);const p=o.endsWith("/")?o:o+"/";(r===o||r===o+"/"||r.startsWith(p))&&(r=r.slice(o.length),r=e.normalizePathname(r));const u=a({suffix:o});return s(c?u:new URL(u).pathname,r).replace(/\/+$/,"")}catch(e){throw i.isError(e)?e:new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error: "+new Error(String(e)).message.trim())}},exports.generateRoute=function(e,r){if(!i.isString(e)||t.isEmptyString(e))throw new TypeError(`❌ 'generateRoute' Failed:\n- Invalid 'route' value.\n- Must be of type \`string\` and non-empty string, but received: "${i.getPreciseType(e)}": \`${s.safeStableStringify(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(i.assertIsPlainObject(r,{message:({validType:r})=>`❌ 'generateRoute' Failed cause in route "${e}":\n- Missing or invalid parameters \`${r}\` for route: "${e}", must be of type \`${r}\` mapping parameters.`}),i.isNil(r))throw new TypeError(`❌ 'generateRoute' Failed cause in route "${e}":\n- Missing parameters \`plain-object\` for route: "${e}".`);const n=["?","&","#","=","/","'",'"',"(",")","+",";","%","@",":"],a=[],o=Array.from(e.matchAll(/\[(\w+)\]/g)).map(e=>e[1]);for(const e of o){const s=r[e];if(!i.isString(s)){a.push(`- Invalid parameter: "${e}" must be of type \`string\`, but received: \`${i.getPreciseType(s)}\`.`);continue}if(t.isEmptyString(s)){a.push(`- Parameter "${e}" cannot be empty string.`);continue}const o=n.filter(e=>s.includes(e));if(/\s/.test(s)&&o.push("white-space(s)"),o.length>0){const r=o.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);n.includes("white-space(s)")||n.push("white-space(s)");const t=n.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);a.push(`- Parameter "${e}" contains invalid characters (${r.join(", ")}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters: (${t.join(", ")}).`)}}if(i.isNonEmptyArray(a))throw new Error(`❌ 'generateRoute' Failed cause in route "${e}":\n${a.join("\n")}.`);return e.replace(/\[(\w+)\]/g,(e,t)=>(i.isNonEmptyString(r[t])?r[t]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")},exports.getBaseUrl=()=>{var t,n;try{const s=null==(t=process.env.NEXT_PUBLIC_BASE_URL)?void 0:t.trim(),i=null==(n=process.env.NEXT_PUBLIC_PORT_FE)?void 0:n.trim();let a=s||"http://localhost";a=r.removeSpaces(a).replace(/\/+$/,"");const o=/:\/\/[^/]+:\d+/.test(a);!o&&i?a+=e.formatEnvPort(i,{prefixColon:!0}):o||s||(a+=":3000");const c=new URL(a);return`${c.protocol}//${c.hostname}${c.port?`:${c.port}`:""}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:"+e)}},exports.getBeApiUrl=a;