@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.1-beta.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 (134) hide show
  1. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
  2. package/dist/any-BmdI8UbK.d.ts +56 -56
  3. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
  4. package/dist/assertions/index.cjs +1 -1
  5. package/dist/assertions/index.d.ts +396 -396
  6. package/dist/assertions/index.js +1 -1
  7. package/dist/chunk-26W3VZIK.cjs +1 -0
  8. package/dist/chunk-2KRCHXFG.cjs +2 -0
  9. package/dist/{chunk-TQMZ2LPI.js → chunk-33ZLH266.js} +1 -1
  10. package/dist/{chunk-VQLAPEL3.js → chunk-4L4EJTNZ.js} +1 -1
  11. package/dist/{chunk-CK3BZGEU.js → chunk-5Q37AP7P.js} +1 -1
  12. package/dist/chunk-7CHFAMS2.js +1 -0
  13. package/dist/{chunk-REFMEB4A.js → chunk-7MMJZ6HS.js} +1 -1
  14. package/dist/chunk-7TC6DE3J.cjs +1 -0
  15. package/dist/{chunk-K4PLGD7C.js → chunk-7VX33E3V.js} +1 -1
  16. package/dist/chunk-BEZPD44N.cjs +1 -0
  17. package/dist/{chunk-2AUUPGMN.js → chunk-BI263OHW.js} +1 -1
  18. package/dist/{chunk-LVUSFXQS.cjs → chunk-CII6WWLO.cjs} +1 -1
  19. package/dist/{chunk-OX6RLS2F.cjs → chunk-D5TYPCWU.cjs} +1 -1
  20. package/dist/{chunk-MWLEM7ED.js → chunk-EEQY5QUG.js} +1 -1
  21. package/dist/chunk-ESJYBIYH.js +1 -0
  22. package/dist/{chunk-MJAW5RAK.js → chunk-EWYPSKKM.js} +1 -1
  23. package/dist/chunk-EXCOQLWX.cjs +1 -0
  24. package/dist/chunk-FWQVTMYA.cjs +1 -0
  25. package/dist/{chunk-25G6B35W.js → chunk-G4EWCRKS.js} +1 -1
  26. package/dist/{chunk-PFLNHD4B.cjs → chunk-G7R5XZRM.cjs} +1 -1
  27. package/dist/{chunk-EXXLUO7L.cjs → chunk-GGEV7LXX.cjs} +1 -1
  28. package/dist/{chunk-VTR75UID.cjs → chunk-HJOZOENU.cjs} +1 -1
  29. package/dist/{chunk-HXTACM3O.cjs → chunk-IRDZVLNZ.cjs} +1 -1
  30. package/dist/chunk-IW73G523.cjs +1 -0
  31. package/dist/chunk-IY5OZAB3.cjs +1 -0
  32. package/dist/{chunk-467VEMJH.js → chunk-J4NCYYGS.js} +1 -1
  33. package/dist/{chunk-RHIBYOFQ.js → chunk-J7JAZAJD.js} +1 -1
  34. package/dist/{chunk-JQZUWBIX.js → chunk-JYNSO7ZY.js} +1 -1
  35. package/dist/{chunk-UUMKL74S.js → chunk-K3UVKYEU.js} +1 -1
  36. package/dist/{chunk-ME5OV5HN.js → chunk-LQ76EDZG.js} +1 -1
  37. package/dist/chunk-MROH35V3.cjs +1 -0
  38. package/dist/chunk-NJSAV73S.js +1 -0
  39. package/dist/{chunk-HXST7RJB.js → chunk-NR44SNYE.js} +1 -1
  40. package/dist/{chunk-BLCANGFS.js → chunk-NXMTWY77.js} +1 -1
  41. package/dist/chunk-OZCQZO2V.cjs +4 -0
  42. package/dist/chunk-Q3NTKN5I.cjs +1 -0
  43. package/dist/{chunk-NSVLG7NY.js → chunk-QDNSC57Z.js} +1 -1
  44. package/dist/{chunk-NUVGETPD.js → chunk-QGXTL5ZH.js} +1 -1
  45. package/dist/{chunk-D43GV6EF.cjs → chunk-QSQDP7L2.cjs} +1 -1
  46. package/dist/{chunk-U4TZO7WV.js → chunk-S5M33A4O.js} +1 -1
  47. package/dist/{chunk-S7GMG4TB.js → chunk-SGTHOQQ2.js} +1 -1
  48. package/dist/chunk-SL3RQOWA.js +1 -0
  49. package/dist/{chunk-NUHOOAUN.cjs → chunk-SZPWZZYG.cjs} +1 -1
  50. package/dist/{chunk-RHE3M2NJ.cjs → chunk-UA4B7JBO.cjs} +1 -1
  51. package/dist/chunk-UQDJF5RR.cjs +1 -0
  52. package/dist/chunk-UTQUYABU.cjs +1 -0
  53. package/dist/{chunk-G72VSVGO.js → chunk-VPW3DRV5.js} +1 -1
  54. package/dist/{chunk-PSWITZK5.js → chunk-W32WALNU.js} +1 -1
  55. package/dist/chunk-XGZ6K753.cjs +1 -0
  56. package/dist/chunk-YFTR64N5.cjs +1 -0
  57. package/dist/chunk-ZFDS7W6B.cjs +1 -0
  58. package/dist/chunk-ZQOLZE6Z.cjs +1 -0
  59. package/dist/conversions/index.cjs +1 -1
  60. package/dist/conversions/index.d.ts +1285 -1285
  61. package/dist/conversions/index.js +1 -1
  62. package/dist/env/index.d.ts +14 -14
  63. package/dist/events/index.cjs +1 -1
  64. package/dist/events/index.d.ts +109 -109
  65. package/dist/events/index.js +1 -1
  66. package/dist/extends-Bk_SBGdT.d.ts +330 -330
  67. package/dist/formatting/index.cjs +1 -1
  68. package/dist/formatting/index.d.ts +855 -855
  69. package/dist/formatting/index.js +1 -1
  70. package/dist/generator/index.cjs +1 -1
  71. package/dist/generator/index.d.ts +155 -155
  72. package/dist/generator/index.js +1 -1
  73. package/dist/if-CvT4R7Kh.d.ts +16 -16
  74. package/dist/index.cjs +1 -1
  75. package/dist/index.js +1 -1
  76. package/dist/is-array--YjXV-Wx.d.ts +1084 -1084
  77. package/dist/isPlainObject-BVhBAPHX.d.ts +154 -154
  78. package/dist/never-BfayMBF9.d.ts +64 -64
  79. package/dist/next/index.cjs +5 -5
  80. package/dist/next/index.d.ts +183 -183
  81. package/dist/next/index.js +1 -1
  82. package/dist/next/server/index.cjs +1 -1
  83. package/dist/next/server/index.d.ts +25 -25
  84. package/dist/next/server/index.js +1 -1
  85. package/dist/nils-DMz3kU7M.d.ts +155 -155
  86. package/dist/omit-VvmIsZmX.d.ts +25 -25
  87. package/dist/operations/index.cjs +1 -1
  88. package/dist/operations/index.d.ts +120 -120
  89. package/dist/operations/index.js +1 -1
  90. package/dist/parsers/index.cjs +1 -1
  91. package/dist/parsers/index.d.ts +34 -34
  92. package/dist/parsers/index.js +1 -1
  93. package/dist/predicates/index.cjs +1 -1
  94. package/dist/predicates/index.d.ts +1674 -1674
  95. package/dist/predicates/index.js +1 -1
  96. package/dist/prettify-C4xLcYOP.d.ts +328 -328
  97. package/dist/promise/index.cjs +1 -1
  98. package/dist/promise/index.d.ts +29 -29
  99. package/dist/promise/index.js +1 -1
  100. package/dist/rzl-utils.global.js +1 -1
  101. package/dist/string-XA-til3C.d.ts +318 -318
  102. package/dist/strings/index.cjs +1 -1
  103. package/dist/strings/index.d.ts +690 -690
  104. package/dist/strings/index.js +1 -1
  105. package/dist/stylings/index.cjs +1 -1
  106. package/dist/stylings/index.d.ts +35 -35
  107. package/dist/stylings/index.js +1 -1
  108. package/dist/type-data-DDs-u2kq.d.ts +241 -241
  109. package/dist/types/index.d.ts +3264 -3264
  110. package/dist/urls/index.cjs +1 -1
  111. package/dist/urls/index.d.ts +373 -373
  112. package/dist/urls/index.js +1 -1
  113. package/package.json +1 -1
  114. package/dist/chunk-2JQQQ625.js +0 -1
  115. package/dist/chunk-445TAVT4.cjs +0 -1
  116. package/dist/chunk-6Q4I2RPC.cjs +0 -1
  117. package/dist/chunk-6SMJMZ7G.cjs +0 -1
  118. package/dist/chunk-DFSTVQFI.cjs +0 -1
  119. package/dist/chunk-DYRDBYPF.cjs +0 -1
  120. package/dist/chunk-GAJTFCUA.js +0 -1
  121. package/dist/chunk-GOJNH55O.cjs +0 -1
  122. package/dist/chunk-IJTZWWRJ.cjs +0 -1
  123. package/dist/chunk-ISJ33O2J.cjs +0 -1
  124. package/dist/chunk-JISH2VGG.js +0 -1
  125. package/dist/chunk-KZQB7H4E.cjs +0 -1
  126. package/dist/chunk-LUVV5KSD.cjs +0 -2
  127. package/dist/chunk-MF5Y5K4N.cjs +0 -1
  128. package/dist/chunk-O5VXBNUQ.cjs +0 -4
  129. package/dist/chunk-O7SJR4CY.cjs +0 -1
  130. package/dist/chunk-PYUVKHUF.cjs +0 -1
  131. package/dist/chunk-XFCJDSB2.cjs +0 -1
  132. package/dist/chunk-XOYX4PLZ.cjs +0 -1
  133. package/dist/chunk-Z6FLCEN6.js +0 -1
  134. package/dist/chunk-ZO5364A6.cjs +0 -1
@@ -1,393 +1,393 @@
1
1
  /** ----------------------------------------------------------
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
- */
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
+ */
26
26
  type QueryParamPairs=[[string,string|number],...[string,string|number][]];
27
27
  /** ---------------------------------
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
- */
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
+ */
76
76
  declare const constructURL:(baseUrl:string|URL,queryParams?:URLSearchParamsIterator<[string,string|number]>|QueryParamPairs,removeParams?:string[])=>URL;
77
77
  /** ---------------------------------
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
- */
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
102
  declare const extractURLs:(url:string|null|undefined)=>string[]|null;type GetPrefixPathnameOptions={
103
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
- */
104
+ *
105
+ * @default 1
106
+ */
107
107
  levels?:number;
108
108
  /** Whether to remove duplicates from the result if multiple URLs are passed (default is `true`).
109
- *
110
- * @default true
111
- */
109
+ *
110
+ * @default true
111
+ */
112
112
  removeDuplicates?:boolean;};
113
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
- */
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
237
  declare const getPrefixPathname:(url:string|string[],base?:string|string[]|null,options?:GetPrefixPathnameOptions)=>string|string[]|null;
238
238
  /** --------------------------------------------------------
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
- */
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
334
  declare const getFirstPrefixPathname:(result:string|string[]|null|undefined,defaultValue?:string)=>string;
335
335
  /** --------------------------------------------------------
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
- */
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
368
  declare const normalizePathname:(pathname:string|null|undefined,defaultPath?:string)=>string;type FormatEnvPortOptions={
369
369
  /** Add prefix with a colon, defaultValue: `false`.
370
- *
371
- * @default false
372
- */
370
+ *
371
+ * @default false
372
+ */
373
373
  prefixColon?:boolean;};
374
374
  /** -----------------------------------------------
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
- */
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
393
  declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname};