@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
@@ -1,418 +1,393 @@
1
1
  /** ----------------------------------------------------------
2
- * * ***Represents a non-empty array of key–value pairs.***
3
- * ----------------------------------------------------------
4
- *
5
- * Type for `queryParams` parameter, the second parameter of **{@link constructURL}**.
6
- *
7
- * - Each inner tuple strictly follows the `[string, string | number]` shape.
8
- * - Ensures the outer array contains **at least one pair** (non-empty).
9
- * - Commonly used for URL construction parameters,
10
- * query string segments, or other key–value structured data.
11
- *
12
- * @example
13
- * // ✅ valid usage
14
- * const params: QueryParamPairs = [
15
- * ["foo", 1],
16
- * ["bar", "baz"]
17
- * ];
18
- *
19
- * constructURL("https://example.com", params);
20
- *
21
- * @example
22
- * // ❌ invalid: must contain at least one item
23
- * const empty: QueryParamPairs = [];
24
- *
25
- * // ❌ invalid: key without value pairs.
26
- * const empty2: QueryParamPairs = [["key"]];
27
- */
2
+ * * ***Type-Utility: `QueryParamPairs`.***
3
+ * ----------------------------------------------------------
4
+ * **Represents a non-empty array of key–value pairs.**
5
+ * @description
6
+ * Type for `queryParams` parameter, the second parameter of **{@link constructURL}**.
7
+ * - **Behavior:**
8
+ * - Each inner tuple strictly follows the `[string, string | number]` shape.
9
+ * - Ensures the outer array contains **at least one pair** (non-empty).
10
+ * - Commonly used for URL construction parameters,
11
+ * query string segments, or other key–value structured data.
12
+ * @example
13
+ * // ✅ valid usage
14
+ * const params: QueryParamPairs = [
15
+ * ["foo", 1],
16
+ * ["bar", "baz"]
17
+ * ];
18
+ * constructURL("https://example.com", params);
19
+ *
20
+ * // ❌ invalid: must contain at least one item
21
+ * const empty: QueryParamPairs = [];
22
+ *
23
+ * // ❌ invalid: key without value pairs.
24
+ * const empty2: QueryParamPairs = [["key"]];
25
+ */
28
26
  type QueryParamPairs=[[string,string|number],...[string,string|number][]];
29
27
  /** ---------------------------------
30
- * * ***Constructs a valid URL with optional query parameters and allows selective removal of duplicate parameters.***
31
- * ---------------------------------
32
- *
33
- * @param {string | URL} baseUrl
34
- * The base URL to build upon. Must include protocol (e.g., "https://"),
35
- * domain, and may include port and existing query parameters.
36
- *
37
- * @param {Iterable<[string, string]>|URLSearchParamsIterator<[string, string]>} [queryParams]
38
- * Additional query parameters to append or overwrite on the URL.
39
- * Accepts any iterable of key-value pairs (like `new URLSearchParams().entries()` and `[[string, string | number]...]`).
40
- *
41
- * @param {string[]} [removeParams]
42
- * A list of query parameter keys to remove from the final URL,
43
- * whether they were in the base URL or provided queryParams.
44
- *
45
- * @returns {URL}
46
- * A new URL object representing the constructed URL with merged
47
- * and cleaned query parameters.
48
- *
49
- * @throws {TypeError}
50
- * Throws if `baseUrl` is not a valid non-empty string or URL object,
51
- * or if `queryParams` is not iterable, or if `removeParams` is not an array of strings.
52
- *
53
- * @example
54
- * // BASIC USAGE:
55
- *
56
- * constructURL("https://example.com/path", new URLSearchParams({ a: "1", b: "2" }).entries());
57
- * // ➔ URL { href: "https://example.com/path?a=1&b=2", ... }
58
- *
59
- * @example
60
- * // REMOVE PARAMETERS FROM BASE AND ADDED:
61
- *
62
- * // with new URLSearchParams({ ... }).entries();
63
- * constructURL("https://example.com/path?foo=1&bar=2", new URLSearchParams({ bar: "ignored", baz: "3" }).entries(), ["bar"]);
64
- * // ➔ URL { href: "https://example.com/path?foo=1&baz=3", ... }
65
- *
66
- * // with [[string, string | number]...]
67
- * constructURL("https://example.com/path?foo=1&bar=2", [["bar", "ignored"],["baz", 3]], ["bar"]);
68
- * // URL { href: "https://example.com/path?foo=1&baz=3", ... }
69
- *
70
- * const params: QueryParamPairs = [
71
- * ["foo", 1],
72
- * ["bar", 2],
73
- * ["baz", 3]
74
- * ];
75
- *
76
- * constructURL("https://example.com", params, ["bar"]);
77
- * // ➔ URL { href: "https://example.com/?foo=1&baz=3", ... }
78
- */
28
+ * * ***Utility: `constructURL`.***
29
+ * ---------------------------------
30
+ * **Constructs a valid URL with optional query parameters and allows selective removal of duplicate parameters.**
31
+ * @param {string | URL} baseUrl The base URL to build upon. Must include protocol (e.g., `"https://"`), `domain`, and may include port and existing query parameters.
32
+ * @param {Iterable<[string, string]> | URLSearchParamsIterator<[string, string]> | QueryParamPairs} [queryParams]
33
+ * Additional query parameters to append or overwrite on the URL.
34
+ * - Accepts any iterable of key-value pairs (like `new URLSearchParams().entries()` and `[[string, string | number]...]`).
35
+ * @param {string[]} [removeParams]
36
+ * A list of query parameter keys to remove from the final URL, whether they were in the base URL or provided queryParams.
37
+ * @returns {URL} A new URL object representing the constructed URL with merged and cleaned query parameters.
38
+ * @throws {TypeError} Throws if `baseUrl` is not a valid non-empty string or URL object, or if `queryParams` is not iterable, or if `removeParams` is not an array of strings.
39
+ * @example
40
+ * 1. #### Basic Usage:
41
+ * ```ts
42
+ * constructURL(
43
+ * "https://example.com/path",
44
+ * new URLSearchParams({ a: "1", b: "2" }).entries()
45
+ * );
46
+ * // ➔ URL { href: "https://example.com/path?a=1&b=2", ... }
47
+ * ```
48
+ * 2. #### Remove parameters from Base and Added:
49
+ * ```ts
50
+ * // with new URLSearchParams({ ... }).entries();
51
+ * constructURL(
52
+ * "https://example.com/path?foo=1&bar=2",
53
+ * new URLSearchParams({ bar: "ignored", baz: "3" }).entries(),
54
+ * ["bar"]
55
+ * );
56
+ * // ➔ URL { href: "https://example.com/path?foo=1&baz=3", ... }
57
+ *
58
+ * // with [[string, string | number]...]
59
+ * constructURL(
60
+ * "https://example.com/path?foo=1&bar=2",
61
+ * [["bar", "ignored"],["baz", 3]],
62
+ * ["bar"]
63
+ * );
64
+ * // URL { href: "https://example.com/path?foo=1&baz=3", ... }
65
+ *
66
+ * const params: QueryParamPairs = [
67
+ * ["foo", 1],
68
+ * ["bar", 2],
69
+ * ["baz", 3]
70
+ * ];
71
+ *
72
+ * constructURL("https://example.com", params, ["bar"]);
73
+ * // ➔ URL { href: "https://example.com/?foo=1&baz=3", ... }
74
+ * ```
75
+ */
79
76
  declare const constructURL:(baseUrl:string|URL,queryParams?:URLSearchParamsIterator<[string,string|number]>|QueryParamPairs,removeParams?:string[])=>URL;
80
77
  /** ---------------------------------
81
- * * ***Extracts all valid URLs from a given string.***
82
- * ---------------------------------
83
- *
84
- * This function scans the input url and returns an array of URLs
85
- * that match a valid `http` or `https` format.
86
- *
87
- * Supports:
88
- * - Internationalized domain names (IDN), e.g. `https://münich.de`
89
- * - Unicode & emoji paths, e.g. `https://example.com/🎉/page`
90
- * - Long URLs with multiple queries & fragments, e.g. `https://example.com/path?foo=1#hash`
91
- *
92
- * Ignores:
93
- * - Non-string inputs
94
- * - Empty or whitespace-only strings
95
- * - Non-HTTP(S) protocols (ftp, mailto, etc)
96
- *
97
- * @param {string|null|undefined} [url] - The input string containing potential URLs.
98
- * @returns {string[] | null} An array of extracted URLs or `null` if no URLs are found.
99
- * @example
100
- * extractURLs("Visit https://example.com and https://例子.公司");
101
- * // ➔ ["https://example.com", "https://例子.公司"]
102
- *
103
- * @example
104
- * extractURLs("Here: https://example.com/🎉/page");
105
- * // ["https://example.com/🎉/page"]
106
- *
107
- * @example
108
- * extractURLs("ftp://example.com http://example.com");
109
- * // ➔ ["http://example.com"]
110
- */
111
- declare const extractURLs:(url?:string|null)=>string[]|null;
112
- /** --------------------------------------------------------
113
- * * ***Get Prefix from URL with Optional Base or Auto-detection (Supports String or Array of URLs).***
114
- * --------------------------------------------------------
115
- *
116
- * @description
117
- * This function extracts the prefix from one or more URLs. It can either:
118
- * - Use a provided `base` string or an array of strings to check and return the matching prefix.
119
- * - Automatically detect the prefix if no `base` is provided by analyzing the first part of the URL.
120
- *
121
- * The function is flexible and can handle both scenarios:
122
- * 1. **When the base is provided as a single string or an array of strings**: The function will check if the URL starts with one of the provided base(s) and return the matching base.
123
- * 2. **When the base is not provided**: The function will automatically detect the prefix by splitting the URL or using a regex.
124
- *
125
- * **Important Notes**:
126
- * - If a base (or an array of bases) is provided, the URL must start with one of the given base(s).
127
- * - If no base is provided, the function will attempt to detect the prefix automatically.
128
- * - The `url` parameter can be either a string or an array of strings.
129
- * - Supports deduplication of results (enabled by default).
130
- * - Automatically returns a single string if only one unique result exists after processing.
131
- *
132
- * ---
133
- *
134
- * @param {string|string[]} url The full URL(s) from which the prefix should be extracted. Can be a string or an array of strings.
135
- * @param {string|string[]|null} [base=null] The base URL(s) (e.g., "/settings"). It can be a string, an array of strings, or `null`. If provided, it will be used to check the URL(s). If not provided, the prefix will be auto-detected.
136
- * @param {{ levels?: number; removeDuplicates?: boolean }} [options] Additional options object:
137
- * - `levels` (default `1`): The number of segments to include when auto-detecting the prefix (e.g. `/foo/bar` for `levels: 2`).
138
- * - `removeDuplicates` (default `true`): Whether to remove duplicate prefixes from the final array result.
139
- *
140
- * @returns {string|string[]|null}
141
- * Returns one of:
142
- * - A single string if only one unique prefix/base is found.
143
- * - An array of strings if multiple different prefixes/bases are found.
144
- * - `null` if no matching base is found when using `base`.
145
- *
146
- * ---
147
- *
148
- * @throws {TypeError}
149
- * Throws if:
150
- * - `url` is not a string or an array of strings.
151
- * - `base` is not a string, array of strings, or `null`.
152
- * - `options` is not an object.
153
- * - `levels` is not a number.
154
- * - `removeDuplicates` is not a boolean.
155
- *
156
- * ---
157
- *
158
- * #### **🔹 Usage Examples**
159
- *
160
- * #### ✅ **Correct Usage (With an Array of URLs and Base)**
161
- * ```ts
162
- * const routes = [
163
- * "/settings/profile",
164
- * "/settings/password",
165
- * "/settings/other-path",
166
- * "/other-path/xyz",
167
- * ];
168
- *
169
- * // With base provided as a string
170
- * routes.forEach(route => {
171
- * console.log(getPrefixPathname(route, '/settings'));
172
- * // ➔ "/settings"
173
- * });
174
- *
175
- * // With base provided as an array
176
- * routes.forEach(route => {
177
- * console.log(getPrefixPathname(route, ['/settings', '/admin']));
178
- * // ➔ "/settings" or "/admin" depending on the current URL.
179
- * });
180
- * ```
181
- *
182
- * #### ✅ **Correct Usage (With Single URL and Single Base)**
183
- * ```ts
184
- * const result = getPrefixPathname("/settings/profile", "/settings");
185
- * console.log(result); // ➔ "/settings"
186
- * ```
187
- *
188
- * #### ✅ **Correct Usage (With Multiple URLs and Single Base)**
189
- * ```ts
190
- * const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
191
- * console.log(result); // ➔ "/settings"
192
- *
193
- * const result2 = getPrefixPathname(["/settings/profile", "/other/password"], "/other");
194
- * console.log(result2); // ➔ "/other"
195
- * ```
196
- *
197
- * #### ✅ **Correct Usage (With Multiple URLs and Multiple Bases)**
198
- * ```ts
199
- * const result = getPrefixPathname(["/settings/profile", "/admin/password"], ["/settings", "/admin"]);
200
- * console.log(result); // ➔ ["/settings", "/admin"]
201
- * ```
202
- *
203
- * #### ✅ **Auto-detection of Prefix**
204
- * ```ts
205
- * const result = getPrefixPathname("/settings/profile");
206
- * console.log(result); // ➔ "/settings"
207
- *
208
- * const result2 = getPrefixPathname("/settings/profile/info", null, { levels: 2 });
209
- * console.log(result2); // ➔ "/settings/profile"
210
- * ```
211
- *
212
- * #### ✅ **Multiple URLs with Auto-detection**
213
- * ```ts
214
- * const result = getPrefixPathname(["/admin/profile", "/settings/password"]);
215
- * console.log(result); // ➔ ["/admin", "/settings"]
216
- * ```
217
- *
218
- * #### ✅ **Handling Duplicates**
219
- * ```ts
220
- * const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
221
- * console.log(result); // ➔ "/settings" (deduped to single string)
222
- *
223
- * const result2 = getPrefixPathname(["/settings/profile", "/settings/profile"], "/settings", { removeDuplicates: false });
224
- * console.log(result2); // ➔ ["/settings", "/settings"]
225
- * ```
226
- *
227
- * #### ❌ **Incorrect Usage (URL Does Not Match Base)**
228
- * ```ts
229
- * const result = getPrefixPathname("/other-path/profile", "/settings");
230
- * console.log(result); // ➔ null
231
- * ```
232
- */
233
- declare const getPrefixPathname:(url:string|string[],base?:string|string[]|null,options?:{
234
- /** The number of levels to include in the prefix (default is 1). For example, with `levels = 2`, the function will return the first two parts of the URL. */
78
+ * * ***Utility: `extractURLs`.***
79
+ * ---------------------------------
80
+ * **Extracts all valid URLs from a given string.**
81
+ * @description
82
+ * This function scans the input url and returns an array of URLs
83
+ * that match a valid `http` or `https` format.
84
+ * - **Supports:**
85
+ * - Internationalized domain names (IDN), e.g. `https://münich.de`
86
+ * - Unicode & emoji paths, e.g. `https://example.com/🎉/page`
87
+ * - Long URLs with multiple queries & fragments, e.g. `https://example.com/path?foo=1#hash`
88
+ * - **Ignores:**
89
+ * - Non-string inputs
90
+ * - Empty or whitespace-only strings
91
+ * - Non-HTTP(S) protocols (ftp, mailto, etc)
92
+ * @param {string | null | undefined} url - The input string containing potential URLs.
93
+ * @returns {string[] | null} An array of extracted URLs or `null` if no URLs are found.
94
+ * @example
95
+ * extractURLs("Visit https://example.com and https://例子.公司");
96
+ * // ➔ ["https://example.com", "https://例子.公司"]
97
+ * extractURLs("Here: https://example.com/🎉/page");
98
+ * // ➔ ["https://example.com/🎉/page"]
99
+ * extractURLs("ftp://example.com http://example.com");
100
+ * // ➔ ["http://example.com"]
101
+ */
102
+ declare const extractURLs:(url:string|null|undefined)=>string[]|null;type GetPrefixPathnameOptions={
103
+ /** The number of levels to include in the prefix (default is `1`). For example, with `levels = 2`, the function will return the first two parts of the URL.
104
+ *
105
+ * @default 1
106
+ */
235
107
  levels?:number;
236
- /** Whether to remove duplicates from the result if multiple URLs are passed (default is `true`). */
237
- removeDuplicates?:boolean;})=>string|string[]|null;
108
+ /** Whether to remove duplicates from the result if multiple URLs are passed (default is `true`).
109
+ *
110
+ * @default true
111
+ */
112
+ removeDuplicates?:boolean;};
113
+ /** --------------------------------------------------------
114
+ * * ***Utility: `getPrefixPathname`.***
115
+ * --------------------------------------------------------
116
+ * **Get Prefix from URL with Optional Base or Auto-detection (Supports String or Array of URLs).**
117
+ * - **This function extracts the prefix from one or more URLs. It can either:**
118
+ * - Use a provided `base` string or an array of strings to check and return the matching prefix.
119
+ * - Automatically detect the prefix if no `base` is provided by analyzing the first part of the URL.
120
+ * - **The function is flexible and can handle both scenarios:**
121
+ * 1. **When the base is provided as a single string or an array of strings**:
122
+ * - The function will check if the URL starts with one of the provided base(s) and return the matching base.
123
+ * 2. **When the base is not provided**:
124
+ * - The function will automatically detect the prefix by splitting the URL or using a regex.
125
+ * - **Important Notes**:
126
+ * - If a base (or an array of bases) is provided, the URL must start with one of the given base(s).
127
+ * - If no base is provided, the function will attempt to detect the prefix automatically.
128
+ * - The `url` parameter can be either a string or an array of strings.
129
+ * - Supports deduplication of results (enabled by default).
130
+ * - Automatically returns a single string if only one unique result exists after processing.
131
+ * @param {string|string[]} url The full URL(s) from which the prefix should be extracted.
132
+ * - Can be a `string` or an `array of strings`.
133
+ * @param {string|string[]|null} [base=null] The base URL(s) (e.g., `"/settings"`).
134
+ * - It can be a `string`, an `array of strings`, or `null`.
135
+ * - If `provided`, it will be used to check the URL(s).
136
+ * - If `not provided`, the prefix will be auto-detected.
137
+ * @param {GetPrefixPathnameOptions} [options] Additional options object:
138
+ * - `levels` (default `1`): The number of segments to include when auto-detecting the prefix (e.g. `/foo/bar` for `levels: 2`).
139
+ * - `removeDuplicates` (default `true`): Whether to remove duplicate prefixes from the final array result.
140
+ * @returns {string|string[]|null} Returns one of:
141
+ * - A single string if only one unique prefix/base is found.
142
+ * - An array of strings if multiple different prefixes/bases are found.
143
+ * - `null` if no matching base is found when using `base`.
144
+ * @throws {TypeError} Throws if:
145
+ * - `url` is `not a string` or `not an array of strings`.
146
+ * - `base` is `not a string`, `array of strings`, or `null`.
147
+ * - `options` is `not an object`.
148
+ * - `levels` is `not a number`.
149
+ * - `removeDuplicates` is `not a boolean`.
150
+ * @example
151
+ * - #### ✅ **Correct Usage (With an Array of URLs and Base):**
152
+ * ```ts
153
+ * const routes = [
154
+ * "/settings/profile",
155
+ * "/settings/password",
156
+ * "/settings/other-path",
157
+ * "/other-path/xyz",
158
+ * ];
159
+ *
160
+ * // With base provided as a string
161
+ * routes.forEach(route => {
162
+ * console.log(getPrefixPathname(route, '/settings'));
163
+ * // ➔ "/settings"
164
+ * });
165
+ *
166
+ * // With base provided as an array
167
+ * routes.forEach(route => {
168
+ * console.log(getPrefixPathname(route, ['/settings', '/admin']));
169
+ * // ➔ "/settings" or "/admin" depending on the current URL.
170
+ * });
171
+ * ```
172
+ * - #### ✅ **Correct Usage (With Single URL and Single Base):**
173
+ * ```ts
174
+ * const result = getPrefixPathname("/settings/profile", "/settings");
175
+ * console.log(result); // ➔ "/settings"
176
+ * ```
177
+ * - #### ✅ **Correct Usage (With Multiple URLs and Single Base):**
178
+ * ```ts
179
+ * const result = getPrefixPathname(
180
+ * ["/settings/profile", "/settings/password"],
181
+ * "/settings"
182
+ * );
183
+ * console.log(result); // ➔ "/settings"
184
+ *
185
+ * const result2 = getPrefixPathname(
186
+ * ["/settings/profile", "/other/password"],
187
+ * "/other"
188
+ * );
189
+ * console.log(result2); // ➔ "/other"
190
+ * ```
191
+ * - #### ✅ **Correct Usage (With Multiple URLs and Multiple Bases)**
192
+ * ```ts
193
+ * const result = getPrefixPathname(
194
+ * ["/settings/profile", "/admin/password"],
195
+ * ["/settings", "/admin"]
196
+ * );
197
+ * console.log(result); // ➔ ["/settings", "/admin"]
198
+ * ```
199
+ * - #### ✅ **Auto-detection of Prefix**
200
+ * ```ts
201
+ * const result = getPrefixPathname("/settings/profile");
202
+ * console.log(result); // ➔ "/settings"
203
+ *
204
+ * const result2 = getPrefixPathname(
205
+ * "/settings/profile/info",
206
+ * null,
207
+ * { levels: 2 }
208
+ * );
209
+ * console.log(result2); // ➔ "/settings/profile"
210
+ * ```
211
+ * - #### ✅ **Multiple URLs with Auto-detection**
212
+ * ```ts
213
+ * const result = getPrefixPathname(["/admin/profile", "/settings/password"]);
214
+ * console.log(result); // ➔ ["/admin", "/settings"]
215
+ * ```
216
+ * - #### ✅ **Handling Duplicates**
217
+ * ```ts
218
+ * const result = getPrefixPathname(
219
+ * ["/settings/profile", "/settings/password"],
220
+ * "/settings"
221
+ * );
222
+ * console.log(result); // ➔ "/settings" (deduped to single string)
223
+ *
224
+ * const result2 = getPrefixPathname(
225
+ * ["/settings/profile", "/settings/profile"],
226
+ * "/settings",
227
+ * { removeDuplicates: false }
228
+ * );
229
+ * console.log(result2); // ➔ ["/settings", "/settings"]
230
+ * ```
231
+ * - #### ❌ **Incorrect Usage (URL Does Not Match Base)**
232
+ * ```ts
233
+ * const result = getPrefixPathname("/other-path/profile", "/settings");
234
+ * console.log(result); // ➔ null
235
+ * ```
236
+ */
237
+ declare const getPrefixPathname:(url:string|string[],base?:string|string[]|null,options?:GetPrefixPathnameOptions)=>string|string[]|null;
238
238
  /** --------------------------------------------------------
239
- * * ***Extract First Valid Prefix from Path Array or String.***
240
- * --------------------------------------------------------
241
- *
242
- * #### 🚀 **Main Purpose:**
243
- * This function helps extract the first valid URL prefix from various possible inputs.
244
- * It is especially useful in routing systems, middleware, or frontend apps that
245
- * need to decide layout, active navigation, or permissions based on the first
246
- * segment (or prefix) of a pathname.
247
- *
248
- * Typical uses include:
249
- * - Determining which layout to render (e.g., `/admin` vs `/dashboard` vs `/`).
250
- * - Highlighting the active menu item in a sidebar based on the current URL.
251
- * - Enforcing route guards or access controls depending on the URL prefix.
252
- * - Parsing multi-level route prefixes and selecting the most relevant one.
253
- *
254
- * ---
255
- *
256
- * #### 🔍 Behavior:
257
- * It works as follows:
258
- * - If `result` is an array of strings, it normalizes each element and returns
259
- * the first non-root path (i.e., not just `"/"`). If all items normalize to `"/"`,
260
- * it returns the `defaultValue` (normalized).
261
- * - If `result` is a single string, it normalizes it and returns it if valid,
262
- * otherwise falls back to the normalized `defaultValue`.
263
- * - If `result` is `null` or `undefined`, it returns the normalized `defaultValue`.
264
- *
265
- * ---
266
- *
267
- * #### 🔍 Validation & Errors:
268
- *
269
- * - Throws a `TypeError` if:
270
- * - `defaultValue` is not a non-empty string.
271
- * - `result` is an array that contains non-string elements.
272
- * - `result` is a value that is neither `string`, `string[]`, nor `null`.
273
- *
274
- * ---
275
- *
276
- * #### 🛠 Usage Examples:
277
- *
278
- * 1. #### For React: *Determining layout*
279
- * ```ts
280
- * const prefix = getFirstPrefixPathname(getPrefixPathname("/admin/settings", ["/admin", "/dashboard"]));
281
- * if (prefix === "/admin") {
282
- * renderAdminLayout();
283
- * }
284
- * ```
285
- *
286
- * 2. #### Setting active menu state
287
- * ```ts
288
- * const activeSection = getFirstPrefixPathname(["", "/dashboard", "/profile"]);
289
- * // ➔ "/dashboard"
290
- * ```
291
- *
292
- * 3. #### Providing graceful fallback
293
- * ```ts
294
- * const section = getFirstPrefixPathname([], "/home");
295
- * // ➔ "/home"
296
- * ```
297
- * 4. #### ✅ Using with an Array of Pathnames
298
- * ```ts
299
- * const result = getPrefixPathname([" ", "/dashboard", "/settings"]);
300
- * console.log(getFirstPrefixPathname(result));
301
- * // ➔ "/dashboard"
302
- * ```
303
- *
304
- * 5. #### ✅ Using with Single String:
305
- * ```ts
306
- * console.log(getFirstPrefixPathname("/profile/settings"));
307
- * // ➔ "/profile/settings"
308
- * console.log(getFirstPrefixPathname(" "));
309
- * // ➔ "/"
310
- * ```
311
- *
312
- * 6. #### ✅ Fallback to Custom Default:
313
- * ```ts
314
- * console.log(getFirstPrefixPathname([" ", ""], "/home"));
315
- * // ➔ "/home"
316
- * console.log(getFirstPrefixPathname(null, "/dashboard"));
317
- * // ➔ "/dashboard"
318
- * ```
319
- *
320
- * 7. #### Throws on Invalid Input:
321
- * ```ts
322
- * getFirstPrefixPathname([1, 2] as any); // ➔ ❌ throws TypeError
323
- * getFirstPrefixPathname({} as any); // throws TypeError
324
- * getFirstPrefixPathname(null, " "); // ➔ ❌ throws TypeError
325
- * ```
326
- *
327
- * ---
328
- *
329
- * @param {string | string[] | null} result
330
- * The pathname(s) to process, can be:
331
- * - A string path (e.g. `"/profile"`),
332
- * - An array of string paths (e.g. `[" ", "/dashboard"]`),
333
- * - Or `null`.
334
- *
335
- * @param {string} [defaultValue="/"]
336
- * A custom default path to use if `result` is null or no valid prefix is found.
337
- * - Must be a non-empty string.
338
- * - Defaults to `"/"`.
339
- *
340
- * @returns {string}
341
- * The first valid normalized pathname, or the normalized default.
342
- *
343
- * @throws {TypeError}
344
- * If `result` is not a valid type, or `defaultValue` is not a non-empty string.
345
- */
346
- declare const getFirstPrefixPathname:(result?:string|string[]|null,defaultValue?:string)=>string;
239
+ * * ***Utility: `getFirstPrefixPathname`.***
240
+ * --------------------------------------------------------
241
+ * **Extract First Valid Prefix from Path Array or String.**
242
+ * - **Main Purpose:**
243
+ * - This function helps extract the first valid URL prefix from various possible inputs.
244
+ * - It is especially useful in routing systems, middleware, or frontend apps that need to
245
+ * decide layout, active navigation, or permissions based on the first segment (or prefix) of a pathname.
246
+ * - **Typical uses include:**
247
+ * - Determining which layout to render (e.g., `/admin` vs `/dashboard` vs `/`).
248
+ * - Highlighting the active menu item in a sidebar based on the current URL.
249
+ * - Enforcing route guards or access controls depending on the URL prefix.
250
+ * - Parsing multi-level route prefixes and selecting the most relevant one.
251
+ * - **Behavior:**
252
+ * - It works as follows:
253
+ * - If `result` is an array of strings, it normalizes each element and returns
254
+ * the first non-root path (i.e., not just `"/"`).
255
+ * - If all items normalize to `"/"`,
256
+ * it returns the `defaultValue` (normalized).
257
+ * - If `result` is a single string, it normalizes it and returns it if valid,
258
+ * otherwise falls back to the normalized `defaultValue`.
259
+ * - If `result` is `null` or `undefined`, it returns the normalized `defaultValue`.
260
+ * - **Validation & Errors:**
261
+ * - Throws a `TypeError` if:
262
+ * - `defaultValue` is not a string or empty-string.
263
+ * - `result` is an array that contains non-string elements.
264
+ * - `result` is a value that is neither `string`, `string[]`, nor `null`.
265
+ * @example
266
+ * 1. #### For React (*Determining layout*):
267
+ * ```ts
268
+ * const prefix = getFirstPrefixPathname(
269
+ * getPrefixPathname(
270
+ * "/admin/settings",
271
+ * ["/admin", "/dashboard"]
272
+ * )
273
+ * );
274
+ *
275
+ * if (prefix === "/admin") {
276
+ * renderAdminLayout();
277
+ * }
278
+ * ```
279
+ *
280
+ * 2. #### Setting active menu state:
281
+ * ```ts
282
+ * const activeSection = getFirstPrefixPathname(["", "/dashboard", "/profile"]);
283
+ * // ➔ "/dashboard"
284
+ * ```
285
+ *
286
+ * 3. #### Providing graceful fallback:
287
+ * ```ts
288
+ * const section = getFirstPrefixPathname([], "/home");
289
+ * // ➔ "/home"
290
+ * ```
291
+ * 4. #### ✅ Using with an Array of Pathnames:
292
+ * ```ts
293
+ * const result = getPrefixPathname([" ", "/dashboard", "/settings"]);
294
+ * console.log(getFirstPrefixPathname(result));
295
+ * // ➔ "/dashboard"
296
+ * ```
297
+ *
298
+ * 5. #### ✅ Using with Single String:
299
+ * ```ts
300
+ * console.log(getFirstPrefixPathname("/profile/settings"));
301
+ * // ➔ "/profile/settings"
302
+ * console.log(getFirstPrefixPathname(" "));
303
+ * // ➔ "/"
304
+ * ```
305
+ *
306
+ * 6. #### ✅ Fallback to Custom Default:
307
+ * ```ts
308
+ * console.log(getFirstPrefixPathname([" ", ""], "/home"));
309
+ * // ➔ "/home"
310
+ * console.log(getFirstPrefixPathname(null, "/dashboard"));
311
+ * // ➔ "/dashboard"
312
+ * ```
313
+ *
314
+ * 7. #### ✅ Throws on Invalid Input:
315
+ * ```ts
316
+ * getFirstPrefixPathname([1, 2] as any); // ➔ ❌ throws TypeError
317
+ * getFirstPrefixPathname({} as any); // ➔ ❌ throws TypeError
318
+ * getFirstPrefixPathname(null, " "); // ➔ ❌ throws TypeError
319
+ * ```
320
+ * @param {string | string[] | null | undefined} result
321
+ * The pathname(s) to process, can be:
322
+ * - A string path (e.g. `"/profile"`),
323
+ * - An array of string paths (e.g. `[" ", "/dashboard"]`),
324
+ * - Or `null`.
325
+ * @param {string} [defaultValue="/"]
326
+ * A custom default path to use if `result` is null or no valid prefix is found.
327
+ * - Must be a string and non-empty string.
328
+ * - Defaults to `"/"`.
329
+ * @returns {string}
330
+ * The first valid normalized pathname, or the normalized default.
331
+ * @throws {TypeError}
332
+ * If `result` is not a valid type, or `defaultValue` is not a string or empty-string.
333
+ */
334
+ declare const getFirstPrefixPathname:(result:string|string[]|null|undefined,defaultValue?:string)=>string;
347
335
  /** --------------------------------------------------------
348
- * * ***Normalizes a given pathname by ensuring consistent formatting.***
349
- * --------------------------------------------------------
350
- *
351
- * @description
352
- * This function processes and normalizes a given pathname:
353
- *
354
- * - If `pathname` is `null`, `undefined`, empty, or only whitespace,
355
- * the `defaultPath` will be returned instead.
356
- *
357
- * - If `pathname` is a full URL (starting with `http://` or `https://`),
358
- * it extracts and returns the pathname along with any search parameters and hash.
359
- * Example: `"https://site.com/foo/bar?x=1#sec"` becomes `"/foo/bar?x=1#sec"`.
360
- *
361
- * - All spaces inside the pathname are removed.
362
- *
363
- * - Multiple consecutive slashes (like `"//"` or `"///"`) are collapsed into a single slash `"/"`.
364
- *
365
- * - Ensures the returned string always starts with exactly one `/`.
366
- *
367
- * @param {string | null | undefined} pathname - The pathname to normalize.
368
- * @param {string} [defaultPath="/"] - A fallback value returned if `pathname` is empty or invalid. Must be a non-empty string, default `"/"`.
369
- *
370
- * @returns {string} A properly normalized pathname starting with a single `/`,
371
- * or the `defaultPath` if the input is invalid or empty.
372
- *
373
- * @throws {TypeError} If `defaultPath` is not a non-empty string.
374
- * @throws {NormalizePathnameError} If an unexpected error occurs during normalization (e.g., URL parsing failure).
375
- *
376
- * @example
377
- * normalizePathname(" /foo//bar ");
378
- * // ➔ "/foo/bar"
379
- *
380
- * normalizePathname("https://example.com//path///to/resource?x=1#hash");
381
- * // "/path/to/resource?x=1#hash"
382
- * normalizePathname(" ");
383
- * // ➔ "/"
384
- * normalizePathname(null, "/home");
385
- * // ➔ "/home"
386
- * normalizePathname("/double//slashes");
387
- * // ➔ "/double/slashes"
388
- * normalizePathname(" nested / path / 🚀 ");
389
- * // ➔ "/nested/path/🚀"
390
- */
391
- declare const normalizePathname:(pathname?:string|null,defaultPath?:string)=>string;
336
+ * * ***Utility: `normalizePathname`.***
337
+ * --------------------------------------------------------
338
+ * **This function processes and normalizes a given pathname.**
339
+ * - **Behavior:**
340
+ * - If `pathname` is `null`, `undefined`, empty, or only whitespace, the `defaultPath` will be returned instead.
341
+ * - If `pathname` is a full URL (starting with `http://` or `https://`), it extracts and returns the pathname along
342
+ * with any search parameters and hash.
343
+ * - Example: `"https://site.com/foo/bar?x=1#sec"` becomes `"/foo/bar?x=1#sec"`.
344
+ * - All spaces inside the pathname are removed.
345
+ * - Multiple consecutive slashes (like `"//"` or `"///"`) are collapsed into a single slash `"/"`.
346
+ * - Ensures the returned string always starts with exactly one `/`.
347
+ * @param {string | null | undefined} pathname - The pathname to normalize.
348
+ * @param {string} [defaultPath="/"] - A fallback value returned if `pathname` is empty or invalid.
349
+ * - Must be a string and non-empty string, default `"/"`.
350
+ * @returns {string} A properly normalized pathname starting with a single `/`,
351
+ * or the `defaultPath` if the input is invalid or empty.
352
+ * @throws {TypeError} If `defaultPath` is not a string or empty-string.
353
+ * @throws {NormalizePathnameError} If an unexpected error occurs during normalization (e.g., URL parsing failure).
354
+ * @example
355
+ * normalizePathname(" /foo//bar ");
356
+ * // "/foo/bar"
357
+ * normalizePathname("https://example.com//path///to/resource?x=1#hash");
358
+ * // "/path/to/resource?x=1#hash"
359
+ * normalizePathname(" ");
360
+ * // ➔ "/"
361
+ * normalizePathname(null, "/home");
362
+ * // "/home"
363
+ * normalizePathname("/double//slashes");
364
+ * // ➔ "/double/slashes"
365
+ * normalizePathname(" nested / path / 🚀 ");
366
+ * // ➔ "/nested/path/🚀"
367
+ */
368
+ declare const normalizePathname:(pathname:string|null|undefined,defaultPath?:string)=>string;type FormatEnvPortOptions={
369
+ /** Add prefix with a colon, defaultValue: `false`.
370
+ *
371
+ * @default false
372
+ */
373
+ prefixColon?:boolean;};
392
374
  /** -----------------------------------------------
393
- * * ***Retrieves and formats an environment port variable.***
394
- * -----------------------------------------------
395
- *
396
- * - Extracts only digits from the input.
397
- * - If no digits found, returns an empty string.
398
- * - By default does NOT prefix with a colon.
399
- * - Use `{ prefixColon: true }` to prefix with a colon.
400
- *
401
- * @param envVar The environment variable string.
402
- * @param options Optional object: `{ prefixColon?: boolean }`.
403
- * @returns A string like ":8080" or "8080", or "" if no digits.
404
- *
405
- * @throws TypeError if `options` is not an object or `prefixColon` is not boolean.
406
- *
407
- * @example
408
- * formatEnvPort("port:8080");
409
- * // ➔ "8080"
410
- * formatEnvPort("port:8080", { prefixColon: true });
411
- * // ":8080"
412
- */
413
- declare const formatEnvPort:(envVar?:string|null,options?:{
414
- /** Add prefix with a colon.
415
- *
416
- * @default false
417
- */
418
- prefixColon?:boolean;})=>string;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname};
375
+ * * ***Utility: `formatEnvPort`.***
376
+ * -----------------------------------------------
377
+ * **Retrieves and formats an environment port variable.**
378
+ * - **Behavior:**
379
+ * - Extracts only digits from the input.
380
+ * - If no digits found, returns an empty string.
381
+ * - By default does NOT prefix with a colon.
382
+ * - Use `{ prefixColon: true }` to prefix with a colon.
383
+ * @param {string | null | undefined} envVar The environment variable string.
384
+ * @param {FormatEnvPortOptions} [options] Optional object: `{ prefixColon?: boolean }`.
385
+ * @returns {string} A string like `":8080"` or `"8080"`, or `""` if no digits.
386
+ * @throws {TypeError} If `options` is not an object or `prefixColon` is not boolean.
387
+ * @example
388
+ * formatEnvPort("port:8080");
389
+ * // ➔ "8080"
390
+ * formatEnvPort("port:8080", { prefixColon: true });
391
+ * // ➔ ":8080"
392
+ */
393
+ declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname};