full-utils 1.0.11 → 2.0.1

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 (170) hide show
  1. package/README.md +189 -1
  2. package/dist/browser.cjs +3 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.d.cts +1 -0
  5. package/dist/browser.d.ts +1 -0
  6. package/dist/browser.mjs +3 -0
  7. package/dist/browser.mjs.map +1 -0
  8. package/dist/index.cjs +3 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.cts +4495 -0
  11. package/dist/index.d.ts +4495 -49
  12. package/dist/index.mjs +3 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/node.cjs +3 -0
  15. package/dist/node.cjs.map +1 -0
  16. package/dist/node.d.cts +166 -0
  17. package/dist/node.d.ts +166 -0
  18. package/dist/node.mjs +3 -0
  19. package/dist/node.mjs.map +1 -0
  20. package/package.json +65 -19
  21. package/dist/index.js +0 -100
  22. package/dist/index.js.map +0 -1
  23. package/dist/src/from/fromJSON.d.ts +0 -5
  24. package/dist/src/from/fromJSON.js +0 -71
  25. package/dist/src/from/fromJSON.js.map +0 -1
  26. package/dist/src/from/fromTimestamp.d.ts +0 -6
  27. package/dist/src/from/fromTimestamp.js +0 -8
  28. package/dist/src/from/fromTimestamp.js.map +0 -1
  29. package/dist/src/index.d.ts +0 -49
  30. package/dist/src/index.js +0 -100
  31. package/dist/src/index.js.map +0 -1
  32. package/dist/src/is/isArr.d.ts +0 -1
  33. package/dist/src/is/isArr.js +0 -7
  34. package/dist/src/is/isArr.js.map +0 -1
  35. package/dist/src/is/isArrFilled.d.ts +0 -1
  36. package/dist/src/is/isArrFilled.js +0 -8
  37. package/dist/src/is/isArrFilled.js.map +0 -1
  38. package/dist/src/is/isBool.d.ts +0 -1
  39. package/dist/src/is/isBool.js +0 -7
  40. package/dist/src/is/isBool.js.map +0 -1
  41. package/dist/src/is/isDate.d.ts +0 -1
  42. package/dist/src/is/isDate.js +0 -16
  43. package/dist/src/is/isDate.js.map +0 -1
  44. package/dist/src/is/isEmail.d.ts +0 -1
  45. package/dist/src/is/isEmail.js +0 -9
  46. package/dist/src/is/isEmail.js.map +0 -1
  47. package/dist/src/is/isExists.d.ts +0 -1
  48. package/dist/src/is/isExists.js +0 -7
  49. package/dist/src/is/isExists.js.map +0 -1
  50. package/dist/src/is/isFunc.d.ts +0 -1
  51. package/dist/src/is/isFunc.js +0 -7
  52. package/dist/src/is/isFunc.js.map +0 -1
  53. package/dist/src/is/isIp.d.ts +0 -1
  54. package/dist/src/is/isIp.js +0 -13
  55. package/dist/src/is/isIp.js.map +0 -1
  56. package/dist/src/is/isMac.d.ts +0 -1
  57. package/dist/src/is/isMac.js +0 -8
  58. package/dist/src/is/isMac.js.map +0 -1
  59. package/dist/src/is/isNum.d.ts +0 -1
  60. package/dist/src/is/isNum.js +0 -7
  61. package/dist/src/is/isNum.js.map +0 -1
  62. package/dist/src/is/isNumFloat.d.ts +0 -1
  63. package/dist/src/is/isNumFloat.js +0 -8
  64. package/dist/src/is/isNumFloat.js.map +0 -1
  65. package/dist/src/is/isNumN.d.ts +0 -1
  66. package/dist/src/is/isNumN.js +0 -8
  67. package/dist/src/is/isNumN.js.map +0 -1
  68. package/dist/src/is/isNumNZ.d.ts +0 -1
  69. package/dist/src/is/isNumNZ.js +0 -8
  70. package/dist/src/is/isNumNZ.js.map +0 -1
  71. package/dist/src/is/isNumP.d.ts +0 -1
  72. package/dist/src/is/isNumP.js +0 -8
  73. package/dist/src/is/isNumP.js.map +0 -1
  74. package/dist/src/is/isNumPZ.d.ts +0 -1
  75. package/dist/src/is/isNumPZ.js +0 -8
  76. package/dist/src/is/isNumPZ.js.map +0 -1
  77. package/dist/src/is/isObj.d.ts +0 -1
  78. package/dist/src/is/isObj.js +0 -10
  79. package/dist/src/is/isObj.js.map +0 -1
  80. package/dist/src/is/isObjFilled.d.ts +0 -1
  81. package/dist/src/is/isObjFilled.js +0 -8
  82. package/dist/src/is/isObjFilled.js.map +0 -1
  83. package/dist/src/is/isPassword.d.ts +0 -10
  84. package/dist/src/is/isPassword.js +0 -26
  85. package/dist/src/is/isPassword.js.map +0 -1
  86. package/dist/src/is/isPhone.d.ts +0 -1
  87. package/dist/src/is/isPhone.js +0 -35
  88. package/dist/src/is/isPhone.js.map +0 -1
  89. package/dist/src/is/isStr.d.ts +0 -1
  90. package/dist/src/is/isStr.js +0 -7
  91. package/dist/src/is/isStr.js.map +0 -1
  92. package/dist/src/is/isStrBool.d.ts +0 -1
  93. package/dist/src/is/isStrBool.js +0 -12
  94. package/dist/src/is/isStrBool.js.map +0 -1
  95. package/dist/src/is/isStrFilled.d.ts +0 -1
  96. package/dist/src/is/isStrFilled.js +0 -8
  97. package/dist/src/is/isStrFilled.js.map +0 -1
  98. package/dist/src/is/isStrOrderType.d.ts +0 -1
  99. package/dist/src/is/isStrOrderType.js +0 -12
  100. package/dist/src/is/isStrOrderType.js.map +0 -1
  101. package/dist/src/is/isVar.d.ts +0 -1
  102. package/dist/src/is/isVar.js +0 -8
  103. package/dist/src/is/isVar.js.map +0 -1
  104. package/dist/src/net/netTCP.d.ts +0 -6
  105. package/dist/src/net/netTCP.js +0 -52
  106. package/dist/src/net/netTCP.js.map +0 -1
  107. package/dist/src/to/toArrFuncArgs.d.ts +0 -1
  108. package/dist/src/to/toArrFuncArgs.js +0 -139
  109. package/dist/src/to/toArrFuncArgs.js.map +0 -1
  110. package/dist/src/to/toBool.d.ts +0 -1
  111. package/dist/src/to/toBool.js +0 -23
  112. package/dist/src/to/toBool.js.map +0 -1
  113. package/dist/src/to/toCellDate.d.ts +0 -1
  114. package/dist/src/to/toCellDate.js +0 -12
  115. package/dist/src/to/toCellDate.js.map +0 -1
  116. package/dist/src/to/toDateStr.d.ts +0 -1
  117. package/dist/src/to/toDateStr.js +0 -14
  118. package/dist/src/to/toDateStr.js.map +0 -1
  119. package/dist/src/to/toGB.d.ts +0 -1
  120. package/dist/src/to/toGB.js +0 -47
  121. package/dist/src/to/toGB.js.map +0 -1
  122. package/dist/src/to/toGH.d.ts +0 -1
  123. package/dist/src/to/toGH.js +0 -36
  124. package/dist/src/to/toGH.js.map +0 -1
  125. package/dist/src/to/toH.d.ts +0 -1
  126. package/dist/src/to/toH.js +0 -36
  127. package/dist/src/to/toH.js.map +0 -1
  128. package/dist/src/to/toInetAton.d.ts +0 -1
  129. package/dist/src/to/toInetAton.js +0 -18
  130. package/dist/src/to/toInetAton.js.map +0 -1
  131. package/dist/src/to/toInetNtoa.d.ts +0 -1
  132. package/dist/src/to/toInetNtoa.js +0 -16
  133. package/dist/src/to/toInetNtoa.js.map +0 -1
  134. package/dist/src/to/toJSON.d.ts +0 -1
  135. package/dist/src/to/toJSON.js +0 -14
  136. package/dist/src/to/toJSON.js.map +0 -1
  137. package/dist/src/to/toLower.d.ts +0 -1
  138. package/dist/src/to/toLower.js +0 -14
  139. package/dist/src/to/toLower.js.map +0 -1
  140. package/dist/src/to/toNull.d.ts +0 -1
  141. package/dist/src/to/toNull.js +0 -11
  142. package/dist/src/to/toNull.js.map +0 -1
  143. package/dist/src/to/toNum.d.ts +0 -1
  144. package/dist/src/to/toNum.js +0 -40
  145. package/dist/src/to/toNum.js.map +0 -1
  146. package/dist/src/to/toPhone.d.ts +0 -1
  147. package/dist/src/to/toPhone.js +0 -24
  148. package/dist/src/to/toPhone.js.map +0 -1
  149. package/dist/src/to/toPoolName.d.ts +0 -1
  150. package/dist/src/to/toPoolName.js +0 -19
  151. package/dist/src/to/toPoolName.js.map +0 -1
  152. package/dist/src/to/toPortions.d.ts +0 -1
  153. package/dist/src/to/toPortions.js +0 -16
  154. package/dist/src/to/toPortions.js.map +0 -1
  155. package/dist/src/to/toRangeip.d.ts +0 -1
  156. package/dist/src/to/toRangeip.js +0 -24
  157. package/dist/src/to/toRangeip.js.map +0 -1
  158. package/dist/src/to/toSqlUpdateMany.d.ts +0 -1
  159. package/dist/src/to/toSqlUpdateMany.js +0 -39
  160. package/dist/src/to/toSqlUpdateMany.js.map +0 -1
  161. package/dist/src/to/toTimestamp.d.ts +0 -6
  162. package/dist/src/to/toTimestamp.js +0 -11
  163. package/dist/src/to/toTimestamp.js.map +0 -1
  164. package/dist/src/to/toTrim.d.ts +0 -1
  165. package/dist/src/to/toTrim.js +0 -10
  166. package/dist/src/to/toTrim.js.map +0 -1
  167. package/dist/src/to/toUndefined.d.ts +0 -1
  168. package/dist/src/to/toUndefined.js +0 -11
  169. package/dist/src/to/toUndefined.js.map +0 -1
  170. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,4495 @@
1
+ /**
2
+ * Parse a human-typed string of function-like arguments into a normalized array of JS values.
3
+ *
4
+ * @summary
5
+ * Splits by **top-level commas** (ignoring commas that appear inside quotes, parentheses,
6
+ * brackets, or braces) and **coerces** each token to a sensible JavaScript type:
7
+ * `null`, `undefined`, booleans, numbers (including `Infinity`/`-Infinity`), strings
8
+ * (with quote stripping and unescaping), and JSON objects/arrays. Tokens that look like
9
+ * a macro or call marker (start with `$` and end with `)`) are returned **as is**.
10
+ *
11
+ * @remarks
12
+ * ### How parsing works
13
+ * 1. **Input normalization**
14
+ * - Non-string inputs are returned as a single-element array `[value]`.
15
+ * - Leading/trailing whitespace is trimmed.
16
+ * - If the entire string is wrapped in square brackets (`[...]`), the brackets are
17
+ * removed (so the function accepts both `a,b,c` and `[a, b, c]`).
18
+ * - Empty input (after trimming or after removing `[...]`) yields `[]`.
19
+ *
20
+ * 2. **Tokenization by top-level commas**
21
+ * - The string is scanned left-to-right.
22
+ * - The parser tracks nesting **depth** for `()`, `[]`, `{}` and whether it is
23
+ * currently **inside quotes**. A comma only splits tokens at **depth 0** and
24
+ * **outside quotes**.
25
+ *
26
+ * 3. **Per-token coercion (in this order)**
27
+ * - **Macro / call marker**: If a token starts with `$`, contains `(`, and ends
28
+ * with `)`, it is returned unchanged (e.g., `"$env(PATH)"`).
29
+ * - **Literals**: `null` → `null`, `undefined` → `undefined`.
30
+ * - **Booleans**: Using {@link isStrBool} + {@link formatToBool} (e.g., `"true"`,
31
+ * `"False"`, `"yes"`, `"0"` depending on your implementation).
32
+ * - **Numbers**: Using {@link formatToNum}. If the result is finite, it is returned.
33
+ * Explicit `"Infinity"` and `"-Infinity"` are also supported.
34
+ * - **Quoted strings**: `'text'` or `"text"` → inner text with escapes processed
35
+ * (`\\` → `\`, `\'` → `'`, `\"` → `"`).
36
+ * - **JSON**: If token begins with `{` and ends with `}`, or begins with `[` and
37
+ * ends with `]`, the function attempts `jsonDecode`. On failure, the raw string
38
+ * is returned.
39
+ * - **Fallback**: Raw token as string.
40
+ *
41
+ * ### Escaping inside quotes
42
+ * - Backslash escaping is supported while inside quotes:
43
+ * - `\\` for a literal backslash
44
+ * - `\"` inside double quotes
45
+ * - `\'` inside single quotes
46
+ *
47
+ * ### Non-throwing behavior
48
+ * - The function aims to be **robust** and **non-throwing**. Invalid JSON will be
49
+ * returned as a plain string rather than crashing.
50
+ *
51
+ * ### Security considerations
52
+ * - The parser **does not** evaluate code; it only returns strings or parsed values.
53
+ * If you plan to execute anything returned (e.g., tokens starting with `$...`),
54
+ * do so in a sandbox with explicit allow-lists.
55
+ *
56
+ * ### Limitations
57
+ * - Numerical parsing relies on {@link formatToNum}. Extremely large or high-precision
58
+ * decimals may still be subject to JavaScript `number` precision limits unless your
59
+ * `formatToNum` converts to a safer representation.
60
+ * - Only basic backslash escapes are handled in quoted strings (no `\uXXXX` decoding here).
61
+ * - Whitespace outside quotes is trimmed from each token; internal whitespace is preserved.
62
+ *
63
+ * @example
64
+ * // Basic values
65
+ * formatStrToFuncArgs('1, true, "hello"'); // => [1, true, "hello"]
66
+ *
67
+ * @example
68
+ * // Bracket-wrapped list
69
+ * formatStrToFuncArgs('[1, 2, 3]'); // => [1, 2, 3]
70
+ *
71
+ * @example
72
+ * // Nested structures and quoting
73
+ * formatStrToFuncArgs('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
74
+ *
75
+ * @example
76
+ * // Booleans, null/undefined, and Infinity
77
+ * formatStrToFuncArgs('yes, NO, null, undefined, Infinity, -Infinity');
78
+ * // => [true, false, null, undefined, Infinity, -Infinity]
79
+ *
80
+ * @example
81
+ * // Macro-like token (returned as-is)
82
+ * formatStrToFuncArgs('$env(PATH)'); // => ["$env(PATH)"]
83
+ *
84
+ * @example
85
+ * // Escapes inside quotes
86
+ * formatStrToFuncArgs('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
87
+ * // => ['He said: "Hi"', "It's ok", "\\path"]
88
+ *
89
+ * @example
90
+ * // Empty and whitespace inputs
91
+ * formatStrToFuncArgs(' '); // => []
92
+ * formatStrToFuncArgs('[]'); // => []
93
+ * formatStrToFuncArgs('[ ]'); // => []
94
+ * formatStrToFuncArgs(' [ a , b ] '); // => ["a", "b"]
95
+ *
96
+ * @param value - Raw string containing comma-separated arguments.
97
+ * If `value` is **not** a string, the function returns `[value]` unchanged.
98
+ *
99
+ * @returns An array of coerced values (`unknown[]`). Each item is one parsed token.
100
+ *
101
+ * @see isStrBool
102
+ * @see formatToBool
103
+ * @see formatToNum
104
+ * @see jsonDecode
105
+ *
106
+ * @public
107
+ * @since 2.0.0
108
+ */
109
+ declare function formatStrToFuncArgs(value: string): unknown[];
110
+
111
+ /**
112
+ * Splits an input array into smaller subarrays (portions) of a given fixed size.
113
+ *
114
+ * @summary
115
+ * Returns an array of chunks, where each chunk contains at most `portionLength` elements.
116
+ * The final chunk may contain fewer elements if the input array length is not evenly divisible
117
+ * by `portionLength`.
118
+ *
119
+ * @typeParam T - Type of the elements in the input array.
120
+ *
121
+ * @param arr - The source array to be split. It can be any readonly array (or tuple).
122
+ * @param portionLength - The desired size of each portion. Must be a **positive integer**.
123
+ *
124
+ * @returns A new two-dimensional array (`T[][]`), where each inner array is one portion.
125
+ * If `portionLength` is not a positive integer, an empty array is returned.
126
+ *
127
+ * @remarks
128
+ * - This function is **non-mutating**: the original array is never modified.
129
+ * - If `portionLength` exceeds the array length, the result will be a single chunk
130
+ * containing the entire array.
131
+ * - If the input array is empty, the result is an empty array.
132
+ * - Uses `Array.prototype.slice()` internally, so the returned chunks are **shallow copies**.
133
+ *
134
+ * ### Performance
135
+ * - Time complexity: **O(n)** — each element is visited exactly once.
136
+ * - Space complexity: **O(n)** — proportional to the total number of elements copied.
137
+ * - For extremely large arrays (millions of elements), prefer a streaming approach
138
+ * if memory is a concern.
139
+ *
140
+ * ### Edge cases
141
+ * - `portionLength <= 0` → returns `[]`.
142
+ * - `portionLength` is not an integer (e.g. `2.5`, `NaN`) → returns `[]`.
143
+ * - `arr.length === 0` → returns `[]`.
144
+ * - Works correctly with frozen arrays and readonly tuples.
145
+ *
146
+ * @example
147
+ * // Split an array into groups of 3
148
+ * splitArrToPortions([1, 2, 3, 4, 5, 6, 7], 3);
149
+ * // => [[1, 2, 3], [4, 5, 6], [7]]
150
+ *
151
+ * @example
152
+ * // Portion length larger than array
153
+ * splitArrToPortions(['a', 'b'], 5);
154
+ * // => [['a', 'b']]
155
+ *
156
+ * @example
157
+ * // Non-integer or invalid sizes
158
+ * splitArrToPortions([1, 2, 3], 0); // => []
159
+ * splitArrToPortions([1, 2, 3], -2); // => []
160
+ * splitArrToPortions([1, 2, 3], NaN); // => []
161
+ *
162
+ * @example
163
+ * // Works with readonly arrays
164
+ * const input = [10, 20, 30, 40] as const;
165
+ * const result = splitArrToPortions(input, 2);
166
+ * // result: [[10, 20], [30, 40]]
167
+ *
168
+ * @category Array
169
+ * @public
170
+ * @since 2.0.0
171
+ */
172
+ declare function splitArrToPortions<T>(arr: readonly T[], portionLength: number): T[][];
173
+
174
+ /**
175
+ * Converts any given value into a normalized boolean (`true` / `false`).
176
+ *
177
+ * @summary
178
+ * Performs **loose coercion** of different input types into a `boolean`
179
+ * following predictable rules for numbers, strings, and actual boolean values.
180
+ * Non-recognized values always return `false`.
181
+ *
182
+ * @param value - Any unknown input that should be interpreted as a boolean.
183
+ *
184
+ * @returns The normalized boolean result (`true` or `false`).
185
+ *
186
+ * @remarks
187
+ * This function is designed to **gracefully handle** a wide variety of input forms —
188
+ * including primitive values, numeric types, and user-typed strings (like `"yes"`, `"no"`, `"on"`, `"off"`).
189
+ *
190
+ * ### Conversion Rules (in order of precedence)
191
+ * 1. **Native booleans** → returned as-is.
192
+ * - `true` → `true`
193
+ * - `false` → `false`
194
+ *
195
+ * 2. **Positive numbers** → interpreted as `true`.
196
+ * - `isNumP(value)` check passes (typically `> 0`).
197
+ * - Examples: `1`, `42`, `3.14` → `true`
198
+ *
199
+ * 3. **Zero or negative numbers** → interpreted as `false`.
200
+ * - `isNumNZ(value)` check passes (typically `<= 0`).
201
+ * - Examples: `0`, `-1` → `false`
202
+ *
203
+ * 4. **Truthy strings** → `"true"`, `"1"`, `"yes"`, `"on"` (case-insensitive)
204
+ * - `"TrUe"` → `true`
205
+ * - `" YES "` → `true`
206
+ *
207
+ * 5. **Falsy strings** → `"false"`, `"0"`, `"no"`, `"off"` (case-insensitive)
208
+ * - `"False"` → `false`
209
+ * - `" off "` → `false`
210
+ *
211
+ * 6. **Everything else** → `false`
212
+ * - `null`, `undefined`, `NaN`, empty string, symbols, objects, arrays, etc.
213
+ *
214
+ * ### String Handling
215
+ * - Strings are **trimmed** and **lower-cased** before comparison.
216
+ * - Case and whitespace are ignored.
217
+ * - Empty strings (`""`) return `false`.
218
+ *
219
+ * ### Error Safety
220
+ * - The function **never throws**.
221
+ * - Non-primitive or unexpected types are handled safely and result in `false`.
222
+ *
223
+ * ### Performance
224
+ * - Time complexity: **O(1)**.
225
+ * - Space complexity: **O(1)**.
226
+ *
227
+ * ### Examples
228
+ *
229
+ * @example
230
+ * // Native booleans
231
+ * formatToBool(true); // => true
232
+ * formatToBool(false); // => false
233
+ *
234
+ * @example
235
+ * // Numeric values
236
+ * formatToBool(1); // => true
237
+ * formatToBool(0); // => false
238
+ * formatToBool(-5); // => false
239
+ *
240
+ * @example
241
+ * // String values
242
+ * formatToBool('yes'); // => true
243
+ * formatToBool('No'); // => false
244
+ * formatToBool('TRUE'); // => true
245
+ * formatToBool('false'); // => false
246
+ * formatToBool('on'); // => true
247
+ * formatToBool('off'); // => false
248
+ *
249
+ * @example
250
+ * // Mixed and invalid inputs
251
+ * formatToBool(null); // => false
252
+ * formatToBool(undefined); // => false
253
+ * formatToBool([]); // => false
254
+ * formatToBool({}); // => false
255
+ * formatToBool('maybe'); // => false
256
+ *
257
+ * @see isBool
258
+ * @see isNumP
259
+ * @see isNumNZ
260
+ * @see isStrFilled
261
+ *
262
+ * @category Conversion
263
+ * @public
264
+ * @since 2.0.0
265
+ */
266
+ declare function formatToBool(value: unknown): boolean;
267
+
268
+ /**
269
+ * Waits asynchronously for the specified amount of time.
270
+ *
271
+ * @summary
272
+ * A tiny promise-based delay utility that resolves after `timeout` milliseconds.
273
+ * It wraps `setTimeout` in a `Promise`, making it convenient to use with
274
+ * `async/await` or as part of larger promise chains.
275
+ *
276
+ * @param timeout - The delay duration in **milliseconds** before the promise resolves.
277
+ * @defaultValue 0
278
+ *
279
+ * @returns A `Promise<void | true>` that settles after the given delay.
280
+ *
281
+ * @example
282
+ * // Basic usage: pause for ~500 ms
283
+ * await wait(500);
284
+ * console.log('Half a second later…');
285
+ *
286
+ * @example
287
+ * // Measure elapsed time
288
+ * const started = Date.now();
289
+ * await wait(1200);
290
+ * const elapsed = Date.now() - started; // ~= 1200ms (subject to timer clamping and scheduling)
291
+ *
292
+ * @example
293
+ * // Use inside a retry/backoff loop
294
+ * for (let attempt = 1; attempt <= 5; attempt++) {
295
+ * try {
296
+ * await doWork();
297
+ * break;
298
+ * } catch (err) {
299
+ * // exponential backoff between attempts
300
+ * await wait(2 ** attempt * 100);
301
+ * }
302
+ * }
303
+ *
304
+ * @example
305
+ * // Parallel delays (resolve when the longest finishes)
306
+ * await Promise.all([wait(100), wait(250), wait(50)]);
307
+ *
308
+ * @remarks
309
+ * - **Timing accuracy:** JavaScript timers are **best-effort** and may be delayed
310
+ * by event-loop load, CPU throttling, tab being backgrounded, or platform-specific
311
+ * clamping. Treat `timeout` as a *minimum* delay, not an exact scheduler.
312
+ * - **Negative or non-finite values:** Passing `<= 0`, `NaN`, or a non-finite value
313
+ * effectively behaves like `0` and resolves on a future macrotask tick.
314
+ * - **Cancellation:** This helper **does not support cancellation**. If you need to
315
+ * abort a wait, consider a variant that accepts an `AbortSignal` and clears the
316
+ * timer when aborted.
317
+ * - **Event loop semantics:** `setTimeout(0)` schedules a **macrotask**; it does not
318
+ * run synchronously. Code after `await wait(0)` will execute on a subsequent turn
319
+ * of the event loop.
320
+ *
321
+ * Notes:
322
+ * - Suitable for throttling UI interactions, pacing network retries, and writing
323
+ * deterministic tests (with caution re: flakiness).
324
+ * - Keep delays small in performance-critical code paths; prefer debouncing or
325
+ * requestAnimationFrame for UI-animation pacing when appropriate.
326
+ *
327
+ * Complexity:
328
+ * - Time: **O(1)** (scheduling a single timer)
329
+ * - Space: **O(1)** (a promise and a timer reference)
330
+ *
331
+ * Performance:
332
+ * - The function allocates a single promise and a timer handle.
333
+ * - Timer resolution is platform dependent; Node.js and browsers may clamp very
334
+ * small delays to a minimum threshold under load.
335
+ *
336
+ * Security:
337
+ * - No I/O, side effects, or data exposure. Purely schedules a future resolution.
338
+ *
339
+ * <b>Returns remarks</b>:
340
+ * The internal promise resolves with the value `true`, but callers typically
341
+ * use `await wait(...)` and ignore the value. If you need a strictly `void`
342
+ * result, you can cast or ignore the resolution value.
343
+ *
344
+ * @category Utilities • Timing
345
+ * @since 1.0.0
346
+ * @see {@link https://developer.mozilla.org/docs/Web/API/setTimeout MDN: setTimeout}
347
+ */
348
+ declare function wait(timeout?: number): Promise<void>;
349
+
350
+ /**
351
+ * Represents a human-readable breakdown of a time duration
352
+ * into its fundamental components — **days**, **hours**, **minutes**, and **seconds**.
353
+ *
354
+ * @remarks
355
+ * This interface is used by time utility functions such as
356
+ * {@link secondsToParts} and {@link partsToSeconds} to represent durations
357
+ * in a normalized structure that is easy to read, format, or serialize.
358
+ *
359
+ * Each field is an **integer number** representing the whole count of that unit.
360
+ * None of the fields are fractional, and they are expected to follow
361
+ * these conventional bounds when generated by {@link secondsToParts}:
362
+ *
363
+ * ```
364
+ * days ≥ 0
365
+ * hours ∈ [0, 23]
366
+ * minutes ∈ [0, 59]
367
+ * seconds ∈ [0, 59]
368
+ * ```
369
+ *
370
+ * However, when constructing manually, these constraints are **not enforced**
371
+ * by TypeScript — it is up to the user or calling function to maintain validity.
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * // Example 1: Typical decomposition
376
+ * const t: TimeParts = { days: 1, hours: 2, minutes: 30, seconds: 45 };
377
+ *
378
+ * // Example 2: Used with utility converters
379
+ * const total = partsToSeconds(t); // -> 95445
380
+ * const back = secondsToParts(total); // -> same structure again
381
+ * ```
382
+ *
383
+ * @example
384
+ * ```ts
385
+ * // Example 3: Display formatting
386
+ * const p: TimeParts = { days: 0, hours: 5, minutes: 3, seconds: 9 };
387
+ * console.log(`${p.hours}h ${p.minutes}m ${p.seconds}s`);
388
+ * // -> "5h 3m 9s"
389
+ * ```
390
+ *
391
+ * @property days - Whole number of days (24-hour periods).
392
+ * @property hours - Whole number of hours in the remaining day (0–23 typical).
393
+ * @property minutes - Whole number of minutes (0–59 typical).
394
+ * @property seconds - Whole number of seconds (0–59 typical).
395
+ *
396
+ * @see {@link secondsToParts} — converts total seconds into this structure.
397
+ * @see {@link partsToSeconds} — converts this structure back into total seconds.
398
+ *
399
+ * @public
400
+ * @category Date & Time
401
+ * @since 2.0.0
402
+ */
403
+ interface TimeParts {
404
+ days: number;
405
+ hours: number;
406
+ minutes: number;
407
+ seconds: number;
408
+ }
409
+
410
+ /**
411
+ * Floors a given {@link Date} object down to the nearest time interval in minutes.
412
+ *
413
+ * @remarks
414
+ * This utility function is commonly used for time bucketing, grouping logs, or
415
+ * aligning timestamps to fixed intervals (e.g. 5-minute or 15-minute marks).
416
+ *
417
+ * It takes an arbitrary `Date` and returns a **new** `Date` instance (it does not
418
+ * mutate the input) where:
419
+ *
420
+ * - The `minutes` value is floored down to the nearest multiple of `everyMinutes`.
421
+ * - `seconds` and `milliseconds` are reset to `0`.
422
+ * - The hour and day remain unchanged.
423
+ *
424
+ * The step is automatically clamped to the range **1 – 60 minutes** to prevent
425
+ * invalid or nonsensical values.
426
+ *
427
+ * The function allocates a single new `Date` object.
428
+ * It is safe for high-frequency use in real-time systems and event batching.
429
+ *
430
+ * @param everyMinutes - The step interval (in minutes) used for rounding down.
431
+ * Must be a positive finite number.
432
+ * Values below 1 are treated as 1, values above 60 as 60.
433
+ *
434
+ * @param date - The input date to be floored.
435
+ * Defaults to the current time (`new Date()`).
436
+ *
437
+ * @returns A **new** `Date` instance, representing the same hour as the input,
438
+ * but with minutes rounded down to the nearest `everyMinutes` multiple.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * // Example 1: Floor to the nearest 15-minute mark
443
+ * const d = new Date('2025-10-18T10:43:27');
444
+ * floorDateToMinutes(15, d);
445
+ * // -> 2025-10-18T10:30:00.000Z
446
+ * ```
447
+ *
448
+ * @example
449
+ * ```ts
450
+ * // Example 2: Using default date (current time)
451
+ * const nowFloored = floorDateToMinutes(10);
452
+ * // -> e.g. 2025-10-18T09:20:00.000Z
453
+ * ```
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * // Example 3: Clamp behavior
458
+ * floorDateToMinutes(-5, new Date()); // treated as 1 minute
459
+ * floorDateToMinutes(999, new Date()); // treated as 60 minutes
460
+ * ```
461
+ *
462
+ * @throws Never throws — invalid step values are automatically normalized.
463
+ *
464
+ * @see {@link Date#setMinutes} for the underlying mutation logic.
465
+ * @see {@link Date#getMinutes} for how minutes are extracted from a Date.
466
+ *
467
+ * @public
468
+ * @category Date & Time
469
+ * @since 2.0.0
470
+ */
471
+ declare function floorDateToMinutes(everyMinutes?: number, date?: Date): Date;
472
+
473
+ /**
474
+ * Formats a {@link Date} object into a human-readable timestamp string
475
+ * using the pattern `"YYYY-MM-DD HH:mm:ss"`.
476
+ *
477
+ * @remarks
478
+ * This function is a simple and locale-independent date formatter that always
479
+ * outputs a **24-hour clock** timestamp with leading zeros for all numeric parts.
480
+ *
481
+ * It does **not** depend on the user's locale or time zone settings beyond what
482
+ * is stored in the provided `Date` object. If you pass a `Date` constructed
483
+ * from UTC or local time, the formatted output will reflect that same basis.
484
+ *
485
+ * Each date/time component (month, day, hours, minutes, seconds) is padded to
486
+ * two digits using {@link String.padStart}, ensuring consistent width such as
487
+ * `2025-03-07 09:04:02`.
488
+ *
489
+ * - The format is fixed-width and consistent — ideal for logs, filenames,
490
+ * and database-friendly timestamps.
491
+ * - The output is **not ISO 8601** (which uses a `'T'` separator and optional
492
+ * timezone offset).
493
+ * Example: ISO → `"2025-10-18T10:43:27Z"`
494
+ * This function → `"2025-10-18 10:43:27"`.
495
+ *
496
+ * @param date - The date to format. Defaults to the **current system time**
497
+ * (`new Date()`).
498
+ *
499
+ * @returns A formatted timestamp string in `"YYYY-MM-DD HH:mm:ss"` form.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * // Example 1: Specific date
504
+ * const d = new Date('2025-10-18T10:43:27Z');
505
+ * formatDateToString(d);
506
+ * // -> "2025-10-18 10:43:27"
507
+ * ```
508
+ *
509
+ * @example
510
+ * ```ts
511
+ * // Example 2: Default (current) date
512
+ * formatDateToString();
513
+ * // -> e.g. "2025-10-18 12:07:55"
514
+ * ```
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * // Example 3: Padding behavior
519
+ * const d = new Date('2025-03-07T09:04:02');
520
+ * formatDateToString(d);
521
+ * // -> "2025-03-07 09:04:02"
522
+ * ```
523
+ *
524
+ * @throws Never throws.
525
+ *
526
+ * @see {@link Date} for JavaScript’s native date-handling API.
527
+ * @see {@link Intl.DateTimeFormat} for locale-aware formatting if needed.
528
+ *
529
+ * @public
530
+ * @category Date & Time
531
+ * @since 2.0.0
532
+ */
533
+ declare function formatDateToString(date?: Date): string;
534
+
535
+ /**
536
+ * Converts a partial {@link TimeParts} structure (days, hours, minutes, seconds)
537
+ * into a total number of **seconds**.
538
+ *
539
+ * @remarks
540
+ * This helper provides a simple way to normalize human-readable time components
541
+ * into a single scalar duration in seconds.
542
+ * It can be useful for:
543
+ * - time-based arithmetic (e.g., adding offsets to timestamps),
544
+ * - scheduling or delay computation,
545
+ * - serializing durations into numeric fields (e.g., databases or APIs).
546
+ *
547
+ * All fields (`days`, `hours`, `minutes`, `seconds`) are **optional**; any missing
548
+ * value defaults to `0`. The calculation uses fixed conversion factors:
549
+ *
550
+ * - 1 day = 86 400 seconds
551
+ * - 1 hour = 3 600 seconds
552
+ * - 1 minute = 60 seconds
553
+ *
554
+ * - Fractional or negative numbers are accepted and processed arithmetically.
555
+ * Example: `{ minutes: 1.5 }` → `90`; `{ hours: -1 }` → `-3600`.
556
+ * - The function performs no validation; it assumes numeric input.
557
+ * TypeScript typing (`number`) ensures intended usage.
558
+ *
559
+ * @param parts - A partial object containing any subset of time fields.
560
+ * Missing values default to zero.
561
+ *
562
+ * @returns The total number of seconds represented by the provided time parts.
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * // Example 1: Simple conversion
567
+ * partsToSeconds({ hours: 1, minutes: 30 }); // -> 5400
568
+ *
569
+ * // Example 2: Full time span
570
+ * partsToSeconds({ days: 2, hours: 3, minutes: 5, seconds: 10 });
571
+ * // -> 183910
572
+ *
573
+ * // Example 3: Partial / missing fields
574
+ * partsToSeconds({}); // -> 0
575
+ * partsToSeconds({ minutes: 5 }); // -> 300
576
+ * ```
577
+ *
578
+ * @throws Never throws.
579
+ *
580
+ * @see {@link secondsToParts} — the inverse operation that expands seconds back into components.
581
+ *
582
+ * @public
583
+ * @category Date & Time
584
+ * @since 2.0.0
585
+ */
586
+ declare function partsToSeconds(parts: {
587
+ days?: number;
588
+ hours?: number;
589
+ minutes?: number;
590
+ seconds?: number;
591
+ }): number;
592
+
593
+ /**
594
+ * Decomposes a total number of seconds into discrete time components:
595
+ * **days**, **hours**, **minutes**, and **seconds**.
596
+ *
597
+ * @remarks
598
+ * This is the inverse operation of {@link partsToSeconds}.
599
+ * It converts a flat duration (in seconds) into a more human-readable structure
600
+ * suitable for display, logging, or formatting.
601
+ *
602
+ * The function performs integer division using {@link Math.floor} for each component
603
+ * and ensures that the result satisfies:
604
+ *
605
+ * ```
606
+ * 0 <= hours < 24
607
+ * 0 <= minutes < 60
608
+ * 0 <= seconds < 60
609
+ * ```
610
+ *
611
+ * Any fractional part of the input (e.g., `12.75`) is truncated (floored) to the
612
+ * nearest lower whole second.
613
+ * Negative or non-finite inputs are considered invalid and will throw an error.
614
+ *
615
+ * - Uses only a few arithmetic operations and is **O(1)**.
616
+ * - Safe for real-time conversions or high-frequency usage (e.g., monitoring dashboards).
617
+ *
618
+ * @param total - Total duration in seconds.
619
+ * Must be a **finite, non-negative number**.
620
+ *
621
+ * @returns A {@link TimeParts} object with integer fields:
622
+ * - `days`
623
+ * - `hours`
624
+ * - `minutes`
625
+ * - `seconds`
626
+ *
627
+ * @example
628
+ * ```ts
629
+ * // Example 1: Basic conversion
630
+ * secondsToParts(3661);
631
+ * // -> { days: 0, hours: 1, minutes: 1, seconds: 1 }
632
+ * ```
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * // Example 2: Multi-day value
637
+ * secondsToParts(90061);
638
+ * // -> { days: 1, hours: 1, minutes: 1, seconds: 1 }
639
+ * ```
640
+ *
641
+ * @example
642
+ * ```ts
643
+ * // Example 3: Invalid input
644
+ * secondsToParts(-10); // throws Error("Invalid total seconds")
645
+ * secondsToParts(NaN); // throws Error("Invalid total seconds")
646
+ * ```
647
+ *
648
+ * @throws {Error}
649
+ * Thrown when `total` is not a finite, non-negative number.
650
+ *
651
+ * @see {@link partsToSeconds} — the complementary function that aggregates components into seconds.
652
+ * @see {@link TimeParts} — the return type describing the breakdown of time.
653
+ *
654
+ * @public
655
+ * @category Date & Time
656
+ * @since 2.0.0
657
+ */
658
+ declare function secondsToParts(total: number): TimeParts;
659
+
660
+ /**
661
+ * Options that control how IPv4 ranges are iterated and materialized.
662
+ *
663
+ * @remarks
664
+ * These options are primarily consumed by {@link rangeIPv4} and {@link rangeIPv4ToArr}.
665
+ * They let you include/exclude the network and broadcast addresses when the input
666
+ * is a CIDR block, and limit the maximum number of items when materializing to an array.
667
+ *
668
+ * @public
669
+ * @category IPv4
670
+ * @since 2.0.0
671
+ */
672
+ interface RangeIPv4Options {
673
+ /**
674
+ * Hard cap on the number of elements to materialize into a returned array.
675
+ *
676
+ * @remarks
677
+ * This option is **only** consulted by {@link rangeIPv4ToArr}. It prevents
678
+ * accidentally allocating huge arrays when the supplied range is very large
679
+ * (e.g. `0.0.0.0/0` contains 4,294,967,296 addresses).
680
+ *
681
+ * If the computed range size exceeds this limit, an error will be thrown.
682
+ *
683
+ * @defaultValue `1_000_000`
684
+ * @example
685
+ * ```ts
686
+ * // Will throw because /16 has 65,536 addresses (> 10_000)
687
+ * rangeIPv4ToArr('10.0.0.0/16', undefined, { limit: 10_000 })
688
+ * ```
689
+ */
690
+ limit?: number;
691
+ /**
692
+ * Whether to include the *network* address when iterating a CIDR range.
693
+ *
694
+ * @remarks
695
+ * This flag is only applied when the input is a CIDR (e.g. `"192.168.0.0/24"`).
696
+ * For non-CIDR, ad-hoc ranges, network/broadcast semantics are not inferred.
697
+ *
698
+ * For `/31` and `/32` specifically, there is no distinct network/broadcast
699
+ * address to exclude, so this flag has no effect.
700
+ *
701
+ * @defaultValue `true`
702
+ * @example
703
+ * ```ts
704
+ * // Exclude 192.168.1.0 from a /24 network
705
+ * [...rangeIPv4('192.168.1.0/24', undefined, { includeNetwork: false })];
706
+ * ```
707
+ */
708
+ includeNetwork?: boolean;
709
+ /**
710
+ * Whether to include the *broadcast* address when iterating a CIDR range.
711
+ *
712
+ * @remarks
713
+ * This flag is only applied when the input is a CIDR (e.g. `"192.168.0.0/24"`).
714
+ * For `/31` and `/32`, there is no broadcast in the traditional sense,
715
+ * so this flag has no effect.
716
+ *
717
+ * @defaultValue `true`
718
+ * @example
719
+ * ```ts
720
+ * // Exclude 192.168.1.255 from a /24 network
721
+ * [...rangeIPv4('192.168.1.0/24', undefined, { includeBroadcast: false })];
722
+ * ```
723
+ */
724
+ includeBroadcast?: boolean;
725
+ }
726
+
727
+ /**
728
+ * Converts a CIDR block into its inclusive start/end IPv4 addresses.
729
+ *
730
+ * @remarks
731
+ * The function validates the CIDR notation and returns a tuple of dotted-quad
732
+ * IPv4 strings representing the first and last addresses in the block.
733
+ * For `/0` the range spans the entire IPv4 address space. For `/32` the start
734
+ * and end are the same single address.
735
+ *
736
+ * @param cidr - CIDR notation string, e.g. `"192.168.1.0/24"` or `"10.0.0.1/32"`.
737
+ * @returns A tuple `[start, end]` in dotted-quad form, or `null` if input is invalid.
738
+ *
739
+ * @example
740
+ * ```ts
741
+ * cidrToRange('192.168.1.0/24'); // ['192.168.1.0','192.168.1.255']
742
+ * cidrToRange('10.0.0.1/32'); // ['10.0.0.1','10.0.0.1']
743
+ * cidrToRange('bad'); // null
744
+ * ```
745
+ *
746
+ * @throws Never throws; returns `null` on invalid input.
747
+ * @see {@link parseIPv4} to parse an IPv4 string to a 32-bit number.
748
+ * @see {@link toIPv4} to convert a number back to dotted-quad.
749
+ * @public
750
+ * @category IPv4
751
+ * @since 2.0.0
752
+ */
753
+ declare function cidrToRange(cidr: string): [string, string] | null;
754
+
755
+ /**
756
+ * Converts a dotted-decimal IPv4 address string (e.g. `"192.168.0.1"`)
757
+ * into its **32-bit unsigned integer** representation.
758
+ *
759
+ * @remarks
760
+ * This function performs a strict validation of the IPv4 address and encodes
761
+ * each of its four octets into a 32-bit number using **big-endian (network byte order)**.
762
+ *
763
+ * The resulting number is in the range `0..4_294_967_295` (`0xFFFFFFFF`),
764
+ * where:
765
+ *
766
+ * - `"0.0.0.0"` → `0`
767
+ * - `"255.255.255.255"` → `4294967295`
768
+ *
769
+ * This representation is particularly useful for:
770
+ * - performing numeric range comparisons (e.g., IP ranges, CIDR checks);
771
+ * - storing IPv4 values compactly in binary structures or databases;
772
+ * - bitwise operations such as masking and subnet arithmetic.
773
+ *
774
+ * - The conversion uses a {@link DataView} and explicit byte writes
775
+ * to guarantee consistent big-endian behavior across platforms.
776
+ * - The output number is safe for 32-bit unsigned arithmetic via `>>> 0`.
777
+ * - If you need the inverse operation, see {@link numToIpAddr}.
778
+ *
779
+ * @param ip - The IPv4 address in dotted-quad string form.
780
+ *
781
+ * @returns A 32-bit **unsigned integer** representing the given IPv4 address.
782
+ *
783
+ * @example
784
+ * ```ts
785
+ * // Example 1: Simple conversion
786
+ * ipAddrToNum("192.168.0.1");
787
+ * // -> 3232235521
788
+ *
789
+ * // Example 2: Edge values
790
+ * ipAddrToNum("0.0.0.0"); // -> 0
791
+ * ipAddrToNum("255.255.255.255"); // -> 4294967295
792
+ * ```
793
+ *
794
+ * @example
795
+ * ```ts
796
+ * // Example 3: Invalid input
797
+ * ipAddrToNum("192.168.1"); // throws Error("Invalid IPv4 address")
798
+ * ipAddrToNum("256.0.0.1"); // throws Error("Invalid IPv4 address")
799
+ * ipAddrToNum("abc.def.ghi.jkl"); // throws Error("Invalid IPv4 address")
800
+ * ```
801
+ *
802
+ * @throws {Error}
803
+ * Thrown when:
804
+ * - The input does not contain exactly four parts separated by dots.
805
+ * - Any octet is not an integer between 0 and 255 inclusive.
806
+ *
807
+ * @see {@link numToIpAddr} — converts a 32-bit integer back to an IPv4 string.
808
+ * @see {@link parseIPv4} — similar numeric parser using bitwise operations.
809
+ *
810
+ * @public
811
+ * @category Network & IP
812
+ * @since 2.0.0
813
+ */
814
+ declare function ipAddrToNum(ip: string): number;
815
+
816
+ /**
817
+ * Converts a 32-bit unsigned integer (numeric IPv4 representation)
818
+ * back into its dotted-decimal string form (e.g. `"192.168.0.1"`).
819
+ *
820
+ * @remarks
821
+ * This is the inverse of {@link ipAddrToNum}.
822
+ * It interprets the input number as a **big-endian (network-byte-order)**
823
+ * IPv4 value, extracting each of the four octets and joining them into
824
+ * the standard dotted-quad notation.
825
+ *
826
+ * If the input is not a valid finite number (checked via {@link isNumP}),
827
+ * an empty string `""` is returned instead of throwing an exception.
828
+ *
829
+ * The resulting string always consists of **exactly four decimal octets**
830
+ * separated by dots, with each octet in the range `0–255`.
831
+ *
832
+ * - Internally uses {@link DataView} to ensure consistent big-endian behavior
833
+ * across all platforms.
834
+ * - The output format is always normalized (no leading zeros, no spaces).
835
+ * - For the forward direction (string → number), see {@link ipAddrToNum}.
836
+ *
837
+ * @param num - The 32-bit unsigned integer representing an IPv4 address.
838
+ *
839
+ * @returns A dotted-decimal IPv4 string (e.g. `"10.0.0.1"`),
840
+ * or an empty string if the input is invalid.
841
+ *
842
+ * @example
843
+ * ```ts
844
+ * // Example 1: Basic conversion
845
+ * numToIpAddr(3232235521);
846
+ * // -> "192.168.0.1"
847
+ *
848
+ * // Example 2: Edge values
849
+ * numToIpAddr(0); // -> "0.0.0.0"
850
+ * numToIpAddr(4294967295); // -> "255.255.255.255"
851
+ * ```
852
+ *
853
+ * @example
854
+ * ```ts
855
+ * // Example 3: Invalid inputs
856
+ * numToIpAddr(NaN); // -> ""
857
+ * numToIpAddr(Infinity); // -> ""
858
+ * numToIpAddr(-5); // -> ""
859
+ * ```
860
+ *
861
+ * @throws Never throws; invalid inputs simply return an empty string.
862
+ *
863
+ * @see {@link ipAddrToNum} — converts dotted IPv4 strings to numeric form.
864
+ * @see {@link parseIPv4} — alternative parser using bitwise arithmetic.
865
+ *
866
+ * @public
867
+ * @category Network & IP
868
+ * @since 2.0.0
869
+ */
870
+ declare function numToIpAddr(num: number): string;
871
+
872
+ /**
873
+ * Parses a dotted-quad IPv4 string (e.g. `"192.168.0.1"`) into a 32-bit unsigned integer.
874
+ *
875
+ * @remarks
876
+ * The returned number is in the range `0..0xFFFFFFFF` and represents the IPv4 address
877
+ * in big-endian order (i.e. the usual network order).
878
+ *
879
+ * The function is strict about format:
880
+ * - Exactly 4 decimal octets separated by dots.
881
+ * - Each octet must be `0..255`.
882
+ * - Only digits are allowed in each octet.
883
+ *
884
+ * Leading zeros in octets are permitted (e.g. `"001.002.003.004"`), but you may
885
+ * choose to forbid them in a custom variant to avoid legacy octal confusions.
886
+ *
887
+ * @param ip - Dotted-quad IPv4 string to parse.
888
+ * @returns The IPv4 as an unsigned 32-bit number, or `null` if invalid.
889
+ *
890
+ * @example
891
+ * ```ts
892
+ * parseIPv4('127.0.0.1'); // 2130706433
893
+ * parseIPv4('256.0.0.1'); // null
894
+ * parseIPv4('1.2.3'); // null
895
+ * ```
896
+ *
897
+ * @public
898
+ * @category IPv4
899
+ * @since 2.0.0
900
+ */
901
+ declare function parseIPv4(ip: string): number | null;
902
+
903
+ declare function rangeIPv4(from: string, to?: string): Generator<string>;
904
+ /**
905
+ * Creates a lazy generator over an inclusive IPv4 range.
906
+ *
907
+ * @remarks
908
+ * The function supports two input modes:
909
+ *
910
+ * 1. **CIDR mode** — when `from` contains a slash and `to` is `undefined`:
911
+ * ```ts
912
+ * for (const ip of rangeIPv4('192.168.1.0/30')) { ... }
913
+ * ```
914
+ * In this mode, {@link RangeIPv4Options.includeNetwork} and
915
+ * {@link RangeIPv4Options.includeBroadcast} are honored for masks `<= /30`.
916
+ * For `/31` and `/32` there is no traditional network/broadcast to exclude.
917
+ *
918
+ * 2. **Ad-hoc range mode** — when `from` is an IPv4 and `to` is either an IPv4
919
+ * or empty/omitted:
920
+ * - If `to` is provided, the range is `[min(from,to) .. max(from,to)]`.
921
+ * - If `to` is omitted or blank, the range spans to the end of the `/24`
922
+ * block: `A.B.C.D .. A.B.C.255`.
923
+ *
924
+ * The iteration is inclusive of both endpoints and is safe around the upper
925
+ * bound: if the current value is `0xFFFFFFFF`, the generator yields it once and terminates.
926
+ *
927
+ * This is a lazy generator: it does **not** allocate the entire range up-front,
928
+ * making it suitable for very large ranges (iterate/stream/process on the fly).
929
+ * If you need a materialized array, consider {@link rangeIPv4ToArr} but mind its `limit`.
930
+ *
931
+ * @overload
932
+ * @param from - A CIDR string (e.g. `"10.0.0.0/8"`). If this overload is used, `to` must be `undefined`.
933
+ *
934
+ * @overload
935
+ * @param from - Starting IPv4 address in dotted-quad form.
936
+ * @param to - Optional ending IPv4 address in dotted-quad form. If omitted or empty, the range ends at `A.B.C.255`.
937
+ * @param opts - Iteration options.
938
+ * @returns A generator of dotted-quad IPv4 strings.
939
+ *
940
+ * @param from - See overloads.
941
+ * @param to - See overloads.
942
+ * @param opts - See overloads.
943
+ *
944
+ * @example
945
+ * ```ts
946
+ * // 1) CIDR iteration (include all)
947
+ * [...rangeIPv4('192.168.1.0/30')];
948
+ * // -> ['192.168.1.0','192.168.1.1','192.168.1.2','192.168.1.3']
949
+ *
950
+ * // 2) CIDR iteration without network/broadcast
951
+ * [...rangeIPv4('192.168.1.0/30', undefined, { includeNetwork: false, includeBroadcast: false })];
952
+ * // -> ['192.168.1.1','192.168.1.2']
953
+ *
954
+ * // 3) Ad-hoc range (explicit end)
955
+ * [...rangeIPv4('10.0.0.1', '10.0.0.4')];
956
+ * // -> ['10.0.0.1','10.0.0.2','10.0.0.3','10.0.0.4']
957
+ *
958
+ * // 4) Single address ⇒ to end of /24
959
+ * [...rangeIPv4('10.1.2.3')].at(-1); // '10.1.2.255'
960
+ * ```
961
+ *
962
+ * @throws {Error}
963
+ * - If `from` is not a valid IPv4 (in non-CIDR mode).
964
+ * - If `to` is supplied and is not a valid IPv4 (in non-CIDR mode).
965
+ * - If `from` is not a valid CIDR in CIDR mode.
966
+ *
967
+ * @see {@link cidrToRange} to convert a CIDR to `[ start, end ]`.
968
+ * @see {@link rangeIPv4ToArr} to materialize a range into an array with a safe limit.
969
+ * @public
970
+ * @category IPv4
971
+ * @since 2.0.0
972
+ */
973
+ declare function rangeIPv4(from: string, to: string | undefined, opts?: RangeIPv4Options): Generator<string>;
974
+
975
+ /**
976
+ * Materializes an IPv4 range into an array of dotted-quad strings.
977
+ *
978
+ * @remarks
979
+ * This is a convenience wrapper around the lazy {@link rangeIPv4} generator that
980
+ * collects the yielded addresses into a new array. To protect against excessive
981
+ * memory usage, a hard {@link RangeIPv4Options.limit | limit} is enforced
982
+ * (default `1_000_000`). If the range exceeds the limit, an error is thrown and
983
+ * **no** partial array is returned.
984
+ *
985
+ * Prefer using the generator for very large ranges, streaming the results into
986
+ * your processing pipeline (e.g. writing to a file or socket).
987
+ *
988
+ * @param from - See {@link rangeIPv4} for accepted forms (CIDR or IPv4).
989
+ * @param to - Optional end address (non-CIDR mode). Ignored for CIDR input.
990
+ * @param opts - Options including the array size `limit`. See {@link RangeIPv4Options}.
991
+ * @returns A new array with all IPv4 addresses in the range (inclusive).
992
+ *
993
+ * @example
994
+ * ```ts
995
+ * // Small range OK
996
+ * rangeIPv4ToArray('192.168.1.10', '192.168.1.13');
997
+ * // -> ['192.168.1.10','192.168.1.11','192.168.1.12','192.168.1.13']
998
+ *
999
+ * // Will throw if exceeds the limit
1000
+ * rangeIPv4ToArray('10.0.0.0/16', undefined, { limit: 10_000 }); // Error
1001
+ * ```
1002
+ *
1003
+ * @throws {Error} If the realized array would exceed `opts.limit`.
1004
+ * @see {@link rangeIPv4} for lazy iteration without materialization.
1005
+ * @public
1006
+ * @category IPv4
1007
+ * @since 2.0.0
1008
+ */
1009
+ declare function rangeIPv4ToArr(from: string, to?: string, opts?: RangeIPv4Options): string[];
1010
+
1011
+ /**
1012
+ * Converts an unsigned 32-bit integer into a dotted-quad IPv4 string.
1013
+ *
1014
+ * @remarks
1015
+ * This is the inverse of {@link parseIPv4}. The function validates that the input
1016
+ * is a finite integer within `0..0xFFFFFFFF` and then formats it as `A.B.C.D`.
1017
+ *
1018
+ * @param n - Unsigned 32-bit IPv4 value (`0..0xFFFFFFFF`).
1019
+ * @returns A dotted-quad string such as `"192.168.0.1"`.
1020
+ *
1021
+ * @example
1022
+ * ```ts
1023
+ * toIPv4(0); // "0.0.0.0"
1024
+ * toIPv4(0xFFFFFFFF); // "255.255.255.255"
1025
+ * ```
1026
+ *
1027
+ * @throws {Error} If `n` is not an integer in `0..0xFFFFFFFF`.
1028
+ * @see {@link parseIPv4}
1029
+ * @public
1030
+ * @category IPv4
1031
+ * @since 2.0.0
1032
+ */
1033
+ declare function toIPv4(n: number): string;
1034
+
1035
+ /**
1036
+ * Configuration options that define password validation rules.
1037
+ *
1038
+ * This interface allows you to specify various constraints
1039
+ * that determine whether a given password is considered valid.
1040
+ *
1041
+ * @example
1042
+ * ```ts
1043
+ * const options: PasswordOptions = {
1044
+ * minLength: 8,
1045
+ * maxLength: 32,
1046
+ * requireUppercase: true,
1047
+ * requireLowercase: true,
1048
+ * requireDigit: true,
1049
+ * requireSpecial: true,
1050
+ * };
1051
+ * ```
1052
+ *
1053
+ * @remarks
1054
+ * You can use these options to build password validation functions,
1055
+ * enforce strong password policies, or configure authentication modules.
1056
+ *
1057
+ * @since 2.0.0
1058
+ */
1059
+ interface PasswordOptions {
1060
+ /**
1061
+ * Minimum allowed number of characters in the password.
1062
+ *
1063
+ * @defaultValue `0`
1064
+ * @example
1065
+ * ```ts
1066
+ * { minLength: 8 } // password must contain at least 8 characters
1067
+ * ```
1068
+ */
1069
+ minLength?: number;
1070
+ /**
1071
+ * Maximum allowed number of characters in the password.
1072
+ *
1073
+ * @defaultValue `Infinity`
1074
+ * @example
1075
+ * ```ts
1076
+ * { maxLength: 32 } // password cannot exceed 32 characters
1077
+ * ```
1078
+ */
1079
+ maxLength?: number;
1080
+ /**
1081
+ * Whether the password must contain at least one uppercase Latin letter (A–Z).
1082
+ *
1083
+ * @defaultValue `false`
1084
+ * @example
1085
+ * ```ts
1086
+ * { requireUppercase: true } // 'Password1' - OK 'password1' - BAD
1087
+ * ```
1088
+ */
1089
+ requireUppercase?: boolean;
1090
+ /**
1091
+ * Whether the password must contain at least one lowercase Latin letter (a–z).
1092
+ *
1093
+ * @defaultValue `false`
1094
+ * @example
1095
+ * ```ts
1096
+ * { requireLowercase: true } // 'PASSWORD1' - BAD 'Password1' - OK
1097
+ * ```
1098
+ */
1099
+ requireLowercase?: boolean;
1100
+ /**
1101
+ * Whether the password must include at least one numeric digit (0–9).
1102
+ *
1103
+ * @defaultValue `false`
1104
+ * @example
1105
+ * ```ts
1106
+ * { requireDigit: true } // 'Password' - BAD 'Password1' - OK
1107
+ * ```
1108
+ */
1109
+ requireDigit?: boolean;
1110
+ /**
1111
+ * Whether the password must include at least one special character
1112
+ * (such as `!@#$%^&*()-_=+[]{};:'",.<>/?`).
1113
+ *
1114
+ * @defaultValue `false`
1115
+ * @example
1116
+ * ```ts
1117
+ * { requireSpecial: true } // 'Password1' - BAD 'Password1!' - OK
1118
+ * ```
1119
+ */
1120
+ requireSpecial?: boolean;
1121
+ }
1122
+
1123
+ /**
1124
+ * Checks whether a given value is an array.
1125
+ *
1126
+ * @summary
1127
+ * A strongly typed wrapper around {@link Array.isArray}, with an enhanced TypeScript
1128
+ * type guard that asserts the value as a **readonly non-empty array** (`readonly [T, ...T[]]`).
1129
+ *
1130
+ * @typeParam T - The expected element type of the array (defaults to `unknown`).
1131
+ *
1132
+ * @param value - Any value to test.
1133
+ *
1134
+ * @returns `true` if the value is an array (of any kind), otherwise `false`.
1135
+ * The return type acts as a **type guard**, allowing TypeScript to infer that
1136
+ * `value` is a readonly array of `T` when the function returns `true`.
1137
+ *
1138
+ * @remarks
1139
+ * - Internally uses the native {@link Array.isArray} method.
1140
+ * - Works correctly across realms (e.g., iframes, worker contexts, etc.).
1141
+ * - The type guard ensures `value` is a **readonly non-empty array**, not just an empty list.
1142
+ * This provides safer downstream access patterns when empty arrays are not expected.
1143
+ * - If you need to allow empty arrays, consider changing the type to `readonly T[]`.
1144
+ *
1145
+ * ### Performance
1146
+ * - Time complexity: **O(1)** — constant time native check.
1147
+ * - Space complexity: **O(1)**.
1148
+ *
1149
+ * ### Common pitfalls
1150
+ * - `isArr([])` → `true`, even though the static type is `readonly [T, ...T[]]`.
1151
+ * TypeScript does not validate runtime emptiness; you should still check `value.length`.
1152
+ * - `isArr('abc')` → `false`
1153
+ * - `isArr({ length: 3 })` → `false`
1154
+ *
1155
+ * ### Examples
1156
+ *
1157
+ * @example
1158
+ * // Basic usage
1159
+ * isArr([1, 2, 3]); // => true
1160
+ * isArr('hello'); // => false
1161
+ * isArr({}); // => false
1162
+ *
1163
+ * @example
1164
+ * // With type inference
1165
+ * const val: unknown = [10, 20];
1166
+ * if (isArr<number>(val)) {
1167
+ * // TypeScript now knows val: readonly [number, ...number[]]
1168
+ * console.log(val[0]); // OK
1169
+ * }
1170
+ *
1171
+ * @example
1172
+ * // With mixed content
1173
+ * isArr([true, 'text', 123]); // => true
1174
+ *
1175
+ * @see Array.isArray
1176
+ *
1177
+ * @category Type Guards
1178
+ * @public
1179
+ * @since 2.0.0
1180
+ */
1181
+ declare function isArr<T = unknown>(value: unknown): value is readonly [T, ...T[]];
1182
+
1183
+ /**
1184
+ * Checks whether a value is a **non-empty array**.
1185
+ *
1186
+ * @summary
1187
+ * A strongly-typed type guard that returns `true` only if the input value is an array
1188
+ * (via {@link isArr}) and contains at least one element (`length > 0`).
1189
+ *
1190
+ * Useful for narrowing unknown data to a **readonly non-empty tuple type**
1191
+ * (`readonly [T, ...T[]]`), which gives TypeScript safer access guarantees.
1192
+ *
1193
+ * @typeParam T - Expected element type of the array (defaults to `unknown`).
1194
+ *
1195
+ * @param value - Any value to test.
1196
+ *
1197
+ * @returns `true` if `value` is an array with at least one element; otherwise `false`.
1198
+ *
1199
+ * @remarks
1200
+ * ### Type narrowing
1201
+ * When this function returns `true`, TypeScript automatically infers that:
1202
+ * ```ts
1203
+ * value is readonly [T, ...T[]]
1204
+ * ```
1205
+ *
1206
+ * That means inside the `if` block, you can safely access `value[0]`
1207
+ * without additional checks.
1208
+ *
1209
+ * ### Behavior
1210
+ * - Delegates the array check to {@link isArr}.
1211
+ * - Works with both mutable (`T[]`) and readonly arrays (`readonly T[]`).
1212
+ * - Does **not** mutate or clone the array.
1213
+ * - Returns `false` for:
1214
+ * - Non-array values (`null`, `undefined`, `object`, `string`, etc.).
1215
+ * - Empty arrays (`[]`).
1216
+ *
1217
+ * ### Performance
1218
+ * - Time complexity: **O(1)** (constant time check).
1219
+ * - Space complexity: **O(1)**.
1220
+ *
1221
+ * ### Examples
1222
+ *
1223
+ * @example
1224
+ * // Basic usage
1225
+ * isArrFilled([1, 2, 3]); // => true
1226
+ * isArrFilled([]); // => false
1227
+ *
1228
+ * @example
1229
+ * // With type inference
1230
+ * const maybeNumbers: unknown = [10, 20];
1231
+ * if (isArrFilled<number>(maybeNumbers)) {
1232
+ * // value is now typed as: readonly [number, ...number[]]
1233
+ * console.log(maybeNumbers[0]); // OK
1234
+ * }
1235
+ *
1236
+ * @example
1237
+ * // Non-array values
1238
+ * isArrFilled('abc'); // => false
1239
+ * isArrFilled(null); // => false
1240
+ * isArrFilled(undefined); // => false
1241
+ * isArrFilled({ length: 2 }); // => false
1242
+ *
1243
+ * @see isArr
1244
+ *
1245
+ * @category Type Guards
1246
+ * @public
1247
+ * @since 2.0.0
1248
+ */
1249
+ declare function isArrFilled<T = unknown>(value: unknown): value is readonly [T, ...T[]];
1250
+
1251
+ /**
1252
+ * Checks whether a given value is a boolean (`true` or `false`).
1253
+ *
1254
+ * @summary
1255
+ * A strict type guard that returns `true` only if `value` is of type `"boolean"`.
1256
+ *
1257
+ * This helps safely narrow unknown or mixed-type values in TypeScript code,
1258
+ * especially when working with dynamic data sources, JSON, or user input.
1259
+ *
1260
+ * @param value - Any value to check.
1261
+ *
1262
+ * @returns `true` if the value is strictly a boolean, otherwise `false`.
1263
+ *
1264
+ * @remarks
1265
+ * - Uses the built-in `typeof` operator (`typeof value === "boolean"`).
1266
+ * - Does **not** coerce values — only primitive `true` or `false` are accepted.
1267
+ * - Returns `false` for Boolean objects created via `new Boolean()`, because those
1268
+ * are of type `"object"`, not `"boolean"`.
1269
+ * - Designed as a **type guard**, so when it returns `true`, TypeScript will infer:
1270
+ * ```ts
1271
+ * value is boolean
1272
+ * ```
1273
+ *
1274
+ * ### Performance
1275
+ * - Time complexity: **O(1)** (constant).
1276
+ * - Space complexity: **O(1)**.
1277
+ *
1278
+ * ### Examples
1279
+ *
1280
+ * @example
1281
+ * // Basic usage
1282
+ * isBool(true); // => true
1283
+ * isBool(false); // => true
1284
+ * isBool(0); // => false
1285
+ * isBool('true'); // => false
1286
+ *
1287
+ * @example
1288
+ * // With type narrowing
1289
+ * const val: unknown = Math.random() > 0.5 ? true : 'yes';
1290
+ * if (isBool(val)) {
1291
+ * // TypeScript now knows val: boolean
1292
+ * console.log(val ? 'OK' : 'NO');
1293
+ * }
1294
+ *
1295
+ * @example
1296
+ * // Boolean object is not accepted
1297
+ * isBool(new Boolean(true)); // => false
1298
+ *
1299
+ * @category Type Guards
1300
+ * @public
1301
+ * @since 2.0.0
1302
+ */
1303
+ declare function isBool(value: unknown): value is boolean;
1304
+
1305
+ /**
1306
+ * Checks whether a value represents a **valid JavaScript date**.
1307
+ *
1308
+ * @summary
1309
+ * Returns `true` if the given value is either:
1310
+ * - an actual `Date` instance with a valid timestamp, or
1311
+ * - a string or number that can be successfully parsed by the JavaScript `Date` constructor.
1312
+ *
1313
+ * Returns `false` for invalid dates (`Invalid Date`), empty strings, `NaN`, or non-date types.
1314
+ *
1315
+ * @param value - Any value to test (can be a `Date`, string, number, or other type).
1316
+ *
1317
+ * @returns `true` if the value can be interpreted as a valid date, otherwise `false`.
1318
+ *
1319
+ * @remarks
1320
+ * ### Validation logic
1321
+ * 1. **If `value` is a `Date` instance:**
1322
+ * Checks `!Number.isNaN(value.getTime())` — ensures it’s a real date, not an invalid one.
1323
+ * ```ts
1324
+ * isDate(new Date('invalid')); // false
1325
+ * ```
1326
+ *
1327
+ * 2. **If `value` is a string or number:**
1328
+ * Attempts to construct a new `Date(value)`.
1329
+ * Returns `true` only if the resulting date’s timestamp is finite (not `NaN`).
1330
+ *
1331
+ * 3. **Otherwise:**
1332
+ * Returns `false`.
1333
+ *
1334
+ * ### What counts as "valid"
1335
+ * - OK: `"2024-12-31"`, `"2024-12-31T23:59:59Z"`, `1728000000000`, `new Date()`
1336
+ * - BAD: `"abc"`, `NaN`, `{}`, `null`, `undefined`, `new Date('invalid')`
1337
+ *
1338
+ * ### Type safety
1339
+ * - This is **not** a strict type guard (it doesn’t narrow to `Date`),
1340
+ * but you can pair it with a cast when `true`:
1341
+ * ```ts
1342
+ * if (isDate(v)) {
1343
+ * const d = new Date(v); // guaranteed valid
1344
+ * }
1345
+ * ```
1346
+ *
1347
+ * ### Performance
1348
+ * - Time complexity: **O(1)**
1349
+ * (`Date` construction and timestamp check are constant-time operations).
1350
+ * - Space complexity: **O(1)**.
1351
+ *
1352
+ * ### Examples
1353
+ *
1354
+ * @example
1355
+ * // Valid Date instances
1356
+ * isDate(new Date()); // => true
1357
+ * isDate(new Date('2024-05-01')); // => true
1358
+ *
1359
+ * @example
1360
+ * // From strings or timestamps
1361
+ * isDate('2025-01-01T00:00:00Z'); // => true
1362
+ * isDate(1700000000000); // => true
1363
+ * isDate('not-a-date'); // => false
1364
+ *
1365
+ * @example
1366
+ * // Invalid cases
1367
+ * isDate({}); // => false
1368
+ * isDate([]); // => false
1369
+ * isDate(''); // => false
1370
+ * isDate(new Date('invalid')); // => false
1371
+ *
1372
+ * @see isStr
1373
+ * @see isNum
1374
+ * @see Date
1375
+ *
1376
+ * @category Type Guards
1377
+ * @public
1378
+ * @since 2.0.0
1379
+ */
1380
+ declare function isDate(value: unknown): boolean;
1381
+
1382
+ /**
1383
+ * Checks whether a given value is a **valid email address**.
1384
+ *
1385
+ * @summary
1386
+ * Validates that the input is a non-empty string and matches a simplified but
1387
+ * practical email pattern according to RFC 5322-compatible syntax rules.
1388
+ *
1389
+ * @param value - Any value to test (string or unknown).
1390
+ *
1391
+ * @returns `true` if the value is a non-empty string that looks like a valid email,
1392
+ * otherwise `false`.
1393
+ *
1394
+ * @remarks
1395
+ * ### Validation process
1396
+ * 1. Ensures the input is a **non-empty string** via {@link isStrFilled}.
1397
+ * 2. Tests the value against a precompiled **regular expression**:
1398
+ * ```
1399
+ * /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+
1400
+ * @[a-zA-Z0-9]
1401
+ * (?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?
1402
+ * (?:\.[a-zA-Z]{2,})+$/
1403
+ * ```
1404
+ * This allows standard ASCII characters in the local part and enforces:
1405
+ * - at least one `@` separator
1406
+ * - valid domain and subdomain segments
1407
+ * - a top-level domain of at least two letters.
1408
+ *
1409
+ * ### Behavior notes
1410
+ * - Returns `false` for empty strings, `null`, `undefined`, or non-string inputs.
1411
+ * - Does **not** perform DNS or MX record validation — only syntactic matching.
1412
+ * - Intended for lightweight client-side or structural checks.
1413
+ * - If you need full compliance with RFC 6531 (Unicode / IDN), normalize the address first.
1414
+ *
1415
+ * ### Performance
1416
+ * - Time complexity: **O(n)** — proportional to input length.
1417
+ * - Space complexity: **O(1)**.
1418
+ * - The compiled regex is cached and reused for efficiency.
1419
+ *
1420
+ * ### Examples
1421
+ *
1422
+ * @example
1423
+ * // Valid emails
1424
+ * isEmail('user@example.com'); // => true
1425
+ * isEmail('john.doe+alias@mail.co.uk'); // => true
1426
+ *
1427
+ * @example
1428
+ * // Invalid formats
1429
+ * isEmail(''); // => false
1430
+ * isEmail('user@'); // => false
1431
+ * isEmail('@example.com'); // => false
1432
+ * isEmail('user@@example.com'); // => false
1433
+ * isEmail('user example@domain.com'); // => false
1434
+ *
1435
+ * @example
1436
+ * // Non-string inputs
1437
+ * isEmail(null); // => false
1438
+ * isEmail(undefined); // => false
1439
+ * isEmail(12345); // => false
1440
+ *
1441
+ * @see isStrFilled
1442
+ *
1443
+ * @category Validation
1444
+ * @public
1445
+ * @since 2.0.0
1446
+ */
1447
+ declare function isEmail(value: unknown): value is string;
1448
+
1449
+ /**
1450
+ * Checks whether a value **exists** — i.e. is neither `null` nor `undefined`.
1451
+ *
1452
+ * @summary
1453
+ * A minimal and strongly typed utility that acts as a **type guard**
1454
+ * to filter out `null` and `undefined` values in TypeScript.
1455
+ * It is especially useful in array filters and conditional checks
1456
+ * where you need to ensure a value is "present".
1457
+ *
1458
+ * @typeParam T - The original type of the tested value.
1459
+ *
1460
+ * @param value - Any value that may be `null` or `undefined`.
1461
+ *
1462
+ * @returns `true` if `value` is not `null` and not `undefined`, otherwise `false`.
1463
+ *
1464
+ * @remarks
1465
+ * ### Type narrowing
1466
+ * When this function returns `true`, TypeScript automatically infers:
1467
+ * ```ts
1468
+ * value is T
1469
+ * ```
1470
+ *
1471
+ * That means inside the `if` block (or after using `Array.filter(isExists)`),
1472
+ * the compiler knows the value cannot be `null` or `undefined`.
1473
+ *
1474
+ * ### Behavior
1475
+ * - Returns `false` for `null` and `undefined`.
1476
+ * - Returns `true` for any other type — including `false`, `0`, `''`, `NaN`, empty arrays, etc.
1477
+ * - The check is **strict** (`!==`) — no type coercion occurs.
1478
+ *
1479
+ * ### Typical use cases
1480
+ * - Filtering arrays that may contain `null` or `undefined`.
1481
+ * - Guarding optional values before access.
1482
+ * - Simplifying type-safe checks in functional chains.
1483
+ *
1484
+ * ### Performance
1485
+ * - Time complexity: **O(1)**
1486
+ * - Space complexity: **O(1)**
1487
+ *
1488
+ * ### Examples
1489
+ *
1490
+ * @example
1491
+ * // Basic checks
1492
+ * isExists(null); // => false
1493
+ * isExists(undefined); // => false
1494
+ * isExists(0); // => true
1495
+ * isExists(''); // => true
1496
+ * isExists(false); // => true
1497
+ *
1498
+ * @example
1499
+ * // With TypeScript narrowing
1500
+ * const val: string | null | undefined = getValue();
1501
+ * if (isExists(val)) {
1502
+ * // val is now guaranteed to be a string
1503
+ * console.log(val.toUpperCase());
1504
+ * }
1505
+ *
1506
+ * @example
1507
+ * // Filtering nullable arrays
1508
+ * const arr = [1, null, 2, undefined, 3];
1509
+ * const clean = arr.filter(isExists);
1510
+ * // clean: number[] => [1, 2, 3]
1511
+ *
1512
+ * @category Type Guards
1513
+ * @public
1514
+ * @since 2.0.0
1515
+ */
1516
+ declare function isExists<T>(value: T | null | undefined): value is T;
1517
+
1518
+ /**
1519
+ * Checks whether a given value is a **function**.
1520
+ *
1521
+ * @summary
1522
+ * A strict type guard that returns `true` only if `value` is a callable function.
1523
+ * It works with regular functions, arrow functions, async functions, class constructors,
1524
+ * and built-in functions like `setTimeout`.
1525
+ *
1526
+ * @typeParam T - The expected function type to narrow to (defaults to the base `Function` type).
1527
+ *
1528
+ * @param value - Any value to check.
1529
+ *
1530
+ * @returns `true` if the value is of type `"function"`, otherwise `false`.
1531
+ *
1532
+ * @remarks
1533
+ * ### Type narrowing
1534
+ * When this function returns `true`, TypeScript infers that:
1535
+ * ```ts
1536
+ * value is T
1537
+ * ```
1538
+ *
1539
+ * This allows safe calling of the function or using its specific signature.
1540
+ *
1541
+ * ### Behavior
1542
+ * - Returns `true` for:
1543
+ * - Normal functions: `function test() {}`
1544
+ * - Arrow functions: `() => {}`
1545
+ * - Async functions: `async () => {}`
1546
+ * - Generator functions: `function* gen() {}`
1547
+ * - Class constructors (typeof `MyClass`).
1548
+ * - Returns `false` for:
1549
+ * - Non-callable objects or primitives.
1550
+ * - Function-like objects that aren't real functions (e.g., `{ call() {} }`).
1551
+ *
1552
+ * ### Performance
1553
+ * - Time complexity: **O(1)**
1554
+ * - Space complexity: **O(1)**
1555
+ *
1556
+ * ### Examples
1557
+ *
1558
+ * @example
1559
+ * // Basic usage
1560
+ * isFunc(() => {}); // => true
1561
+ * isFunc(function test() {}); // => true
1562
+ * isFunc(class A {}); // => true
1563
+ * isFunc(123); // => false
1564
+ * isFunc({}); // => false
1565
+ *
1566
+ * @example
1567
+ * // Type narrowing
1568
+ * const fn: unknown = () => 'ok';
1569
+ * if (isFunc<() => string>(fn)) {
1570
+ * const result = fn(); // result: string
1571
+ * }
1572
+ *
1573
+ * @example
1574
+ * // Class constructors are also "functions"
1575
+ * class MyClass {}
1576
+ * isFunc(MyClass); // => true
1577
+ *
1578
+ * @category Type Guards
1579
+ * @public
1580
+ * @since 2.0.0
1581
+ */
1582
+ declare function isFunc<T extends Function = Function>(value: unknown): value is T;
1583
+
1584
+ /**
1585
+ * Checks whether a given value is a **valid IPv4 address**.
1586
+ *
1587
+ * @summary
1588
+ * Validates that the input is a string containing four octets (e.g. `"192.168.0.1"`),
1589
+ * where each octet is a number between `0` and `255`, separated by dots.
1590
+ *
1591
+ * @param value - Any value to test (string or unknown).
1592
+ *
1593
+ * @returns `true` if the value is a syntactically valid IPv4 address, otherwise `false`.
1594
+ *
1595
+ * @remarks
1596
+ * ### Validation steps
1597
+ * 1. Ensures the input is a string via {@link isStr}.
1598
+ * 2. Trims leading and trailing whitespace.
1599
+ * 3. Tests the cleaned string against a strict regular expression for IPv4 format:
1600
+ * ```
1601
+ * /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.
1602
+ * (25[0-5]|2[0-4]\d|[01]?\d\d?)\.
1603
+ * (25[0-5]|2[0-4]\d|[01]?\d\d?)\.
1604
+ * (25[0-5]|2[0-4]\d|[01]?\d\d?)$/
1605
+ * ```
1606
+ * Each group allows:
1607
+ * - `0–9`, `00–99`, `100–199`, `200–249`, `250–255`
1608
+ *
1609
+ * ### Behavior notes
1610
+ * - Returns `false` for non-strings, empty strings, or malformed IPs.
1611
+ * - Does **not** support IPv6 (use a separate validator for that).
1612
+ * - Does **not** perform CIDR or subnet validation — only syntax checking.
1613
+ * - Leading zeros are allowed (e.g. `"010.000.000.001"` is accepted, as per regex).
1614
+ *
1615
+ * ### Performance
1616
+ * - Time complexity: **O(1)** (fixed regex evaluation).
1617
+ * - Space complexity: **O(1)**.
1618
+ *
1619
+ * ### Examples
1620
+ *
1621
+ * @example
1622
+ * // Valid IPv4 addresses
1623
+ * isIpAddr('192.168.0.1'); // => true
1624
+ * isIpAddr('8.8.8.8'); // => true
1625
+ * isIpAddr('0.0.0.0'); // => true
1626
+ * isIpAddr('255.255.255.255'); // => true
1627
+ *
1628
+ * @example
1629
+ * // Invalid IPv4 strings
1630
+ * isIpAddr('256.0.0.1'); // => false (octet > 255)
1631
+ * isIpAddr('192.168.0'); // => false (missing octet)
1632
+ * isIpAddr('192.168.0.1.5'); // => false (too many octets)
1633
+ * isIpAddr('192.168.0.A'); // => false (non-numeric)
1634
+ * isIpAddr('192,168,0,1'); // => false (wrong separator)
1635
+ *
1636
+ * @example
1637
+ * // Non-string inputs
1638
+ * isIpAddr(12345); // => false
1639
+ * isIpAddr(null); // => false
1640
+ * isIpAddr(undefined); // => false
1641
+ *
1642
+ * @see isStr
1643
+ *
1644
+ * @category Validation
1645
+ * @public
1646
+ * @since 2.0.0
1647
+ */
1648
+ declare function isIpAddr(value: unknown): value is string;
1649
+
1650
+ /**
1651
+ * Checks whether a given value is a **valid MAC address**.
1652
+ *
1653
+ * @summary
1654
+ * Validates that the input is a string formatted as a standard 6-octet
1655
+ * MAC (Media Access Control) address, consisting of 12 hexadecimal digits
1656
+ * separated by either colons (`:`) or hyphens (`-`).
1657
+ *
1658
+ * @param value - Any value to test (typically a string from user input or network data).
1659
+ *
1660
+ * @returns `true` if the value matches the MAC address pattern, otherwise `false`.
1661
+ *
1662
+ * @remarks
1663
+ * ### Accepted formats
1664
+ * - `00:1A:2B:3C:4D:5E`
1665
+ * - `00-1A-2B-3C-4D-5E`
1666
+ * - Both uppercase and lowercase hexadecimal digits are allowed.
1667
+ * - Mixed separators (e.g., `"00:1A-2B:3C-4D:5E"`) are **not** accepted.
1668
+ *
1669
+ * ### Validation logic
1670
+ * 1. Confirms that `value` is a string via {@link isStr}.
1671
+ * 2. Uses the following regular expression:
1672
+ * ```
1673
+ * /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
1674
+ * ```
1675
+ * which enforces:
1676
+ * - Exactly 6 byte segments (`xx:xx:xx:xx:xx:xx` or `xx-xx-xx-xx-xx-xx`)
1677
+ * - Each segment: two hexadecimal digits (`0–9`, `A–F`, `a–f`)
1678
+ * - A consistent separator (`:` or `-`)
1679
+ *
1680
+ * ### Behavior notes
1681
+ * - Returns `false` for empty strings, non-strings, or malformed addresses.
1682
+ * - Does **not** support 8-octet EUI-64 or Cisco short 3-octet formats.
1683
+ * - Does **not** check for broadcast or multicast address semantics — only syntax.
1684
+ *
1685
+ * ### Performance
1686
+ * - Time complexity: **O(1)** (fixed regex match)
1687
+ * - Space complexity: **O(1)** (no allocations beyond regex)
1688
+ *
1689
+ * ### Examples
1690
+ *
1691
+ * @example
1692
+ * // Valid MAC addresses
1693
+ * isMacAddr('00:1A:2B:3C:4D:5E'); // => true
1694
+ * isMacAddr('AA-BB-CC-DD-EE-FF'); // => true
1695
+ * isMacAddr('ff:ff:ff:ff:ff:ff'); // => true
1696
+ *
1697
+ * @example
1698
+ * // Invalid MAC addresses
1699
+ * isMacAddr('00:1A:2B:3C:4D'); // => false (too short)
1700
+ * isMacAddr('00:1A:2B:3C:4D:5E:7F'); // => false (too long)
1701
+ * isMacAddr('00:1A:2B:3C:4D:ZZ'); // => false (invalid hex)
1702
+ * isMacAddr('001A.2B3C.4D5E'); // => false (wrong format)
1703
+ * isMacAddr(''); // => false
1704
+ *
1705
+ * @example
1706
+ * // Non-string values
1707
+ * isMacAddr(null); // => false
1708
+ * isMacAddr(undefined); // => false
1709
+ * isMacAddr(123456); // => false
1710
+ *
1711
+ * @see isStr
1712
+ * @see isIp
1713
+ *
1714
+ * @category Validation
1715
+ * @public
1716
+ * @since 2.0.0
1717
+ */
1718
+ declare function isMacAddr(value: unknown): value is string;
1719
+
1720
+ /**
1721
+ * Checks whether a given value is a **finite number**.
1722
+ *
1723
+ * @summary
1724
+ * A strict type guard that returns `true` only if `value` is of type `"number"`
1725
+ * and is a finite numeric value (not `NaN`, `Infinity`, or `-Infinity`).
1726
+ *
1727
+ * @param value - Any value to check.
1728
+ *
1729
+ * @returns `true` if the value is a finite number, otherwise `false`.
1730
+ *
1731
+ * @remarks
1732
+ * ### Behavior
1733
+ * - Uses the built-in `typeof` operator to ensure the value is a primitive number.
1734
+ * - Rejects special non-finite numeric values:
1735
+ * - `NaN`
1736
+ * - `Infinity`
1737
+ * - `-Infinity`
1738
+ * - Does **not** coerce strings — `"123"` returns `false`.
1739
+ * - Works only with **number primitives**, not `Number` objects (`new Number(5)` returns `false`).
1740
+ *
1741
+ * ### Type narrowing
1742
+ * When this function returns `true`, TypeScript automatically infers:
1743
+ * ```ts
1744
+ * value is number
1745
+ * ```
1746
+ * allowing you to use numeric operators and arithmetic safely.
1747
+ *
1748
+ * ### Comparison with related checks
1749
+ * | Function | Accepts | Rejects |
1750
+ * |----------------|---------------------------------|--------------------------------|
1751
+ * | `isNum` | finite numbers only | `NaN`, `Infinity`, non-numbers |
1752
+ * | `isNumP` | positive finite numbers | `0`, negatives, `NaN` |
1753
+ * | `isNumNZ` | zero or negative finite numbers | positives, `NaN` |
1754
+ *
1755
+ * ### Performance
1756
+ * - Time complexity: **O(1)**
1757
+ * - Space complexity: **O(1)**
1758
+ *
1759
+ * ### Examples
1760
+ *
1761
+ * @example
1762
+ * // Valid finite numbers
1763
+ * isNum(42); // => true
1764
+ * isNum(0); // => true
1765
+ * isNum(-3.14); // => true
1766
+ *
1767
+ * @example
1768
+ * // Invalid numeric values
1769
+ * isNum(NaN); // => false
1770
+ * isNum(Infinity); // => false
1771
+ * isNum(-Infinity); // => false
1772
+ *
1773
+ * @example
1774
+ * // Non-number inputs
1775
+ * isNum('123'); // => false
1776
+ * isNum(true); // => false
1777
+ * isNum(null); // => false
1778
+ * isNum(undefined); // => false
1779
+ *
1780
+ * @example
1781
+ * // TypeScript narrowing
1782
+ * const x: unknown = 100;
1783
+ * if (isNum(x)) {
1784
+ * console.log(x.toFixed(2)); // OK — x is number
1785
+ * }
1786
+ *
1787
+ * @category Type Guards
1788
+ * @public
1789
+ * @since 2.0.0
1790
+ */
1791
+ declare function isNum(value: unknown): value is number;
1792
+
1793
+ /**
1794
+ * Checks whether a given value is a **finite non-integer (floating-point) number**.
1795
+ *
1796
+ * @summary
1797
+ * Returns `true` if the value is a finite number and **has a fractional part**
1798
+ * (i.e. not an integer).
1799
+ * Acts as a strict type guard for float-like numeric values.
1800
+ *
1801
+ * @param value - Any value to test.
1802
+ *
1803
+ * @returns `true` if the value is a finite, non-integer number; otherwise `false`.
1804
+ *
1805
+ * @remarks
1806
+ * ### Behavior
1807
+ * - First verifies that the value is a finite number via {@link isNum}.
1808
+ * - Then ensures it is **not** an integer using `!Number.isInteger(value)`.
1809
+ * - Rejects all non-numeric, `NaN`, or infinite values.
1810
+ *
1811
+ * ### Comparison with related checks
1812
+ * | Function | Matches | Rejects |
1813
+ * |----------------|--------------------------------|------------------------------------|
1814
+ * | `isNum` | any finite number | `NaN`, `Infinity`, `-Infinity` |
1815
+ * | `isNumFloat` | finite numbers **with fraction** | integers, `NaN`, non-numbers |
1816
+ * | `isNumInt` | finite **integers** only | floats, `NaN`, non-numbers |
1817
+ *
1818
+ * ### Performance
1819
+ * - Time complexity: **O(1)**
1820
+ * - Space complexity: **O(1)**
1821
+ *
1822
+ * ### Examples
1823
+ *
1824
+ * @example
1825
+ * // Valid floats
1826
+ * isNumFloat(3.14); // => true
1827
+ * isNumFloat(-0.001); // => true
1828
+ * isNumFloat(1 / 3); // => true
1829
+ *
1830
+ * @example
1831
+ * // Integers
1832
+ * isNumFloat(0); // => false
1833
+ * isNumFloat(42); // => false
1834
+ * isNumFloat(-7); // => false
1835
+ *
1836
+ * @example
1837
+ * // Invalid or non-number values
1838
+ * isNumFloat(NaN); // => false
1839
+ * isNumFloat(Infinity); // => false
1840
+ * isNumFloat('3.14'); // => false
1841
+ * isNumFloat(null); // => false
1842
+ *
1843
+ * @example
1844
+ * // Type narrowing
1845
+ * const val: unknown = 12.5;
1846
+ * if (isNumFloat(val)) {
1847
+ * const n = val * 2; // val is number
1848
+ * }
1849
+ *
1850
+ * @see isNum
1851
+ * @see Number.isInteger
1852
+ *
1853
+ * @category Type Guards
1854
+ * @public
1855
+ * @since 2.0.0
1856
+ */
1857
+ declare function isNumFloat(value: unknown): value is number;
1858
+
1859
+ /**
1860
+ * Checks whether a given value is a **negative finite number**.
1861
+ *
1862
+ * @summary
1863
+ * A strict type guard that returns `true` only if the input is a finite number
1864
+ * and its value is **less than 0**.
1865
+ * Useful for safely detecting negative numeric values without coercion.
1866
+ *
1867
+ * @param value - Any value to test.
1868
+ *
1869
+ * @returns `true` if the value is a finite number less than zero, otherwise `false`.
1870
+ *
1871
+ * @remarks
1872
+ * ### Behavior
1873
+ * - Relies on {@link isNum} to ensure the value is a finite number (not `NaN`, `Infinity`, etc.).
1874
+ * - Then checks `value < 0`.
1875
+ * - Returns `false` for zero, positive numbers, and all non-numeric types.
1876
+ *
1877
+ * ### Comparison with related checks
1878
+ * | Function | Description | Condition |
1879
+ * |--------------|----------------------------------------|-----------------------------|
1880
+ * | `isNum` | Any finite number | `Number.isFinite(value)` |
1881
+ * | `isNumP` | Positive numbers only | `value > 0` |
1882
+ * | `isNumN` | Negative numbers only | `value < 0` |
1883
+ * | `isNumNZ` | Negative or zero numbers | `value <= 0` |
1884
+ * | `isNumFloat` | Finite non-integer (fractional) numbers | `!Number.isInteger(value)` |
1885
+ *
1886
+ * ### Performance
1887
+ * - Time complexity: **O(1)**
1888
+ * - Space complexity: **O(1)**
1889
+ *
1890
+ * ### Examples
1891
+ *
1892
+ * @example
1893
+ * // Negative numbers
1894
+ * isNumN(-1); // => true
1895
+ * isNumN(-3.14); // => true
1896
+ * isNumN(-0.0001); // => true
1897
+ *
1898
+ * @example
1899
+ * // Non-negative numbers
1900
+ * isNumN(0); // => false
1901
+ * isNumN(1); // => false
1902
+ * isNumN(42); // => false
1903
+ *
1904
+ * @example
1905
+ * // Invalid values
1906
+ * isNumN(NaN); // => false
1907
+ * isNumN('-5'); // => false
1908
+ * isNumN(null); // => false
1909
+ * isNumN(undefined); // => false
1910
+ *
1911
+ * @example
1912
+ * // Type narrowing
1913
+ * const val: unknown = -12;
1914
+ * if (isNumN(val)) {
1915
+ * const abs = Math.abs(val); // val is number
1916
+ * }
1917
+ *
1918
+ * @see isNum
1919
+ * @see isNumP
1920
+ * @see isNumNZ
1921
+ * @see isNumFloat
1922
+ *
1923
+ * @category Type Guards
1924
+ * @public
1925
+ * @since 2.0.0
1926
+ */
1927
+ declare function isNumN(value: unknown): value is number;
1928
+
1929
+ /**
1930
+ * Checks whether a given value is a **finite number that is less than or equal to zero**.
1931
+ *
1932
+ * @summary
1933
+ * A strict type guard that returns `true` if the input is a finite number and
1934
+ * its value is **negative or zero**.
1935
+ * Commonly used to identify non-positive numeric values.
1936
+ *
1937
+ * @param value - Any value to test.
1938
+ *
1939
+ * @returns `true` if the value is a finite number less than or equal to zero; otherwise `false`.
1940
+ *
1941
+ * @remarks
1942
+ * ### Behavior
1943
+ * - Uses {@link isNum} to ensure the input is a finite number (rejects `NaN`, `Infinity`, etc.).
1944
+ * - Then checks the condition `value <= 0`.
1945
+ * - Returns `false` for all positive numbers and non-numeric values.
1946
+ *
1947
+ * ### Comparison with related checks
1948
+ * | Function | Description | Condition |
1949
+ * |--------------|-----------------------------------|----------------|
1950
+ * | `isNum` | Any finite number | — |
1951
+ * | `isNumP` | Positive numbers only | `value > 0` |
1952
+ * | `isNumN` | Negative numbers only | `value < 0` |
1953
+ * | `isNumNZ` | Negative **or zero** numbers | `value <= 0` |
1954
+ * | `isNumFloat` | Finite non-integer (fractional) | `!Number.isInteger(value)` |
1955
+ *
1956
+ * ### Performance
1957
+ * - Time complexity: **O(1)**
1958
+ * - Space complexity: **O(1)**
1959
+ *
1960
+ * ### Examples
1961
+ *
1962
+ * @example
1963
+ * // Negative and zero values
1964
+ * isNumNZ(-1); // => true
1965
+ * isNumNZ(-0.5); // => true
1966
+ * isNumNZ(0); // => true
1967
+ *
1968
+ * @example
1969
+ * // Positive values
1970
+ * isNumNZ(0.0001); // => false
1971
+ * isNumNZ(5); // => false
1972
+ *
1973
+ * @example
1974
+ * // Invalid or non-numeric inputs
1975
+ * isNumNZ('0'); // => false
1976
+ * isNumNZ(NaN); // => false
1977
+ * isNumNZ(Infinity); // => false
1978
+ * isNumNZ(null); // => false
1979
+ *
1980
+ * @example
1981
+ * // Type narrowing
1982
+ * const x: unknown = -10;
1983
+ * if (isNumNZ(x)) {
1984
+ * console.log(x.toFixed(2)); // x is number
1985
+ * }
1986
+ *
1987
+ * @see isNum
1988
+ * @see isNumP
1989
+ * @see isNumN
1990
+ * @see isNumFloat
1991
+ *
1992
+ * @category Type Guards
1993
+ * @public
1994
+ * @since 2.0.0
1995
+ */
1996
+ declare function isNumNZ(value: unknown): value is number;
1997
+
1998
+ /**
1999
+ * Checks whether a given value is a **positive finite number**.
2000
+ *
2001
+ * @summary
2002
+ * A strict type guard that returns `true` only if the input is a finite number
2003
+ * greater than zero (`> 0`).
2004
+ * Useful for safely validating numeric values that must be positive — such as
2005
+ * counters, IDs, amounts, or dimensions.
2006
+ *
2007
+ * @param value - Any value to test.
2008
+ *
2009
+ * @returns `true` if the value is a finite positive number, otherwise `false`.
2010
+ *
2011
+ * @remarks
2012
+ * ### Behavior
2013
+ * - Uses {@link isNum} to ensure the input is a finite number (`NaN`, `Infinity`, and `-Infinity` are rejected).
2014
+ * - Returns `true` only when `value > 0`.
2015
+ * - Returns `false` for zero, negative, or non-numeric values.
2016
+ *
2017
+ * ### Comparison with related checks
2018
+ * | Function | Description | Condition |
2019
+ * |--------------|-----------------------------------|----------------------------|
2020
+ * | `isNum` | Any finite number | — |
2021
+ * | `isNumP` | Positive numbers only | `value > 0` |
2022
+ * | `isNumN` | Negative numbers only | `value < 0` |
2023
+ * | `isNumNZ` | Negative **or zero** numbers | `value <= 0` |
2024
+ * | `isNumFloat` | Finite non-integer (fractional) | `!Number.isInteger(value)` |
2025
+ *
2026
+ * ### Performance
2027
+ * - Time complexity: **O(1)**
2028
+ * - Space complexity: **O(1)**
2029
+ *
2030
+ * ### Examples
2031
+ *
2032
+ * @example
2033
+ * // Positive values
2034
+ * isNumP(1); // => true
2035
+ * isNumP(3.14); // => true
2036
+ * isNumP(0.00001); // => true
2037
+ *
2038
+ * @example
2039
+ * // Zero and negatives
2040
+ * isNumP(0); // => false
2041
+ * isNumP(-1); // => false
2042
+ * isNumP(-0.5); // => false
2043
+ *
2044
+ * @example
2045
+ * // Invalid or non-numeric inputs
2046
+ * isNumP('5'); // => false
2047
+ * isNumP(NaN); // => false
2048
+ * isNumP(Infinity); // => false
2049
+ * isNumP(null); // => false
2050
+ *
2051
+ * @example
2052
+ * // Type narrowing
2053
+ * const x: unknown = 12;
2054
+ * if (isNumP(x)) {
2055
+ * console.log(x.toFixed(1)); // x is number
2056
+ * }
2057
+ *
2058
+ * @see isNum
2059
+ * @see isNumN
2060
+ * @see isNumNZ
2061
+ * @see isNumFloat
2062
+ *
2063
+ * @category Type Guards
2064
+ * @public
2065
+ * @since 2.0.0
2066
+ */
2067
+ declare function isNumP(value: unknown): value is number;
2068
+
2069
+ /**
2070
+ * Checks whether a given value is a **finite number greater than or equal to zero**.
2071
+ *
2072
+ * @summary
2073
+ * A strict type guard that returns `true` if the input is a finite number
2074
+ * and its value is **non-negative** (`≥ 0`).
2075
+ * Useful for safely validating values such as counters, sizes, durations,
2076
+ * and other quantities that cannot be negative.
2077
+ *
2078
+ * @param value - Any value to test.
2079
+ *
2080
+ * @returns `true` if the value is a finite number greater than or equal to zero; otherwise `false`.
2081
+ *
2082
+ * @remarks
2083
+ * ### Behavior
2084
+ * - Uses {@link isNum} to ensure the input is a finite number (`NaN`, `Infinity`, `-Infinity` are rejected).
2085
+ * - Returns `true` when `value >= 0`.
2086
+ * - Returns `false` for negative numbers or non-numeric inputs.
2087
+ *
2088
+ * ### Comparison with related checks
2089
+ * | Function | Description | Condition |
2090
+ * |--------------|----------------------------------|----------------------------|
2091
+ * | `isNum` | Any finite number | — |
2092
+ * | `isNumP` | Positive numbers only | `value > 0` |
2093
+ * | `isNumPZ` | Non-negative numbers (`≥ 0`) | `value >= 0` |
2094
+ * | `isNumN` | Negative numbers only | `value < 0` |
2095
+ * | `isNumNZ` | Negative or zero numbers | `value <= 0` |
2096
+ * | `isNumFloat` | Finite non-integer numbers | `!Number.isInteger(value)` |
2097
+ *
2098
+ * ### Performance
2099
+ * - Time complexity: **O(1)**
2100
+ * - Space complexity: **O(1)**
2101
+ *
2102
+ * ### Examples
2103
+ *
2104
+ * @example
2105
+ * // Non-negative numbers
2106
+ * isNumPZ(0); // => true
2107
+ * isNumPZ(5); // => true
2108
+ * isNumPZ(3.14); // => true
2109
+ *
2110
+ * @example
2111
+ * // Negative numbers
2112
+ * isNumPZ(-1); // => false
2113
+ * isNumPZ(-0.1); // => false
2114
+ *
2115
+ * @example
2116
+ * // Invalid or non-numeric inputs
2117
+ * isNumPZ('10'); // => false
2118
+ * isNumPZ(NaN); // => false
2119
+ * isNumPZ(Infinity); // => false
2120
+ * isNumPZ(null); // => false
2121
+ *
2122
+ * @example
2123
+ * // Type narrowing
2124
+ * const val: unknown = 7;
2125
+ * if (isNumPZ(val)) {
2126
+ * console.log(Math.sqrt(val)); // val is number
2127
+ * }
2128
+ *
2129
+ * @see isNum
2130
+ * @see isNumP
2131
+ * @see isNumN
2132
+ * @see isNumNZ
2133
+ * @see isNumFloat
2134
+ *
2135
+ * @category Type Guards
2136
+ * @public
2137
+ * @since 2.0.0
2138
+ */
2139
+ declare function isNumPZ(value: unknown): value is number;
2140
+
2141
+ /**
2142
+ * Checks whether a given value is a **plain object** (i.e. `{}`), not `null`, not an array, and not a class instance.
2143
+ *
2144
+ * @summary
2145
+ * A strict type guard that returns `true` only if the input is a plain object
2146
+ * created using an object literal (`{}`) or `Object.create(null)`.
2147
+ * Excludes arrays, functions, `null`, and instances of custom classes.
2148
+ *
2149
+ * @param value - Any value to test.
2150
+ *
2151
+ * @returns `true` if the value is a non-null, non-array plain object; otherwise `false`.
2152
+ *
2153
+ * @remarks
2154
+ * ### Behavior
2155
+ * The check ensures all of the following:
2156
+ * 1. `typeof value === "object"` — confirms the value is object-like.
2157
+ * 2. `value !== null` — excludes `null`, since `typeof null === "object"`.
2158
+ * 3. `Object.prototype.toString.call(value) === "[object Object]"` — filters out built-ins like `Map`, `Set`, `Date`, etc.
2159
+ * 4. `!Array.isArray(value)` — ensures arrays are excluded.
2160
+ *
2161
+ * ### What counts as a "plain object"
2162
+ * `{}`, `{ a: 1 }`, `Object.create(null)`
2163
+ * `[]`, `new Date()`, `new Map()`, `null`, class instances.
2164
+ *
2165
+ * ### Comparison with related concepts
2166
+ * | Example value | Result | Explanation |
2167
+ * |--------------------------|---------|----------------------------------|
2168
+ * | `{}` | true | Plain object |
2169
+ * | `Object.create(null)` | true | No prototype but still object |
2170
+ * | `[]` | false | Array excluded |
2171
+ * | `null` | false | Explicitly filtered |
2172
+ * | `new Date()` | false | Built-in class instance |
2173
+ * | `class A {}; new A()` | false | Custom class instance |
2174
+ *
2175
+ * ### Type narrowing
2176
+ * When this function returns `true`, TypeScript infers:
2177
+ * ```ts
2178
+ * value is Record<string, unknown>
2179
+ * ```
2180
+ * allowing safe property access and iteration.
2181
+ *
2182
+ * ### Performance
2183
+ * - Time complexity: **O(1)**
2184
+ * - Space complexity: **O(1)**
2185
+ *
2186
+ * ### Examples
2187
+ *
2188
+ * @example
2189
+ * // Plain objects
2190
+ * isObj({}); // => true
2191
+ * isObj({ key: 'value' }); // => true
2192
+ * isObj(Object.create(null)); // => true
2193
+ *
2194
+ * @example
2195
+ * // Non-objects or special cases
2196
+ * isObj(null); // => false
2197
+ * isObj([]); // => false
2198
+ * isObj(new Date()); // => false
2199
+ * isObj(new Map()); // => false
2200
+ * isObj(() => {}); // => false
2201
+ *
2202
+ * @example
2203
+ * // Type narrowing
2204
+ * const val: unknown = { x: 1 };
2205
+ * if (isObj(val)) {
2206
+ * console.log(val.x); // safe: val is Record<string, unknown>
2207
+ * }
2208
+ *
2209
+ * @category Type Guards
2210
+ * @public
2211
+ * @since 2.0.0
2212
+ */
2213
+ declare function isObj(value: unknown): value is Record<string, unknown>;
2214
+
2215
+ /**
2216
+ * Checks whether a given value is a **non-empty plain object**.
2217
+ *
2218
+ * @summary
2219
+ * A strict type guard that returns `true` only if the input is a plain object
2220
+ * (validated by {@link isObj}) **and** has at least one own enumerable key.
2221
+ * In other words, it must be an object literal like `{ a: 1 }`, not `{}`.
2222
+ *
2223
+ * @param value - Any value to test.
2224
+ *
2225
+ * @returns `true` if the value is a plain object with at least one own property; otherwise `false`.
2226
+ *
2227
+ * @remarks
2228
+ * ### Behavior
2229
+ * - Uses {@link isObj} to verify the value is a plain object (not `null`, not an array, not a class instance).
2230
+ * - Calls `Object.keys(value).length > 0` to ensure the object has one or more keys.
2231
+ * - Returns `false` for empty objects (`{}`), arrays, functions, `null`, and other non-object types.
2232
+ *
2233
+ * ### Comparison with related checks
2234
+ * | Function | Description | Example |
2235
+ * |------------------|---------------------------------------|----------------------|
2236
+ * | `isObj` | Checks if value is a plain object | `{}` true / `[]` false |
2237
+ * | `isObjFilled` | Checks if plain object is **non-empty** | `{a: 1}` true / `{}` false |
2238
+ * | `isArrFilled` | Checks if array is non-empty | `[1]` true / `[]` false |
2239
+ * | `isStrFilled` | Checks if string is non-empty | `'a'` true / `''` false |
2240
+ *
2241
+ * ### Type narrowing
2242
+ * When this function returns `true`, TypeScript infers:
2243
+ * ```ts
2244
+ * value is Record<string, unknown>
2245
+ * ```
2246
+ * allowing safe property access and iteration.
2247
+ *
2248
+ * ### Performance
2249
+ * - Time complexity: **O(n)** — proportional to the number of object keys.
2250
+ * - Space complexity: **O(1)**.
2251
+ *
2252
+ * ### Examples
2253
+ *
2254
+ * @example
2255
+ * // Non-empty plain objects
2256
+ * isObjFilled({ a: 1 }); // => true
2257
+ * isObjFilled({ key: null }); // => true
2258
+ * isObjFilled({ nested: {} }); // => true
2259
+ *
2260
+ * @example
2261
+ * // Empty or invalid objects
2262
+ * isObjFilled({}); // => false
2263
+ * isObjFilled([]); // => false
2264
+ * isObjFilled(null); // => false
2265
+ * isObjFilled(new Date()); // => false
2266
+ *
2267
+ * @example
2268
+ * // Type narrowing
2269
+ * const data: unknown = { x: 5 };
2270
+ * if (isObjFilled(data)) {
2271
+ * console.log(Object.keys(data)); // safe
2272
+ * }
2273
+ *
2274
+ * @see isObj
2275
+ * @see isArrFilled
2276
+ * @see isStrFilled
2277
+ *
2278
+ * @category Type Guards
2279
+ * @public
2280
+ * @since 2.0.0
2281
+ */
2282
+ declare function isObjFilled(value: unknown): value is Record<string, unknown>;
2283
+
2284
+ /**
2285
+ * Validates whether a string meets configurable **password strength requirements**.
2286
+ *
2287
+ * @summary
2288
+ * A flexible password validation helper that checks for length, uppercase and lowercase letters,
2289
+ * digits, and special characters.
2290
+ * All rules are configurable through the optional {@link PasswordOptions} parameter.
2291
+ *
2292
+ * @param value - The value to validate as a password.
2293
+ * @param options - Optional validation rules (see {@link PasswordOptions}).
2294
+ * Defaults ensure strong password requirements:
2295
+ * ```ts
2296
+ * {
2297
+ * minLength: 8,
2298
+ * maxLength: 256,
2299
+ * requireUppercase: true,
2300
+ * requireLowercase: true,
2301
+ * requireDigit: true,
2302
+ * requireSpecial: true
2303
+ * }
2304
+ * ```
2305
+ *
2306
+ * @returns `true` if the value is a valid string matching all configured requirements, otherwise `false`.
2307
+ *
2308
+ * @remarks
2309
+ * ### Behavior
2310
+ * 1. Ensures `value` is a string using {@link isStr}.
2311
+ * 2. Enforces **length limits** (`minLength` ≤ length ≤ `maxLength`).
2312
+ * 3. Optionally checks for:
2313
+ * - Uppercase characters (Latin or Cyrillic): `/[A-ZА-Я]/`
2314
+ * - Lowercase characters (Latin or Cyrillic): `/[a-zа-я]/`
2315
+ * - Digits: `/\d/`
2316
+ * - Special characters: `/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/`
2317
+ * 4. Returns `true` only if all active checks pass.
2318
+ *
2319
+ * ### Default rule set (strong password)
2320
+ * - At least 8 characters long
2321
+ * - Contains uppercase and lowercase letters
2322
+ * - Contains at least one digit
2323
+ * - Contains at least one special symbol
2324
+ * - Not longer than 256 characters
2325
+ *
2326
+ * ### Example configuration
2327
+ * ```ts
2328
+ * // Minimal check — only length between 6 and 20
2329
+ * isPassword('abcdef', { minLength: 6, maxLength: 20, requireSpecial: false });
2330
+ *
2331
+ * // Strict corporate policy
2332
+ * isPassword('Qwerty#123', { minLength: 10, requireSpecial: true });
2333
+ *
2334
+ * // Simplified mobile app rule
2335
+ * isPassword('myPass1', { requireSpecial: false });
2336
+ * ```
2337
+ *
2338
+ * ### Type narrowing
2339
+ * When this function returns `true`, TypeScript infers:
2340
+ * ```ts
2341
+ * value is string
2342
+ * ```
2343
+ * allowing you to safely treat it as a verified password.
2344
+ *
2345
+ * ### Performance
2346
+ * - Time complexity: **O(n)** (depends on string length and regex scans).
2347
+ * - Space complexity: **O(1)**.
2348
+ *
2349
+ * ### Examples
2350
+ *
2351
+ * @example
2352
+ * // Default strong policy (8+ chars, upper, lower, digit, special)
2353
+ * isPassword('Aa1@aaaa'); // => true
2354
+ * isPassword('Password123!'); // => true
2355
+ * isPassword('qwerty'); // => false (no upper/digit/special)
2356
+ *
2357
+ * @example
2358
+ * // Custom rules
2359
+ * isPassword('abc123', {
2360
+ * minLength: 6,
2361
+ * requireUppercase: false,
2362
+ * requireSpecial: false
2363
+ * }); // => true
2364
+ *
2365
+ * @example
2366
+ * // Invalid inputs
2367
+ * isPassword(''); // => false
2368
+ * isPassword(null); // => false
2369
+ * isPassword(undefined); // => false
2370
+ * isPassword(123456); // => false
2371
+ *
2372
+ * @see isStr
2373
+ *
2374
+ * @category Validation
2375
+ * @public
2376
+ * @since 2.0.0
2377
+ */
2378
+ declare function isPassword(value: unknown, { minLength, maxLength, requireUppercase, requireLowercase, requireDigit, requireSpecial, }?: PasswordOptions): value is string;
2379
+
2380
+ /**
2381
+ * Checks whether a given value is a **valid phone number** in a generic international format.
2382
+ *
2383
+ * @summary
2384
+ * A flexible, language-neutral phone number validator that accepts both string and numeric inputs.
2385
+ * It supports optional leading `"+"`, allows dashes (`"-"`) as separators, and ensures that the
2386
+ * number structure is syntactically valid — not necessarily region-specific.
2387
+ *
2388
+ * @param value - Any value to test (string or number).
2389
+ *
2390
+ * @returns `true` if the value represents a valid phone-like number, otherwise `false`.
2391
+ *
2392
+ * @remarks
2393
+ * ### Validation logic
2394
+ * 1. **Type check:**
2395
+ * Accepts strings and finite numbers (`isStrFilled` or `isNum` must pass).
2396
+ * 2. **Normalization:**
2397
+ * Converts to string and trims whitespace.
2398
+ * 3. **Negative or misplaced signs:**
2399
+ * Rejects numbers starting with `"-"`.
2400
+ * 4. **Plus sign validation:**
2401
+ * - Only one `+` is allowed.
2402
+ * - If present, it must appear **only at the start**.
2403
+ * 5. **Character whitelist:**
2404
+ * The number must match the pattern `/^\+?[0-9-]+$/`,
2405
+ * i.e., only digits, dashes, and an optional leading plus sign.
2406
+ * 6. **Length check:**
2407
+ * Must be between **3** and **20** characters (inclusive).
2408
+ * 7. **Ending rule:**
2409
+ * The last character must be a digit.
2410
+ * 8. **Double-dash check:**
2411
+ * Rejects sequences containing `"--"`.
2412
+ *
2413
+ * ### Behavior
2414
+ * - Accepts: `+1234567890`, `380-67-123-4567`, `79001234567`, `12345`.
2415
+ * - Rejects: `"--123"`, `"++123"`, `"12a34"`, `"12 34"`, `"-123"`, `"123-"`.
2416
+ * - Not region-specific — does **not** check country codes or local dialing rules.
2417
+ * - Designed for structural validation only.
2418
+ *
2419
+ * ### Comparison
2420
+ * | Example | Valid | Reason |
2421
+ * |----------------------|:------:|--------------------------------|
2422
+ * | `+380671234567` | true | Proper international format |
2423
+ * | `067-123-4567` | true | Local format with dashes |
2424
+ * | `123` | true | Minimum valid length |
2425
+ * | `+12-34-56--78` | false | Contains `"--"` |
2426
+ * | `+12A345` | false | Contains letters |
2427
+ * | `123-` | false | Ends with non-digit |
2428
+ * | `++38050` | false | Multiple `"+"` symbols |
2429
+ * | `380+501234` | false | Misplaced plus |
2430
+ *
2431
+ * ### Type narrowing
2432
+ * When this function returns `true`, TypeScript infers:
2433
+ * ```ts
2434
+ * value is string
2435
+ * ```
2436
+ * even if the original value was numeric — ensuring it can be safely stored or formatted as text.
2437
+ *
2438
+ * ### Performance
2439
+ * - Time complexity: **O(n)** — single regex checks and scans.
2440
+ * - Space complexity: **O(1)**.
2441
+ *
2442
+ * ### Examples
2443
+ *
2444
+ * @example
2445
+ * // Valid international numbers
2446
+ * isPhone('+380671234567'); // => true
2447
+ * isPhone('380-67-123-4567'); // => true
2448
+ * isPhone(380501234567); // => true
2449
+ *
2450
+ * @example
2451
+ * // Invalid formats
2452
+ * isPhone('--12345'); // => false
2453
+ * isPhone('+12+34'); // => false
2454
+ * isPhone('12A345'); // => false
2455
+ * isPhone('123-'); // => false
2456
+ * isPhone(''); // => false
2457
+ *
2458
+ * @example
2459
+ * // Type narrowing
2460
+ * const val: unknown = '+14155552671';
2461
+ * if (isPhone(val)) {
2462
+ * console.log(val.replace(/\D/g, '')); // safe normalization
2463
+ * }
2464
+ *
2465
+ * @see isStrFilled
2466
+ * @see isNum
2467
+ * @see formatToPhone
2468
+ *
2469
+ * @category Validation
2470
+ * @public
2471
+ * @since 2.0.0
2472
+ */
2473
+ declare function isPhone(value: unknown): value is string;
2474
+
2475
+ /**
2476
+ * Checks whether a given value is a **string** primitive.
2477
+ *
2478
+ * @summary
2479
+ * A strict type guard that returns `true` only if the provided value
2480
+ * has the JavaScript type `"string"`.
2481
+ * Rejects all non-string types, including `String` objects created via `new String()`.
2482
+ *
2483
+ * @param value - Any value to test.
2484
+ *
2485
+ * @returns `true` if the value is a string primitive, otherwise `false`.
2486
+ *
2487
+ * @remarks
2488
+ * ### Behavior
2489
+ * - Uses the `typeof` operator for a strict type check.
2490
+ * - Does **not** coerce values — `"123"` is valid, but `123` is not.
2491
+ * - Returns `false` for:
2492
+ * - `String` wrapper objects (`new String('abc')`)
2493
+ * - Non-string types (`number`, `boolean`, `object`, `undefined`, etc.)
2494
+ *
2495
+ * ### Type narrowing
2496
+ * When this function returns `true`, TypeScript infers:
2497
+ * ```ts
2498
+ * value is string
2499
+ * ```
2500
+ * enabling full access to string methods safely.
2501
+ *
2502
+ * ### Comparison
2503
+ * | Input | Result | Note |
2504
+ * |------------------|:------:|-----------------------------------|
2505
+ * | `'hello'` | true | String literal |
2506
+ * | `new String('x')`| false | Object wrapper, not primitive |
2507
+ * | `123` | false | Number |
2508
+ * | `null` | false | Not a string |
2509
+ * | `undefined` | false | Not a string |
2510
+ *
2511
+ * ### Performance
2512
+ * - Time complexity: **O(1)**
2513
+ * - Space complexity: **O(1)**
2514
+ *
2515
+ * ### Examples
2516
+ *
2517
+ * @example
2518
+ * // Basic usage
2519
+ * isStr('Hello'); // => true
2520
+ * isStr(''); // => true
2521
+ * isStr(123); // => false
2522
+ * isStr(null); // => false
2523
+ *
2524
+ * @example
2525
+ * // Type narrowing
2526
+ * const val: unknown = 'abc';
2527
+ * if (isStr(val)) {
2528
+ * console.log(val.toUpperCase()); // safe
2529
+ * }
2530
+ *
2531
+ * @category Type Guards
2532
+ * @public
2533
+ * @since 2.0.0
2534
+ */
2535
+ declare function isStr(value: unknown): value is string;
2536
+
2537
+ /**
2538
+ * Checks whether a given value is a **string representation of a boolean** — `"true"` or `"false"`.
2539
+ *
2540
+ * @summary
2541
+ * A strict type guard that returns `true` if the input is a non-empty string
2542
+ * equal to `"true"` or `"false"` (case-insensitive, with whitespace ignored).
2543
+ * Commonly used for validating query parameters, environment variables, or serialized booleans.
2544
+ *
2545
+ * @param value - Any value to test.
2546
+ *
2547
+ * @returns `true` if the value is a string `"true"` or `"false"` (ignoring case and whitespace), otherwise `false`.
2548
+ *
2549
+ * @remarks
2550
+ * ### Behavior
2551
+ * 1. Uses {@link isStrFilled} to ensure the input is a non-empty string.
2552
+ * 2. Trims whitespace and converts it to lowercase.
2553
+ * 3. Returns `true` only if the normalized string equals `"true"` or `"false"`.
2554
+ * 4. Returns `false` for other strings, numbers, or non-string types.
2555
+ *
2556
+ * ### Typical usage
2557
+ * This utility is helpful when you need to:
2558
+ * - Parse stringified boolean flags (`'true'`, `'false'`)
2559
+ * - Validate configuration or query params
2560
+ * - Handle environment variables (`process.env.FEATURE_ENABLED`)
2561
+ *
2562
+ * ### Type narrowing
2563
+ * When this function returns `true`, TypeScript infers:
2564
+ * ```ts
2565
+ * value is string
2566
+ * ```
2567
+ * and you can safely pass it to a boolean converter (e.g. `formatToBool()`).
2568
+ *
2569
+ * ### Performance
2570
+ * - Time complexity: **O(1)**
2571
+ * - Space complexity: **O(1)**
2572
+ *
2573
+ * ### Examples
2574
+ *
2575
+ * @example
2576
+ * // Valid boolean strings
2577
+ * isStrBool('true'); // => true
2578
+ * isStrBool('FALSE'); // => true
2579
+ * isStrBool(' True '); // => true
2580
+ *
2581
+ * @example
2582
+ * // Invalid strings
2583
+ * isStrBool('yes'); // => false
2584
+ * isStrBool('0'); // => false
2585
+ * isStrBool(''); // => false
2586
+ *
2587
+ * @example
2588
+ * // Non-string inputs
2589
+ * isStrBool(true); // => false
2590
+ * isStrBool(1); // => false
2591
+ * isStrBool(null); // => false
2592
+ *
2593
+ * @example
2594
+ * // Combined with formatToBool()
2595
+ * import { formatToBool } from '../bool/formatToBool';
2596
+ *
2597
+ * const val: unknown = 'False';
2598
+ * if (isStrBool(val)) {
2599
+ * console.log(formatToBool(val)); // false
2600
+ * }
2601
+ *
2602
+ * @see isStr
2603
+ * @see isStrFilled
2604
+ * @see isBool
2605
+ * @see formatToBool
2606
+ *
2607
+ * @category Validation
2608
+ * @public
2609
+ * @since 2.0.0
2610
+ */
2611
+ declare function isStrBool(value: unknown): value is string;
2612
+
2613
+ /**
2614
+ * Checks whether a given value is a **non-empty string** (not just whitespace).
2615
+ *
2616
+ * @summary
2617
+ * A strict type guard that returns `true` only if the value is a string
2618
+ * containing at least one non-whitespace character.
2619
+ * This is an extended form of {@link isStr} that excludes empty (`""`) and
2620
+ * whitespace-only strings (`" "`).
2621
+ *
2622
+ * @param value - Any value to test.
2623
+ *
2624
+ * @returns `true` if the value is a string with visible content, otherwise `false`.
2625
+ *
2626
+ * @remarks
2627
+ * ### Behavior
2628
+ * - Uses {@link isStr} to confirm the value is a string primitive.
2629
+ * - Calls `.trim()` to remove whitespace and checks if the resulting length is greater than zero.
2630
+ * - Returns `false` for:
2631
+ * - Empty strings (`""`)
2632
+ * - Whitespace-only strings (`" "`, `"\n"`, `"\t"`)
2633
+ * - Non-string values (`number`, `boolean`, `object`, `null`, etc.)
2634
+ *
2635
+ * ### Comparison
2636
+ * | Function | Description | Example |
2637
+ * |-----------------|-----------------------------------|---------------------------|
2638
+ * | `isStr` | Any string (including empty) | `""` true |
2639
+ * | `isStrFilled` | Non-empty trimmed string only | `" "` false / `"x"` true |
2640
+ *
2641
+ * ### Type narrowing
2642
+ * When this function returns `true`, TypeScript infers:
2643
+ * ```ts
2644
+ * value is string
2645
+ * ```
2646
+ * ensuring safe use of string operations.
2647
+ *
2648
+ * ### Performance
2649
+ * - Time complexity: **O(n)** (due to `.trim()`).
2650
+ * - Space complexity: **O(1)**.
2651
+ *
2652
+ * ### Examples
2653
+ *
2654
+ * @example
2655
+ * // Valid strings
2656
+ * isStrFilled('hello'); // => true
2657
+ * isStrFilled(' text '); // => true
2658
+ *
2659
+ * @example
2660
+ * // Empty or whitespace-only
2661
+ * isStrFilled(''); // => false
2662
+ * isStrFilled(' '); // => false
2663
+ *
2664
+ * @example
2665
+ * // Non-string values
2666
+ * isStrFilled(null); // => false
2667
+ * isStrFilled(123); // => false
2668
+ * isStrFilled(undefined); // => false
2669
+ *
2670
+ * @example
2671
+ * // Type narrowing
2672
+ * const val: unknown = ' value ';
2673
+ * if (isStrFilled(val)) {
2674
+ * console.log(val.trim().toUpperCase()); // safe
2675
+ * }
2676
+ *
2677
+ * @see isStr
2678
+ * @see isArrFilled
2679
+ * @see isObjFilled
2680
+ *
2681
+ * @category Type Guards
2682
+ * @public
2683
+ * @since 2.0.0
2684
+ */
2685
+ declare function isStrFilled(value: unknown): value is string;
2686
+
2687
+ /**
2688
+ * Checks whether a given value is a string equal to **"asc"** or **"desc"** (case-insensitive).
2689
+ *
2690
+ * @summary
2691
+ * A strict type guard that validates sorting direction strings —
2692
+ * `"asc"` (ascending) or `"desc"` (descending).
2693
+ * Useful for validating API parameters, SQL sort directives, or UI sort controls.
2694
+ *
2695
+ * @param value - Any value to test.
2696
+ *
2697
+ * @returns `true` if the value is a non-empty string representing `"asc"` or `"desc"`, otherwise `false`.
2698
+ *
2699
+ * @remarks
2700
+ * ### Behavior
2701
+ * 1. Uses {@link isStrFilled} to ensure the value is a non-empty string.
2702
+ * 2. Trims whitespace and converts it to lowercase.
2703
+ * 3. Returns `true` only if the normalized value equals `"asc"` or `"desc"`.
2704
+ * 4. Returns `false` for empty strings, other words, or non-string types.
2705
+ *
2706
+ * ### Type narrowing
2707
+ * When this function returns `true`, TypeScript infers:
2708
+ * ```ts
2709
+ * value is 'asc' | 'desc'
2710
+ * ```
2711
+ * which is ideal for type-safe sort order handling in functions and APIs.
2712
+ *
2713
+ * ### Performance
2714
+ * - Time complexity: **O(1)** (fixed length checks)
2715
+ * - Space complexity: **O(1)**
2716
+ *
2717
+ * ### Examples
2718
+ *
2719
+ * @example
2720
+ * // Valid inputs
2721
+ * isStrAscDesc('asc'); // => true
2722
+ * isStrAscDesc('DESC'); // => true
2723
+ * isStrAscDesc(' Asc '); // => true
2724
+ *
2725
+ * @example
2726
+ * // Invalid inputs
2727
+ * isStrAscDesc('ascending'); // => false
2728
+ * isStrAscDesc(''); // => false
2729
+ * isStrAscDesc(null); // => false
2730
+ * isStrAscDesc('up'); // => false
2731
+ *
2732
+ * @example
2733
+ * // Type narrowing in use
2734
+ * function sortData(order: unknown) {
2735
+ * if (isStrAscDesc(order)) {
2736
+ * console.log(`Sorting in ${order} order`);
2737
+ * } else {
2738
+ * console.log('Invalid sort direction');
2739
+ * }
2740
+ * }
2741
+ *
2742
+ * @see isStr
2743
+ * @see isStrFilled
2744
+ *
2745
+ * @category Validation
2746
+ * @public
2747
+ * @since 2.0.0
2748
+ */
2749
+ declare function isStrAscDesc(value: unknown): value is 'asc' | 'desc';
2750
+
2751
+ /**
2752
+ * Checks whether a given value is a **valid variable-like identifier**.
2753
+ *
2754
+ * @summary
2755
+ * A strict type guard that returns `true` only if the value is a string
2756
+ * matching the pattern of a valid **programming variable name**:
2757
+ * must start with a letter (`A–Z`, `a–z`) or underscore (`_`),
2758
+ * and may contain only letters, digits, or underscores afterward.
2759
+ *
2760
+ * @param value - Any value to test.
2761
+ *
2762
+ * @returns `true` if the value is a syntactically valid variable name; otherwise `false`.
2763
+ *
2764
+ * @remarks
2765
+ * ### Validation rule
2766
+ * Uses the following regular expression:
2767
+ * ```regex
2768
+ * /^[A-Za-z_][A-Za-z0-9_]*$/
2769
+ * ```
2770
+ * This enforces:
2771
+ * - **First character:** a Latin letter (`A–Z`, `a–z`) or underscore (`_`)
2772
+ * - **Subsequent characters:** any combination of letters, digits, or underscores
2773
+ * - **No spaces, symbols, or Unicode letters** are allowed
2774
+ *
2775
+ * ### Typical use cases
2776
+ * - Validating variable names in configuration files or templates
2777
+ * - Checking safe property keys for code generation
2778
+ * - Ensuring identifiers in scripting or parsing logic
2779
+ *
2780
+ * ### Behavior
2781
+ * - Returns `false` for:
2782
+ * - Strings starting with digits (`"1abc"`)
2783
+ * - Strings containing hyphens or spaces (`"my-var"`, `"user name"`)
2784
+ * - Empty strings or non-string values
2785
+ * - Returns `true` for:
2786
+ * - `"name"`, `"_value"`, `"myVar1"`, `"SOME_CONSTANT"`
2787
+ *
2788
+ * ### Type narrowing
2789
+ * When this function returns `true`, TypeScript infers:
2790
+ * ```ts
2791
+ * value is string
2792
+ * ```
2793
+ * ensuring safe string usage in contexts like symbol tables or identifier maps.
2794
+ *
2795
+ * ### Performance
2796
+ * - Time complexity: **O(n)** — proportional to string length (regex evaluation)
2797
+ * - Space complexity: **O(1)**
2798
+ *
2799
+ * ### Examples
2800
+ *
2801
+ * @example
2802
+ * // Valid identifiers
2803
+ * isVar('name'); // => true
2804
+ * isVar('_id'); // => true
2805
+ * isVar('myVar1'); // => true
2806
+ * isVar('SOME_CONSTANT'); // => true
2807
+ *
2808
+ * @example
2809
+ * // Invalid identifiers
2810
+ * isVar(''); // => false
2811
+ * isVar('1var'); // => false
2812
+ * isVar('user-name'); // => false
2813
+ * isVar('my var'); // => false
2814
+ * isVar('$value'); // => false
2815
+ *
2816
+ * @example
2817
+ * // Non-string values
2818
+ * isVar(null); // => false
2819
+ * isVar(123); // => false
2820
+ * isVar({}); // => false
2821
+ *
2822
+ * @see isStr
2823
+ * @see isStrFilled
2824
+ *
2825
+ * @category Validation
2826
+ * @public
2827
+ * @since 2.0.0
2828
+ */
2829
+ declare function isVar(value: unknown): value is string;
2830
+
2831
+ /**
2832
+ * Structural JSON-like type used throughout decoding.
2833
+ *
2834
+ * @remarks
2835
+ * This mirrors the standard JSON value domain:
2836
+ * `null`, booleans, numbers, strings, arrays of JSON-like values,
2837
+ * and plain object maps with string keys pointing to JSON-like values.
2838
+ *
2839
+ * @public
2840
+ * @category JSON
2841
+ * @since 2.0.0
2842
+ */
2843
+ type JSONLike = null | boolean | number | string | JSONLike[] | {
2844
+ [k: string]: JSONLike;
2845
+ };
2846
+
2847
+ /**
2848
+ * Parses a string that may represent JSON, quoted scalars, or plain text.
2849
+ *
2850
+ * @remarks
2851
+ * The parsing order is:
2852
+ *
2853
+ * 1. Try JSON via {@link tryParseJSON}. If it works, return the parsed value.
2854
+ * 2. If not JSON, check if the string is quoted with `'`, `"` or `` ` ``.
2855
+ * If quoted, return the **unquoted** inner text.
2856
+ * 3. If not quoted:
2857
+ * - If `allowString === true`, return the **trimmed** string as-is.
2858
+ * - Otherwise return `null`.
2859
+ *
2860
+ * This helper is used recursively by {@link jsonDecode} to decode string fields
2861
+ * found inside arrays/objects.
2862
+ *
2863
+ * @param s - Source string.
2864
+ * @param allowString - Whether to allow returning raw (unquoted) strings.
2865
+ * @returns A JSON-like value, or `null` if the string cannot be interpreted
2866
+ * and `allowString` is `false`.
2867
+ *
2868
+ * @example
2869
+ * ```ts
2870
+ * parseStringLike('{"a":1}', false); // -> { a: 1 }
2871
+ * parseStringLike('"hello"', false); // -> "hello"
2872
+ * parseStringLike('hello', false); // -> null
2873
+ * parseStringLike('hello', true); // -> "hello"
2874
+ * ```
2875
+ *
2876
+ * @internal
2877
+ */
2878
+ declare function parseStringLike(s: string, allowString: boolean): JSONLike | null;
2879
+
2880
+ /**
2881
+ * Attempts to parse a string using native {@link JSON.parse}.
2882
+ *
2883
+ * @remarks
2884
+ * Returns a discriminated union with `{ ok: true, value }` on success,
2885
+ * or `{ ok: false }` on any parsing error. Exceptions are caught and
2886
+ * **never thrown** to callers.
2887
+ *
2888
+ * @param str - The candidate JSON string.
2889
+ * @returns A result object indicating parse success/failure.
2890
+ *
2891
+ * @example
2892
+ * ```ts
2893
+ * tryParseJSON('{"a":1}'); // { ok: true, value: { a: 1 } }
2894
+ * tryParseJSON('not json'); // { ok: false }
2895
+ * ```
2896
+ *
2897
+ * @internal
2898
+ */
2899
+ declare function tryParseJSON(str: string): {
2900
+ ok: true;
2901
+ value: JSONLike;
2902
+ } | {
2903
+ ok: false;
2904
+ };
2905
+
2906
+ /**
2907
+ * Best-effort decoder that normalizes unknown input into a JSON-like value.
2908
+ *
2909
+ * @remarks
2910
+ * `jsonDecode` accepts many shapes of input and produces a `JSONLike` (or `null`)
2911
+ * according to the following rules:
2912
+ *
2913
+ * - **Primitive passthrough**: `null`, numbers, and booleans are returned as-is.
2914
+ * - **Arrays/Objects (filled)**: for each string element/property, we attempt to decode
2915
+ * it via {@link parseStringLike} (JSON → unquoted string → raw string if `allowString`).
2916
+ * Non-string items are passed through unchanged (cast to `JSONLike`).
2917
+ * - **Arrays/Objects (empty)**: returned as-is (they’re valid JSON).
2918
+ * - **Standalone strings**: decoded via {@link parseStringLike}.
2919
+ * - **Other values**: return `null`.
2920
+ *
2921
+ * The function is **non-throwing**; any JSON parse errors are swallowed internally
2922
+ * and mapped to either unquoted/raw strings (depending on `allowString`) or `null`.
2923
+ *
2924
+ * - Uses native `JSON.parse` — safe for untrusted strings provided you do not eval the result.
2925
+ * - Does **not** perform schema validation; if you need strict shapes, validate after decoding.
2926
+ *
2927
+ * @typeParam T - Target type to cast the normalized result to.
2928
+ * Defaults to `JSONLike`. Use with care — this is a **type cast**, not a runtime check.
2929
+ *
2930
+ * @param value - The unknown input to decode (can be primitives, arrays, objects, etc.).
2931
+ * @param allowString - If `true`, non-JSON, non-quoted strings are returned as trimmed strings.
2932
+ * If `false`, such strings decode to `null`.
2933
+ *
2934
+ * @returns The decoded value cast to `T`, or `null` when it cannot be decoded.
2935
+ *
2936
+ * @example
2937
+ * ```ts
2938
+ * // 1) Primitives pass through
2939
+ * jsonDecode(42); // 42
2940
+ * jsonDecode(true); // true
2941
+ * jsonDecode(null); // null
2942
+ *
2943
+ * // 2) JSON string
2944
+ * jsonDecode('{"a":[1,"2"]}'); // { a: [1, "2"] }
2945
+ *
2946
+ * // 3) Quoted string
2947
+ * jsonDecode('"hello"'); // "hello"
2948
+ *
2949
+ * // 4) Raw string with allowString=false (default)
2950
+ * jsonDecode('hello'); // null
2951
+ *
2952
+ * // 5) Raw string with allowString=true
2953
+ * jsonDecode('hello', true); // "hello"
2954
+ *
2955
+ * // 6) Arrays/objects with string fields get per-field decoding
2956
+ * jsonDecode({ a: '{"k":1}', b: 'world' }, true);
2957
+ * // -> { a: { k: 1 }, b: "world" }
2958
+ * ```
2959
+ *
2960
+ * @throws Never throws; invalid inputs yield `null` or are passed through per rules above.
2961
+ *
2962
+ * @public
2963
+ * @category JSON
2964
+ * @since 2.0.0
2965
+ */
2966
+ declare function jsonDecode<T = JSONLike>(value: unknown, allowString?: boolean): T | null;
2967
+
2968
+ /**
2969
+ * Safely serializes a plain object or array into a JSON string.
2970
+ *
2971
+ * @remarks
2972
+ * This helper wraps {@link JSON.stringify} and adds two key safety features:
2973
+ *
2974
+ * 1. It only serializes **objects** and **arrays**, ignoring all other data types
2975
+ * (numbers, strings, booleans, `null`, `undefined`).
2976
+ * 2. It catches all potential `JSON.stringify` errors (such as circular references)
2977
+ * and returns an empty string `""` instead of throwing.
2978
+ *
2979
+ * The function is thus ideal for safe logging, diagnostics, or best-effort
2980
+ * serialization where throwing is undesirable.
2981
+ *
2982
+ * - The output is always a valid JSON string (or empty string on failure).
2983
+ * - Use {@link jsonDecode} to reverse the process and safely parse it back.
2984
+ * - BigInt values are **not supported** by `JSON.stringify` — they will trigger
2985
+ * a caught error, resulting in an empty string.
2986
+ *
2987
+ * @param value - Any value to encode. Only arrays or plain objects will be serialized;
2988
+ * other types return an empty string.
2989
+ *
2990
+ * @returns The JSON-encoded string representation of the input,
2991
+ * or an empty string (`""`) if:
2992
+ * - The input is not an array or object.
2993
+ * - Serialization fails (e.g., circular reference or BigInt values).
2994
+ *
2995
+ * @example
2996
+ * ```ts
2997
+ * // Example 1: Basic usage
2998
+ * jsonEncode({ a: 1, b: true });
2999
+ * // -> '{"a":1,"b":true}'
3000
+ *
3001
+ * // Example 2: Arrays
3002
+ * jsonEncode([1, 2, 3]);
3003
+ * // -> '[1,2,3]'
3004
+ *
3005
+ * // Example 3: Non-serializable input
3006
+ * jsonEncode(123); // -> ''
3007
+ * jsonEncode('hello'); // -> ''
3008
+ * jsonEncode(undefined); // -> ''
3009
+ *
3010
+ * // Example 4: Circular reference
3011
+ * const obj: any = {};
3012
+ * obj.self = obj;
3013
+ * jsonEncode(obj); // -> '' (fails safely)
3014
+ * ```
3015
+ *
3016
+ * @throws Never throws — all exceptions from `JSON.stringify` are caught internally.
3017
+ *
3018
+ * @see {@link jsonDecode} — performs the inverse operation with safe parsing and normalization.
3019
+ * @see {@link JSON.stringify} — the native method used under the hood.
3020
+ *
3021
+ * @public
3022
+ * @category JSON
3023
+ * @since 2.0.0
3024
+ */
3025
+ declare function jsonEncode(value: unknown): string;
3026
+
3027
+ /**
3028
+ * Represents a **fixed-precision decimal number** using exact integer arithmetic.
3029
+ *
3030
+ * @remarks
3031
+ * JavaScript’s native `number` type uses 64-bit IEEE-754 floating-point representation,
3032
+ * which introduces rounding errors for many decimal values
3033
+ * (for example, `0.1 + 0.2 !== 0.3`).
3034
+ *
3035
+ * `FixedDecimal` provides a lossless, predictable alternative by separating
3036
+ * the number into three explicit components:
3037
+ *
3038
+ * - **`sign`** → numeric sign (`1` for positive values, `-1` for negative ones)
3039
+ * - **`digitsInteger`** → all digits of the number stored as a `BigInt`
3040
+ * (the decimal point is removed)
3041
+ * - **`scale`** → number of digits that were originally after the decimal point
3042
+ *
3043
+ * Together, these three parts allow precise decimal math, rounding,
3044
+ * and string/number conversions without losing accuracy.
3045
+ *
3046
+ * ---
3047
+ * **Conceptual example**
3048
+ *
3049
+ * The decimal value:
3050
+ * ```
3051
+ * -123.456
3052
+ * ```
3053
+ * would be represented as:
3054
+ * ```ts
3055
+ * {
3056
+ * sign: -1,
3057
+ * digitsInteger: 123456n,
3058
+ * scale: 3
3059
+ * }
3060
+ * ```
3061
+ *
3062
+ * which mathematically equals:
3063
+ * ```
3064
+ * sign × (digitsInteger / 10^scale)
3065
+ * = -1 × (123456 / 10^3)
3066
+ * = -123.456
3067
+ * ```
3068
+ *
3069
+ * ---
3070
+ * **Usage**
3071
+ *
3072
+ * Instances of `FixedDecimal` are typically produced and consumed by utility functions:
3073
+ * - {@link parseToFixedDecimal} — converts arbitrary input (`string`/`number`/`bigint`) to `FixedDecimal`
3074
+ * - {@link roundFixedDecimal} — rounds to a target number of fractional digits
3075
+ * - {@link fixedDecimalToStr} — converts back to a human-readable string
3076
+ * - {@link fixedDecimalToNum} — converts to a JavaScript `number` (with possible precision loss)
3077
+ *
3078
+ * ---
3079
+ * @property sign - Numeric sign of the value.
3080
+ * `1` for positive and zero values, `-1` for negative ones.
3081
+ *
3082
+ * @property digitsInteger - A `BigInt` holding all digits of the number
3083
+ * without any decimal separator.
3084
+ * Example: `"123.45"` → `digitsInteger = 12345n`.
3085
+ *
3086
+ * @property scale - Number of digits that appear after the decimal point
3087
+ * in the original value.
3088
+ * Example: `"123.45"` → `scale = 2`.
3089
+ *
3090
+ * ---
3091
+ * @example
3092
+ * // Example: 0.034 represented as FixedDecimal
3093
+ * const fd: FixedDecimal = {
3094
+ * sign: 1,
3095
+ * digitsInteger: 34n,
3096
+ * scale: 3
3097
+ * };
3098
+ * // mathematically: 1 × (34 / 10³) = 0.034
3099
+ *
3100
+ * @example
3101
+ * // Example: -987000.00 → same magnitude, different scale
3102
+ * const fd2: FixedDecimal = {
3103
+ * sign: -1,
3104
+ * digitsInteger: 98700000n,
3105
+ * scale: 2
3106
+ * };
3107
+ * // -987000.00
3108
+ *
3109
+ * @example
3110
+ * // Zero value representation
3111
+ * const zero: FixedDecimal = {
3112
+ * sign: 1,
3113
+ * digitsInteger: 0n,
3114
+ * scale: 0
3115
+ * };
3116
+ *
3117
+ * @see parseToFixedDecimal
3118
+ * @see roundFixedDecimal
3119
+ * @see fixedDecimalToStr
3120
+ * @see fixedDecimalToNum
3121
+ *
3122
+ * @category Types
3123
+ * @since 2.0.0
3124
+ * @public
3125
+ */
3126
+ interface FixedDecimal {
3127
+ /**
3128
+ * The numeric sign of the value:
3129
+ * `1` for positive or zero, `-1` for negative.
3130
+ */
3131
+ sign: 1 | -1;
3132
+ /**
3133
+ * All digits of the number stored as a `BigInt`,
3134
+ * with the decimal point removed.
3135
+ */
3136
+ digitsInteger: bigint;
3137
+ /**
3138
+ * The number of digits that originally appeared
3139
+ * after the decimal point.
3140
+ */
3141
+ scale: number;
3142
+ }
3143
+
3144
+ /**
3145
+ * Adjusts the **scale** (i.e., number of fractional digits) of a {@link FixedDecimal}
3146
+ * by a given offset without altering its numeric meaning.
3147
+ *
3148
+ * @remarks
3149
+ * A `FixedDecimal` represents a decimal number as:
3150
+ * ```ts
3151
+ * { sign: 1 | -1, digitsInteger: bigint, scale: number }
3152
+ * ```
3153
+ * where `digitsInteger × 10^(-scale)` yields the real value.
3154
+ *
3155
+ * This helper changes the `scale` while keeping the numerical value consistent.
3156
+ * When `scaleDelta > 0`, the function *increases* the scale (adds more fractional
3157
+ * digits of precision) **without changing** `digitsInteger`.
3158
+ * When `scaleDelta < 0`, it *reduces* the scale by multiplying `digitsInteger`
3159
+ * to preserve the same actual numeric value.
3160
+ *
3161
+ * O(1) time and space, except for the BigInt multiplication when `scaleDelta < 0`.
3162
+ *
3163
+ * @param value - The {@link FixedDecimal} to adjust.
3164
+ * Should contain:
3165
+ * - `sign`: either `1` (positive) or `-1` (negative),
3166
+ * - `digitsInteger`: the integer form of all digits without a decimal point,
3167
+ * - `scale`: the number of fractional digits currently represented.
3168
+ *
3169
+ * @param scaleDelta - The number of fractional places to add or remove.
3170
+ * Positive values mean **increase precision** (more digits after the decimal point);
3171
+ * negative values mean **reduce precision**, scaling the integer part accordingly.
3172
+ *
3173
+ * @returns A new {@link FixedDecimal} with the adjusted `scale` and appropriately
3174
+ * modified `digitsInteger` if needed.
3175
+ *
3176
+ * @throws {RangeError} If the operation would cause an invalid scale
3177
+ * (e.g., non-integer `scaleDelta`), though `Math.trunc` is used to normalize inputs.
3178
+ *
3179
+ * @example
3180
+ * ```ts
3181
+ * const num: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3182
+ * // Represents 123.45
3183
+ *
3184
+ * // Increase scale by +2 → same numeric value but more fractional digits
3185
+ * const up = changeFixedDecimalScale(num, +2);
3186
+ * // up = { sign: 1, digitsInteger: 12345n, scale: 4 } → 1.2345 × 10^2 = 123.45
3187
+ *
3188
+ * // Decrease scale by -2 → multiply digitsInteger to preserve value
3189
+ * const down = changeFixedDecimalScale(num, -2);
3190
+ * // down = { sign: 1, digitsInteger: 1234500n, scale: 0 } → 1234500 × 10^0 = 123.45
3191
+ * ```
3192
+ *
3193
+ * @example
3194
+ * ```ts
3195
+ * // No change when delta = 0
3196
+ * const same = changeFixedDecimalScale(num, 0);
3197
+ * // same === { sign: 1, digitsInteger: 12345n, scale: 2 }
3198
+ * ```
3199
+ *
3200
+ * @since 2.0.0
3201
+ */
3202
+ declare function changeFixedDecimalScale(value: FixedDecimal, scaleDelta: number): FixedDecimal;
3203
+
3204
+ /**
3205
+ * Converts a number expressed in normalized exponential/scientific notation
3206
+ * (e.g., `"1.23e+5"`, `"4e-7"`, `"0009.500e2"`) into its **sign**, **integer**,
3207
+ * and **fractional** parts as plain decimal digit strings — **without** any
3208
+ * decimal point or leading `+`/`-` characters.
3209
+ *
3210
+ * @remarks
3211
+ * - This function does **not** perform numeric arithmetic; instead it does a
3212
+ * textual normalization that preserves all significant digits exactly.
3213
+ * - It accepts the `sign` separately so that callers can pre-parse signs from
3214
+ * inputs like `"-1.23e3"` and pass `sign = -1` with `exponentialString = "1.23e3"`.
3215
+ * (If you already have a positive string, pass `sign = 1`.)
3216
+ * - The function normalizes the coefficient and exponent first, then uses a
3217
+ * single regex match to validate the shape:
3218
+ * - Coefficient: `([0-9]+)(?:\.([0-9]*))?`
3219
+ * - Exponent: `e([+\-]?[0-9]+)`
3220
+ * - Trailing zeros are added to the **integer** side for positive net exponents,
3221
+ * while leading zeros are added to the **fractional** side for negative net exponents.
3222
+ * - All returned parts (`integerPart`, `fractionalPart`) contain only ASCII digits.
3223
+ * The decimal point is **not** returned; you can re-insert it if needed by
3224
+ * placing it between `integerPart` and `fractionalPart`.
3225
+ *
3226
+ * Time O(n) and space O(n), where n is the number of digits in the coefficient,
3227
+ * due to string concatenation and slicing.
3228
+ *
3229
+ * @param sign - The pre-parsed sign of the number: `1` for positive, `-1` for negative.
3230
+ * @param exponentialString - A string in exponential notation.
3231
+ * Examples: `"1e3"`, `"1.23e+5"`, `"4.560e-2"`, `"0009.500e2"`.
3232
+ * The function is case-insensitive for the `'e'` and tolerates leading zeros in the coefficient.
3233
+ *
3234
+ * @returns An object with three properties:
3235
+ * - `sign`: Echo of the input sign (`1` | `-1`).
3236
+ * - `integerPart`: All digits to the left of the decimal point after expansion.
3237
+ * - `fractionalPart`: All digits to the right of the decimal point after expansion.
3238
+ *
3239
+ * @throws {Error} If `exponentialString` cannot be parsed as scientific notation.
3240
+ *
3241
+ * @example
3242
+ * ```ts
3243
+ * // 1.23 × 10^5 = 123000
3244
+ * convertExponentialToParts(1, "1.23e5");
3245
+ * // => { sign: 1, integerPart: "123000", fractionalPart: "" }
3246
+ * ```
3247
+ *
3248
+ * @example
3249
+ * ```ts
3250
+ * // 4.5 × 10^-3 = 0.0045
3251
+ * convertExponentialToParts(1, "4.5e-3");
3252
+ * // => { sign: 1, integerPart: "0", fractionalPart: "0045" }
3253
+ * ```
3254
+ *
3255
+ * @example
3256
+ * ```ts
3257
+ * // -7.00e+0 = -7
3258
+ * convertExponentialToParts(-1, "7.00e0");
3259
+ * // => { sign: -1, integerPart: "7", fractionalPart: "" }
3260
+ * ```
3261
+ *
3262
+ * @example
3263
+ * ```ts
3264
+ * // Leading zeros in coefficient are handled; fractional length adjusts exponent
3265
+ * convertExponentialToParts(1, "0009.500e2"); // 9.500 × 10^2 = 950
3266
+ * // => { sign: 1, integerPart: "950", fractionalPart: "" }
3267
+ * ```
3268
+ *
3269
+ * @example
3270
+ * ```ts
3271
+ * // You can reconstruct a normalized decimal string yourself:
3272
+ * const { sign, integerPart, fractionalPart } = convertExponentialToParts(-1, "1.234e-2");
3273
+ * const signChar = sign < 0 ? "-" : "";
3274
+ * const plain = fractionalPart ? `${integerPart}.${fractionalPart}` : integerPart;
3275
+ * // plain == "0.01234"
3276
+ * const result = signChar + plain; // "-0.01234"
3277
+ * ```
3278
+ *
3279
+ * @see isNumPZ — utility used here to detect non-negative integers (exponent ≥ 0).
3280
+ *
3281
+ * @since 2.0.0
3282
+ */
3283
+ declare function convertExponentialToParts(sign: 1 | -1, exponentialString: string): {
3284
+ sign: 1 | -1;
3285
+ integerPart: string;
3286
+ fractionalPart: string;
3287
+ };
3288
+
3289
+ /**
3290
+ * Converts a {@link FixedDecimal} — an exact decimal representation —
3291
+ * into a native JavaScript `number` (IEEE 754 double precision).
3292
+ *
3293
+ * @remarks
3294
+ * This function is a **lossy** conversion when `value` contains
3295
+ * more precision than JavaScript’s floating-point format can represent.
3296
+ * It internally calls {@link fixedDecimalToStr} to produce a normalized
3297
+ * string such as `"-123.4567"` and then passes it to the built-in
3298
+ * `Number()` constructor.
3299
+ *
3300
+ * O(n) relative to the number of digits in `digitsInteger`
3301
+ * (due to string creation in {@link fixedDecimalToStr}).
3302
+ *
3303
+ * @param value - The {@link FixedDecimal} instance to convert.
3304
+ * Must contain:
3305
+ * - `sign`: either `1` or `-1`;
3306
+ * - `digitsInteger`: a `bigint` representing all digits without any decimal point;
3307
+ * - `scale`: how many digits belong after the decimal point.
3308
+ *
3309
+ * @returns The approximate numeric value as a JavaScript `number`.
3310
+ * If the string form is too large or too precise, the result may be
3311
+ * rounded or become `Infinity`.
3312
+ *
3313
+ * @example
3314
+ * ```ts
3315
+ * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3316
+ * // Represents exactly 123.45
3317
+ * const num = fixedDecimalToNum(fd); // 123.45 (Number)
3318
+ * ```
3319
+ *
3320
+ * @example
3321
+ * ```ts
3322
+ * // Handles negative numbers as well
3323
+ * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };
3324
+ * const n = fixedDecimalToNum(neg); // -0.987
3325
+ * ```
3326
+ *
3327
+ * @example
3328
+ * ```ts
3329
+ * // Extreme precision may lose digits beyond ~15–17 significant figures
3330
+ * const big: FixedDecimal = { sign: 1, digitsInteger: 12345678901234567890n, scale: 10 };
3331
+ * const approx = fixedDecimalToNum(big);
3332
+ * console.log(approx); // ~1234567890.1234567 (rounded)
3333
+ * ```
3334
+ *
3335
+ * @see fixedDecimalToStr — for the exact string representation
3336
+ * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number#precision JavaScript number precision
3337
+ *
3338
+ * @since 2.0.0
3339
+ */
3340
+ declare function fixedDecimalToNum(value: FixedDecimal): number;
3341
+
3342
+ /**
3343
+ * Converts a {@link FixedDecimal} — an exact, integer-based decimal structure —
3344
+ * into its canonical string representation (e.g. `"-123.456"`).
3345
+ *
3346
+ * @remarks
3347
+ * This function is **exact and reversible**: no precision loss occurs because it
3348
+ * operates on the raw digit string (`digitsInteger`) and inserts the decimal point
3349
+ * purely by string manipulation.
3350
+ *
3351
+ * The algorithm:
3352
+ * 1. Converts the `digitsInteger` `BigInt` to a string of digits.
3353
+ * 2. If `scale` is `0`, returns the signed integer directly.
3354
+ * 3. If `scale` is positive:
3355
+ * - Pads with leading zeros when the number of digits is smaller than `scale`.
3356
+ * - Otherwise, splits at the appropriate boundary between integer and fractional parts.
3357
+ *
3358
+ * O(n) where `n` is the number of digits in `digitsInteger.toString()`.
3359
+ *
3360
+ * @param value - The {@link FixedDecimal} object:
3361
+ * - `sign`: `1` for positive or `-1` for negative numbers.
3362
+ * - `digitsInteger`: All digits as a `BigInt` without a decimal point.
3363
+ * - `scale`: The number of digits after the decimal point.
3364
+ *
3365
+ * @returns A string representation of the number, including a `-` sign if negative.
3366
+ * If the number is fractional, a single `.` separates integer and fractional parts.
3367
+ *
3368
+ * @example
3369
+ * ```ts
3370
+ * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3371
+ * fixedDecimalToStr(fd); // "123.45"
3372
+ * ```
3373
+ *
3374
+ * @example
3375
+ * ```ts
3376
+ * // Negative number
3377
+ * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };
3378
+ * fixedDecimalToStr(neg); // "-0.987"
3379
+ * ```
3380
+ *
3381
+ * @example
3382
+ * ```ts
3383
+ * // Small fractional with fewer digits than scale
3384
+ * const tiny: FixedDecimal = { sign: 1, digitsInteger: 12n, scale: 5 };
3385
+ * fixedDecimalToStr(tiny); // "0.00012"
3386
+ * ```
3387
+ *
3388
+ * @example
3389
+ * ```ts
3390
+ * // Whole number (scale = 0)
3391
+ * const whole: FixedDecimal = { sign: 1, digitsInteger: 42n, scale: 0 };
3392
+ * fixedDecimalToStr(whole); // "42"
3393
+ * ```
3394
+ *
3395
+ * @see changeFixedDecimalScale — for adjusting the scale value safely
3396
+ * @see fixedDecimalToNum — for converting to a JavaScript number
3397
+ *
3398
+ * @since 2.0.0
3399
+ */
3400
+ declare function fixedDecimalToStr(value: FixedDecimal): string;
3401
+
3402
+ /**
3403
+ * Converts an arbitrary numeric input to a JavaScript `number`, optionally rounding
3404
+ * it to a fixed number of fractional digits using **half-up** rounding.
3405
+ *
3406
+ * @remarks
3407
+ * This function is a convenience wrapper around your fixed-precision helpers:
3408
+ *
3409
+ * 1. {@link parseToFixedDecimal} — parses the unknown input (`number`/`string`/etc.)
3410
+ * into an exact, lossless fixed-decimal representation.
3411
+ * 2. `roundFixedDecimal` — (invoked only when `round > 1`) rounds that fixed-decimal
3412
+ * value to the requested scale using the **half-up** algorithm.
3413
+ * 3. {@link fixedDecimalToNum} — converts the (optionally rounded) fixed-decimal
3414
+ * back to a JavaScript `number`.
3415
+ *
3416
+ * Because rounding is done in fixed-precision space, you avoid common IEEE-754
3417
+ * floating-point artifacts (e.g., `0.1 + 0.2 !== 0.3`) during parsing/rounding.
3418
+ * Precision is finally limited only at the last step when the value is converted
3419
+ * to a JS `number`.
3420
+ *
3421
+ * @param value - Any value that represents a number. Typical cases:
3422
+ * - `number` (e.g., `12`, `-0.034`, `1e6`)
3423
+ * - numeric `string` (e.g., `"42"`, `"-123.456"`)
3424
+ * - values that your {@link parseToFixedDecimal} knows how to normalize.
3425
+ *
3426
+ * If the value cannot be parsed by {@link parseToFixedDecimal}, an error will be thrown from there.
3427
+ *
3428
+ * @param round - Target number of fractional digits for rounding **in fixed-precision**.
3429
+ * - If `round > 1`, the function rounds to exactly `round` digits after the decimal point
3430
+ * using **half-up** (i.e., `.5` rounds away from zero) via `roundFixedDecimal`.
3431
+ * - If `round <= 1`, no rounding is applied; the parsed value is passed through as-is.
3432
+ *
3433
+ * @defaultValue `1` (no rounding; passthrough)
3434
+ *
3435
+ * @returns The resulting numeric value as a JavaScript `number`.
3436
+ *
3437
+ * @throws {Error}
3438
+ * - Re-throws any parsing/normalization errors from {@link parseToFixedDecimal}.
3439
+ * - Re-throws any rounding errors from `roundFixedDecimal` (e.g., invalid scale).
3440
+ *
3441
+ * @example
3442
+ * // No rounding (default `round = 1` → passthrough)
3443
+ * formatToNum("123.456"); // => 123.456
3444
+ * formatToNum(0.034); // => 0.034
3445
+ *
3446
+ * @example
3447
+ * // Round to 2 fractional digits (half-up)
3448
+ * formatToNum("123.456", 2); // => 123.46 (because .456 → .46)
3449
+ * formatToNum("-1.235", 2); // => -1.24 (half-up away from zero)
3450
+ *
3451
+ * @example
3452
+ * // Large values: parsed and rounded in fixed precision, then converted to number
3453
+ * formatToNum("234893249238948.000003432", 6); // precise rounding in fixed space,
3454
+ * // final result as JS number
3455
+ *
3456
+ * @example
3457
+ * // Explicit passthrough (any `round <= 1` behaves the same)
3458
+ * formatToNum("1000.555", 1); // => 1000.555 (no rounding step invoked)
3459
+ * formatToNum("1000.555", 0); // => 1000.555 (still no rounding)
3460
+ *
3461
+ * @see parseToFixedDecimal
3462
+ * @see fixedDecimalToNum
3463
+ * @see roundFixedDecimal
3464
+ *
3465
+ * @category Number Formatting
3466
+ * @since 2.0.0
3467
+ * @public
3468
+ */
3469
+ declare function formatToNum(value: unknown, round?: number): number;
3470
+
3471
+ /**
3472
+ * Normalizes an arbitrary numeric input into sign, integer, and fractional string parts
3473
+ * without losing precision, preparing it for exact fixed-decimal processing.
3474
+ *
3475
+ * @remarks
3476
+ * This utility accepts `bigint`, `number`, and `string` inputs and returns a tuple-like
3477
+ * object with three fields:
3478
+ *
3479
+ * - `sign`: `1` for non-negative values, `-1` for negative values.
3480
+ * - `integerPart`: the digits before the decimal point as a string (no sign, no separators).
3481
+ * - `fractionalPart`: the digits after the decimal point as a string (no sign, no separators).
3482
+ *
3483
+ * For JavaScript `number`s, the function first checks finiteness and then converts the
3484
+ * absolute value to an exponential string (via `toExponential(30)`) to avoid
3485
+ * floating-point artifacts when extracting digits. It delegates parsing of that exponential
3486
+ * form to {@link convertExponentialToParts}.
3487
+ *
3488
+ * For `string`s, the function:
3489
+ * - Trims whitespace and replaces a comma `,` decimal separator with a dot `.`.
3490
+ * - Parses and removes a leading `+`/`-` sign (if present).
3491
+ * - Validates the remaining characters with a permissive numeric pattern that allows:
3492
+ * - optional integer digits,
3493
+ * - an optional decimal point with digits,
3494
+ * - an optional scientific exponent (`e` or `E` with optional `+`/`-` and digits).
3495
+ * - If an exponent is present, it delegates to {@link convertExponentialToParts};
3496
+ * otherwise it splits on the decimal point.
3497
+ *
3498
+ * **Important:** This function does not strip leading zeros in `integerPart` or trailing
3499
+ * zeros in `fractionalPart`. If you need canonicalized output (e.g., remove leading/trailing
3500
+ * zeros), do that in a later step (e.g., when building your fixed-decimal representation).
3501
+ *
3502
+ * @param input - The numeric input to normalize. Supported types:
3503
+ * - `bigint` (e.g., `123n`, `-9007199254740993n`)
3504
+ * - `number` (finite only; `NaN`, `Infinity`, `-Infinity` will throw)
3505
+ * - `string` (e.g., `"42"`, `"-0.034"`, `"1.2e-5"`, with optional leading sign, optional
3506
+ * decimal part, optional exponent; commas are allowed as decimal separators and are
3507
+ * converted to dots)
3508
+ *
3509
+ * @returns An object with the normalized components:
3510
+ * ```ts
3511
+ * {
3512
+ * sign: 1 | -1;
3513
+ * integerPart: string;
3514
+ * fractionalPart: string;
3515
+ * }
3516
+ * ```
3517
+ * The `integerPart` and `fractionalPart` contain only ASCII digits (`0`–`9`) and
3518
+ * **never** include sign or exponent markers.
3519
+ *
3520
+ * @throws {Error}
3521
+ * - If `input` is a `number` but not finite (`NaN`, `Infinity`, `-Infinity`).
3522
+ * - If `input` is a `string` that is empty after trimming/replacement.
3523
+ * - If `input` is a `string` that fails the numeric validation regex.
3524
+ * - If `input` is of an unsupported type (not `bigint`, `number`, or `string`).
3525
+ * - Any errors propagated from {@link convertExponentialToParts} when parsing exponential forms.
3526
+ *
3527
+ * @example
3528
+ * // bigint input → fractional part is empty
3529
+ * normalizeToDecimalComponents(123n);
3530
+ * // => { sign: 1, integerPart: "123", fractionalPart: "" }
3531
+ *
3532
+ * @example
3533
+ * // negative bigint
3534
+ * normalizeToDecimalComponents(-987654321n);
3535
+ * // => { sign: -1, integerPart: "987654321", fractionalPart: "" }
3536
+ *
3537
+ * @example
3538
+ * // finite number input; uses exponential internally to avoid FP artifacts
3539
+ * normalizeToDecimalComponents(0.0000034);
3540
+ * // => { sign: 1, integerPart: "0", fractionalPart: "0000034" } // exact digits
3541
+ *
3542
+ * @example
3543
+ * // string with decimal comma and explicit sign
3544
+ * normalizeToDecimalComponents("+1,250");
3545
+ * // => { sign: 1, integerPart: "1", fractionalPart: "250" }
3546
+ *
3547
+ * @example
3548
+ * // scientific notation string
3549
+ * normalizeToDecimalComponents("-1.234e+3");
3550
+ * // => { sign: -1, integerPart: "1234", fractionalPart: "" }
3551
+ *
3552
+ * @example
3553
+ * // invalid string (throws)
3554
+ * normalizeToDecimalComponents("12.34.56"); // Error: Invalid numeric string.
3555
+ *
3556
+ * @see convertExponentialToParts
3557
+ * @category Parsing
3558
+ * @since 2.0.0
3559
+ * @public
3560
+ */
3561
+ declare function normalizeToDecimalComponents(input: unknown): {
3562
+ sign: 1 | -1;
3563
+ integerPart: string;
3564
+ fractionalPart: string;
3565
+ };
3566
+
3567
+ /**
3568
+ * Parses any numeric input (`number`, `bigint`, or `string`) into an exact {@link FixedDecimal}
3569
+ * representation, preserving all digits without floating-point rounding errors.
3570
+ *
3571
+ * @remarks
3572
+ * This function transforms arbitrary numeric input into a **fixed-precision decimal structure**
3573
+ * that can safely represent extremely large or small values without losing information.
3574
+ * It achieves this by first decomposing the input using {@link normalizeToDecimalComponents}
3575
+ * and then constructing a `FixedDecimal` object consisting of:
3576
+ *
3577
+ * - `sign` → `1` for positive values, `-1` for negative values.
3578
+ * - `digitsInteger` → a `BigInt` that encodes *all digits* of the number as if
3579
+ * the decimal point were removed.
3580
+ * - `scale` → the count of digits that were originally after the decimal point.
3581
+ *
3582
+ * The resulting value can later be precisely converted back to a string or to a
3583
+ * JavaScript `number` using helpers like `fixedDecimalToStr` or `fixedDecimalToNum`.
3584
+ *
3585
+ * This process **avoids IEEE-754 floating-point artifacts**, ensuring mathematically
3586
+ * exact handling of decimal fractions (e.g. `"0.1" + "0.2" → 0.3` instead of `0.30000000000000004`).
3587
+ *
3588
+ * @param input - Any numeric source value. Supported types:
3589
+ * - `number` — finite only (`NaN`, `Infinity`, `-Infinity` will throw).
3590
+ * - `bigint` — directly converted without fractional digits.
3591
+ * - `string` — may contain optional sign, decimal point, or exponential notation (`1.23e-5`).
3592
+ * Commas `,` as decimal separators are also supported and converted to dots `.`.
3593
+ *
3594
+ * @returns A normalized {@link FixedDecimal} object:
3595
+ * ```ts
3596
+ * {
3597
+ * sign: 1 | -1; // the numeric sign
3598
+ * digitsInteger: bigint; // all digits as a BigInt, no decimal point
3599
+ * scale: number; // number of digits after the decimal
3600
+ * }
3601
+ * ```
3602
+ *
3603
+ * @throws {Error}
3604
+ * - If the input is not a supported type (`number`, `bigint`, or `string`).
3605
+ * - If the string cannot be parsed as a valid numeric representation.
3606
+ * - If the number is not finite.
3607
+ * - Any error propagated from {@link normalizeToDecimalComponents}.
3608
+ *
3609
+ * @example
3610
+ * // Simple integer number
3611
+ * parseToFixedDecimal(42);
3612
+ * // => { sign: 1, digitsInteger: 42n, scale: 0 }
3613
+ *
3614
+ * @example
3615
+ * // Decimal fraction
3616
+ * parseToFixedDecimal("123.456");
3617
+ * // => { sign: 1, digitsInteger: 123456n, scale: 3 }
3618
+ *
3619
+ * @example
3620
+ * // Number in exponential notation
3621
+ * parseToFixedDecimal("-1.23e-4");
3622
+ * // => { sign: -1, digitsInteger: 123n, scale: 6 } // represents -0.000123
3623
+ *
3624
+ * @example
3625
+ * // Leading zeros and trailing fractional zeros are trimmed internally
3626
+ * parseToFixedDecimal("00045.67000");
3627
+ * // => { sign: 1, digitsInteger: 4567n, scale: 2 } // "45.67"
3628
+ *
3629
+ * @example
3630
+ * // Very large integer input using bigint
3631
+ * parseToFixedDecimal(123456789012345678901234567890n);
3632
+ * // => { sign: 1, digitsInteger: 123456789012345678901234567890n, scale: 0 }
3633
+ *
3634
+ * @example
3635
+ * // Negative value with high precision fraction
3636
+ * parseToFixedDecimal("-0.00000003432");
3637
+ * // => { sign: -1, digitsInteger: 3432n, scale: 11 }
3638
+ *
3639
+ * @see normalizeToDecimalComponents
3640
+ * @see FixedDecimal
3641
+ * @see fixedDecimalToNum
3642
+ * @see fixedDecimalToStr
3643
+ *
3644
+ * @category Parsing
3645
+ * @since 2.0.0
3646
+ * @public
3647
+ */
3648
+ declare function parseToFixedDecimal(input: unknown): FixedDecimal;
3649
+
3650
+ /**
3651
+ * Rounds a {@link FixedDecimal} value to the specified number of fractional digits,
3652
+ * using either **half-up** (standard rounding) or **truncation** (cut-off without rounding).
3653
+ *
3654
+ * @remarks
3655
+ * This function operates entirely in fixed-precision integer space (`BigInt` arithmetic),
3656
+ * so rounding is mathematically exact — it never suffers from floating-point errors.
3657
+ *
3658
+ * Internally, it determines how many fractional digits must be removed from
3659
+ * `source.digitsInteger` to reach the desired precision (`decimalPlaces`), divides
3660
+ * by `10 ** digitsToRemove`, and conditionally increments the result depending on
3661
+ * the remainder and rounding mode.
3662
+ *
3663
+ * It preserves the original `sign` and returns a new {@link FixedDecimal} object
3664
+ * with an updated `scale` (number of digits after the decimal point).
3665
+ *
3666
+ * ---
3667
+ * **Rounding modes:**
3668
+ * - `'half-up'` — standard rounding to nearest neighbor; `.5` rounds **away from zero**.
3669
+ * Example: `1.235 → 1.24`, `-1.235 → -1.24`.
3670
+ * - `'trunc'` — truncates digits beyond the target precision (rounds **toward zero**).
3671
+ * Example: `1.239 → 1.23`, `-1.239 → -1.23`.
3672
+ *
3673
+ * ---
3674
+ * @param source - The input {@link FixedDecimal} to round.
3675
+ * Must contain a valid combination of:
3676
+ * - `sign`: `1` or `-1`
3677
+ * - `digitsInteger`: a `BigInt` representing all digits (no decimal point)
3678
+ * - `scale`: number of digits after the decimal
3679
+ *
3680
+ * @param decimalPlaces - Target number of digits to keep **after the decimal point**.
3681
+ * Values less than 0 are treated as 0.
3682
+ * For example, rounding to `2` means "keep two digits after the decimal".
3683
+ *
3684
+ * @param roundMode - Rounding algorithm to use:
3685
+ * - `'half-up'` (default) → rounds 0.5 and higher up.
3686
+ * - `'trunc'` → simply removes extra digits without rounding up.
3687
+ *
3688
+ * @defaultValue `'half-up'`
3689
+ *
3690
+ * @returns A **new** {@link FixedDecimal} with the adjusted `digitsInteger`
3691
+ * and `scale` equal to `decimalPlaces`.
3692
+ * If the requested precision is greater than or equal to `source.scale`,
3693
+ * the source value is returned unchanged (shallow copy).
3694
+ *
3695
+ * @throws {Error}
3696
+ * - Never throws directly in normal use, but may propagate errors if invalid
3697
+ * numeric parameters are passed (e.g., non-integer `decimalPlaces`).
3698
+ *
3699
+ * ---
3700
+ * @example
3701
+ * // Half-up rounding
3702
+ * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 }; // 123.456
3703
+ * roundFixedDecimal(value, 2, 'half-up');
3704
+ * // => { sign: 1, digitsInteger: 12346n, scale: 2 } // 123.46
3705
+ *
3706
+ * @example
3707
+ * // Truncation (cut-off)
3708
+ * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 };
3709
+ * roundFixedDecimal(value, 2, 'trunc');
3710
+ * // => { sign: 1, digitsInteger: 12345n, scale: 2 } // 123.45
3711
+ *
3712
+ * @example
3713
+ * // No rounding needed (scale already smaller)
3714
+ * const v: FixedDecimal = { sign: -1, digitsInteger: 1234n, scale: 1 }; // -123.4
3715
+ * roundFixedDecimal(v, 3);
3716
+ * // => identical copy: { sign: -1, digitsInteger: 1234n, scale: 1 }
3717
+ *
3718
+ * @example
3719
+ * // Rounding very small values
3720
+ * const v: FixedDecimal = { sign: 1, digitsInteger: 123n, scale: 6 }; // 0.000123
3721
+ * roundFixedDecimal(v, 4);
3722
+ * // => { sign: 1, digitsInteger: 1n, scale: 4 } // 0.0001
3723
+ *
3724
+ * @example
3725
+ * // Rounding negative numbers (half-up → away from zero)
3726
+ * const v: FixedDecimal = { sign: -1, digitsInteger: 125n, scale: 2 }; // -1.25
3727
+ * roundFixedDecimal(v, 1, 'half-up');
3728
+ * // => { sign: -1, digitsInteger: 13n, scale: 1 } // -1.3
3729
+ *
3730
+ * @see FixedDecimal
3731
+ * @see parseToFixedDecimal
3732
+ * @see fixedDecimalToNum
3733
+ * @see fixedDecimalToStr
3734
+ * @see formatToNum
3735
+ *
3736
+ * @category Math
3737
+ * @since 2.0.0
3738
+ * @public
3739
+ */
3740
+ declare function roundFixedDecimal(source: FixedDecimal, decimalPlaces: number, roundMode?: 'half-up' | 'trunc'): FixedDecimal;
3741
+
3742
+ /**
3743
+ * Converts any given string-like value into a lower-cased, trimmed string.
3744
+ *
3745
+ * @summary
3746
+ * Safely transforms an unknown value into a normalized lowercase string.
3747
+ * If the input is not a valid non-empty string, the function returns an empty string (`""`).
3748
+ *
3749
+ * @param value - Any unknown input to convert to lowercase.
3750
+ *
3751
+ * @returns A lowercase string, or an empty string if the input is not a valid string.
3752
+ *
3753
+ * @remarks
3754
+ * ### Processing steps
3755
+ * 1. **Type check** — ensures the input is a string using {@link isStr}.
3756
+ * 2. **Trimming** — removes leading and trailing whitespace via {@link formatToTrim}.
3757
+ * 3. **Validation** — ensures the result is non-empty with {@link isStrFilled}.
3758
+ * 4. **Lowercasing** — calls `String.prototype.toLowerCase()` on the trimmed text.
3759
+ * 5. If the string is empty or not valid at any step, returns `""`.
3760
+ *
3761
+ * ### Error safety
3762
+ * - The function **never throws**, regardless of input type.
3763
+ * - Non-string inputs (numbers, booleans, objects, arrays, `null`, `undefined`) all yield `""`.
3764
+ *
3765
+ * ### Use cases
3766
+ * - Case-insensitive string comparison (normalize both sides with `formatToLowerCase`).
3767
+ * - Normalizing user input before storing or indexing.
3768
+ * - Simplifying logic where optional strings may be `null` or empty.
3769
+ *
3770
+ * ### Performance
3771
+ * - Time complexity: **O(n)** (where `n` = string length, due to trimming and lowercasing).
3772
+ * - Space complexity: **O(n)** (new string created by normalization).
3773
+ *
3774
+ * ### Examples
3775
+ *
3776
+ * @example
3777
+ * // Basic strings
3778
+ * formatToLowerCase('HELLO'); // => "hello"
3779
+ * formatToLowerCase(' TEST '); // => "test"
3780
+ *
3781
+ * @example
3782
+ * // Mixed types
3783
+ * formatToLowerCase(123); // => ""
3784
+ * formatToLowerCase(true); // => ""
3785
+ * formatToLowerCase(null); // => ""
3786
+ *
3787
+ * @example
3788
+ * // Empty or whitespace inputs
3789
+ * formatToLowerCase(' '); // => ""
3790
+ * formatToLowerCase(''); // => ""
3791
+ *
3792
+ * @example
3793
+ * // Already lowercase
3794
+ * formatToLowerCase('data'); // => "data"
3795
+ *
3796
+ * @see isStr
3797
+ * @see isStrFilled
3798
+ * @see formatToTrim
3799
+ *
3800
+ * @category String
3801
+ * @public
3802
+ * @since 2.0.0
3803
+ */
3804
+ declare function formatToLowerCase(value?: unknown): string;
3805
+
3806
+ /**
3807
+ * Converts `undefined` or empty (whitespace-only) strings into `null`.
3808
+ *
3809
+ * @summary
3810
+ * Safely normalizes optional values by replacing both `undefined` and blank strings
3811
+ * with `null`, while preserving all other values as-is.
3812
+ * This helps unify "missing" or "empty" values under a single, database-friendly
3813
+ * `null` representation.
3814
+ *
3815
+ * @param value - Any input value that may be a string, `undefined`, or another type.
3816
+ *
3817
+ * @returns
3818
+ * - `null` if:
3819
+ * - The input is `undefined`, or
3820
+ * - The input is a string that becomes empty after trimming (using {@link formatToTrim}).
3821
+ * - Otherwise returns the original `value`.
3822
+ *
3823
+ * @remarks
3824
+ * ### Processing steps
3825
+ * 1. If `value` is `undefined`, returns `null`.
3826
+ * 2. If `value` is a string:
3827
+ * - Trims it with {@link formatToTrim}, removing whitespace and invisible characters.
3828
+ * - If the trimmed result is empty (`''`), returns `null`.
3829
+ * 3. Otherwise returns the original value unchanged.
3830
+ *
3831
+ * ### Behavior notes
3832
+ * - Non-string, defined values (like `0`, `false`, `{}`, `[]`) are **not modified**.
3833
+ * - The function is **pure** (non-mutating) and safe for use in JSON or ORM normalization.
3834
+ * - Often used to prepare form data, REST payloads, or DB entities for consistent nullability.
3835
+ *
3836
+ * ### Comparison with {@link formatToUndefined}
3837
+ * | Case | `formatToNull` | `formatToUndefined` |
3838
+ * |------|----------------|----------------------|
3839
+ * | `undefined` | `null` | `undefined` |
3840
+ * | `''` (empty string) | `null` | `undefined` |
3841
+ * | `'text'` | `'text'` | `'text'` |
3842
+ * | non-string (e.g. `0`) | `0` | `0` |
3843
+ *
3844
+ * ### Use cases
3845
+ * - Unifying “empty” form values before DB insertion (`''` or `undefined` → `null`)
3846
+ * - Sanitizing request bodies before persistence or validation
3847
+ * - Preventing inconsistent null/undefined states across backend and frontend layers
3848
+ *
3849
+ * ### Performance
3850
+ * - Time complexity: **O(n)** (depends on string length)
3851
+ * - Space complexity: **O(n)** (creates a trimmed string copy)
3852
+ *
3853
+ * ### Examples
3854
+ *
3855
+ * @example
3856
+ * // Empty and whitespace strings
3857
+ * formatToNull(''); // => null
3858
+ * formatToNull(' '); // => null
3859
+ *
3860
+ * @example
3861
+ * // Undefined also becomes null
3862
+ * formatToNull(undefined); // => null
3863
+ *
3864
+ * @example
3865
+ * // Non-empty strings remain as-is
3866
+ * formatToNull('Hello'); // => "Hello"
3867
+ * formatToNull(' Data '); // => " Data "
3868
+ *
3869
+ * @example
3870
+ * // Non-string types are preserved
3871
+ * formatToNull(0); // => 0
3872
+ * formatToNull(false); // => false
3873
+ * formatToNull([]); // => []
3874
+ * formatToNull({}); // => {}
3875
+ *
3876
+ * @see isStr
3877
+ * @see formatToTrim
3878
+ * @see formatToUndefined
3879
+ *
3880
+ * @category String
3881
+ * @public
3882
+ * @since 2.0.0
3883
+ */
3884
+ declare function formatToNull(value: unknown): {} | null;
3885
+
3886
+ /**
3887
+ * Normalizes and validates a phone number into international format (`E.164` style).
3888
+ *
3889
+ * @summary
3890
+ * Converts various human-entered phone number formats (with spaces, dashes, parentheses,
3891
+ * or local prefixes) into a clean, standardized string beginning with `"+"`
3892
+ * and containing 10–15 digits.
3893
+ *
3894
+ * Returns `null` if the value is not a valid phone number after normalization.
3895
+ *
3896
+ * @param value - The input value to format. Can be any unknown type; only strings are processed.
3897
+ * @param defaultCountry - Optional international prefix to prepend for 10-digit local numbers
3898
+ * (defaults to `"+7"` — Russia/Kazakhstan).
3899
+ * Use your target country code (e.g., `"+34"` for Spain, `"+1"` for USA).
3900
+ *
3901
+ * @returns
3902
+ * A normalized phone number in `+XXXXXXXXXX` format if valid, or `null` if the input
3903
+ * cannot be interpreted as a valid number.
3904
+ *
3905
+ * @remarks
3906
+ * ### Normalization rules
3907
+ * 1. **Input validation:**
3908
+ * If `value` is not a string, returns `null`.
3909
+ *
3910
+ * 2. **Trimming and cleaning:**
3911
+ * Removes all whitespace, hyphens, parentheses, and dots.
3912
+ * Example:
3913
+ * `" (123) 456-7890 "` → `"1234567890"`.
3914
+ *
3915
+ * 3. **International formats:**
3916
+ * - `00` prefix (common in Europe) is replaced with `"+"`.
3917
+ * → `"0049123456789"` → `"+49123456789"`.
3918
+ *
3919
+ * 4. **Local numbers (10 digits):**
3920
+ * Prepends the `defaultCountry` code.
3921
+ * → `"1234567890"` → `"+71234567890"` (default country `+7`).
3922
+ *
3923
+ * 5. **Generic international numbers (9–15 digits):**
3924
+ * If not starting with `"0"`, adds `"+"` prefix.
3925
+ * → `"380501234567"` → `"+380501234567"`.
3926
+ *
3927
+ * 6. **Validation check:**
3928
+ * The result must match the pattern `/^\+\d{10,15}$/`
3929
+ * — i.e., plus sign followed by 10–15 digits.
3930
+ * If not, returns `null`.
3931
+ *
3932
+ * ### Error safety
3933
+ * - Never throws — all invalid or unexpected inputs return `null`.
3934
+ * - Automatically cleans up common formatting symbols without side effects.
3935
+ *
3936
+ * ### Performance
3937
+ * - Time complexity: **O(n)** (string length).
3938
+ * - Space complexity: **O(n)** (new string creation during cleanup).
3939
+ *
3940
+ * ### Common pitfalls
3941
+ * - Numbers starting with `"0"` are **rejected**, since they are ambiguous.
3942
+ * - 8-digit local formats are not automatically expanded — use a country-specific parser if needed.
3943
+ * - This function performs **basic formatting and validation**, not full ITU-T E.164 compliance.
3944
+ *
3945
+ * ### Examples
3946
+ *
3947
+ * @example
3948
+ * // International format already valid
3949
+ * formatToPhone('+380501234567'); // => "+380501234567"
3950
+ *
3951
+ * @example
3952
+ * // European "00" prefix
3953
+ * formatToPhone('00442079460729'); // => "+442079460729"
3954
+ *
3955
+ * @example
3956
+ * // Local 10-digit number (default country +7)
3957
+ * formatToPhone('9123456789'); // => "+79123456789"
3958
+ *
3959
+ * @example
3960
+ * // With custom default country
3961
+ * formatToPhone('9876543210', '+34'); // => "+349876543210"
3962
+ *
3963
+ * @example
3964
+ * // Strings with spaces, punctuation, parentheses
3965
+ * formatToPhone('(050) 123-45-67'); // => "+70501234567"
3966
+ * formatToPhone('+1 (202) 555-0183'); // => "+12025550183"
3967
+ *
3968
+ * @example
3969
+ * // Invalid or ambiguous inputs
3970
+ * formatToPhone(''); // => null
3971
+ * formatToPhone('000123456'); // => null
3972
+ * formatToPhone('abcdefgh'); // => null
3973
+ * formatToPhone(null); // => null
3974
+ * formatToPhone(true); // => null
3975
+ *
3976
+ * @see isStr
3977
+ * @see formatToTrim
3978
+ *
3979
+ * @category String
3980
+ * @public
3981
+ * @since 2.0.0
3982
+ */
3983
+ declare function formatToPhone(value?: unknown, defaultCountry?: string): string | null;
3984
+
3985
+ /**
3986
+ * Trims, normalizes, and cleans up invisible characters from a string.
3987
+ *
3988
+ * @summary
3989
+ * Safely converts any input into a clean, Unicode-normalized string with all
3990
+ * leading/trailing whitespace removed and zero-width characters stripped out.
3991
+ *
3992
+ * Returns an empty string (`""`) for all non-string inputs.
3993
+ *
3994
+ * @param value - Any value that may contain text or string-like content.
3995
+ *
3996
+ * @returns A normalized, trimmed string without invisible Unicode separators.
3997
+ * Returns an empty string if `value` is not a string.
3998
+ *
3999
+ * @remarks
4000
+ * ### Processing steps
4001
+ * 1. **Type check:**
4002
+ * Uses {@link isStr} to ensure the input is a string.
4003
+ * Non-strings are converted to `""`.
4004
+ *
4005
+ * 2. **Trimming:**
4006
+ * Removes all leading and trailing whitespace (`String.prototype.trim()`).
4007
+ *
4008
+ * 3. **Unicode normalization:**
4009
+ * Applies `normalize('NFKC')` — Compatibility Composition — which:
4010
+ * - Converts full-width and compatibility forms into canonical ones.
4011
+ * Example: `"ABC"` → `"ABC"`.
4012
+ * - Normalizes composed characters (e.g., `"é"` vs `"é"`).
4013
+ *
4014
+ * 4. **Invisible character cleanup:**
4015
+ * Removes hidden zero-width Unicode characters commonly introduced by copy/paste:
4016
+ * - `U+200B` ZERO WIDTH SPACE
4017
+ * - `U+200C` ZERO WIDTH NON-JOINER
4018
+ * - `U+200D` ZERO WIDTH JOINER
4019
+ * - `U+FEFF` ZERO WIDTH NO-BREAK SPACE (BOM)
4020
+ *
4021
+ * 5. **Safe stringification:**
4022
+ * Non-string values are returned as empty string rather than `"undefined"` or `"null"`.
4023
+ *
4024
+ * ### Benefits
4025
+ * - Eliminates subtle text differences that break comparisons or hashing.
4026
+ * - Prevents user input issues caused by hidden characters.
4027
+ * - Safe to use in both frontend and backend environments.
4028
+ *
4029
+ * ### Performance
4030
+ * - Time complexity: **O(n)** — proportional to the input string length.
4031
+ * - Space complexity: **O(n)** — creates a new normalized copy.
4032
+ *
4033
+ * ### Common use cases
4034
+ * - Sanitizing user input before validation or storage.
4035
+ * - Cleaning keys, tags, and names from external data sources.
4036
+ * - Preparing values for strict equality or hashing.
4037
+ *
4038
+ * ### Examples
4039
+ *
4040
+ * @example
4041
+ * // Basic trimming
4042
+ * formatToTrim(' Hello '); // => "Hello"
4043
+ *
4044
+ * @example
4045
+ * // Removes zero-width characters
4046
+ * formatToTrim('word\u200B'); // => "word"
4047
+ *
4048
+ * @example
4049
+ * // Unicode normalization
4050
+ * formatToTrim('ABC'); // => "ABC"
4051
+ * formatToTrim('e\u0301'); // => "é"
4052
+ *
4053
+ * @example
4054
+ * // Non-string inputs
4055
+ * formatToTrim(123); // => ""
4056
+ * formatToTrim(null); // => ""
4057
+ * formatToTrim(undefined); // => ""
4058
+ * formatToTrim({ text: 'hi' }); // => ""
4059
+ *
4060
+ * @see isStr
4061
+ * @see String.prototype.normalize
4062
+ *
4063
+ * @category String
4064
+ * @public
4065
+ * @since 2.0.0
4066
+ */
4067
+ declare function formatToTrim(value: unknown): string;
4068
+
4069
+ /**
4070
+ * Converts `null` or empty (whitespace-only) strings into `undefined`.
4071
+ *
4072
+ * @summary
4073
+ * Normalizes optional values by replacing both `null` and blank strings
4074
+ * with `undefined`, while keeping all other values unchanged.
4075
+ * This is useful when preparing objects for APIs or serialization,
4076
+ * where `undefined` fields are automatically omitted or ignored.
4077
+ *
4078
+ * @param value - Any value that may be a string, `null`, or another type.
4079
+ *
4080
+ * @returns
4081
+ * - `undefined` if:
4082
+ * - The value is `null`, or
4083
+ * - The value is a string that becomes empty after trimming (via {@link formatToTrim}).
4084
+ * - Otherwise returns the original value.
4085
+ *
4086
+ * @remarks
4087
+ * ### Processing steps
4088
+ * 1. If `value` is `null`, return `undefined`.
4089
+ * 2. If `value` is a string:
4090
+ * - Trim using {@link formatToTrim} to remove whitespace and invisible characters.
4091
+ * - If trimmed result is empty, return `undefined`.
4092
+ * 3. Otherwise, return the original value unchanged.
4093
+ *
4094
+ * ### Behavior notes
4095
+ * - Non-string, non-null values (`0`, `false`, `{}`, `[]`, etc.) are **not modified**.
4096
+ * - The function is **non-mutating** — it never changes the original reference.
4097
+ * - It complements {@link formatToNull}, depending on whether your system
4098
+ * prefers `undefined` (omit field) or `null` (explicit empty value).
4099
+ *
4100
+ * ### Comparison with {@link formatToNull}
4101
+ * | Case | `formatToNull` | `formatToUndefined` |
4102
+ * |------|----------------|----------------------|
4103
+ * | `null` | `null` | `undefined` |
4104
+ * | `undefined` | `null` | `undefined` |
4105
+ * | `''` (empty string) | `null` | `undefined` |
4106
+ * | `'text'` | `'text'` | `'text'` |
4107
+ * | Non-string (e.g. `0`) | `0` | `0` |
4108
+ *
4109
+ * ### Use cases
4110
+ * - Preparing data before sending to REST or GraphQL APIs
4111
+ * (so empty fields are omitted during JSON serialization)
4112
+ * - Cleaning form input values before saving or validation
4113
+ * - Ensuring `undefined` consistency in optional object properties
4114
+ *
4115
+ * ### Performance
4116
+ * - Time complexity: **O(n)** (depends on string length)
4117
+ * - Space complexity: **O(n)** (due to string trimming)
4118
+ *
4119
+ * ### Examples
4120
+ *
4121
+ * @example
4122
+ * // Empty and whitespace-only strings
4123
+ * formatToUndefined(''); // => undefined
4124
+ * formatToUndefined(' '); // => undefined
4125
+ *
4126
+ * @example
4127
+ * // null is also normalized
4128
+ * formatToUndefined(null); // => undefined
4129
+ *
4130
+ * @example
4131
+ * // Non-empty strings remain unchanged
4132
+ * formatToUndefined('Hello'); // => "Hello"
4133
+ *
4134
+ * @example
4135
+ * // Non-string types are preserved
4136
+ * formatToUndefined(0); // => 0
4137
+ * formatToUndefined(false); // => false
4138
+ * formatToUndefined([]); // => []
4139
+ * formatToUndefined({}); // => {}
4140
+ *
4141
+ * @see isStr
4142
+ * @see formatToTrim
4143
+ * @see formatToNull
4144
+ *
4145
+ * @category String
4146
+ * @public
4147
+ * @since 2.0.0
4148
+ */
4149
+ declare function formatToUndefined(value: unknown): {} | undefined;
4150
+
4151
+ /**
4152
+ * Converts a numeric value with a given unit (bytes, KB, MB, GB, TB, PB)
4153
+ * into gigabytes (`GB`).
4154
+ *
4155
+ * @summary
4156
+ * Safely normalizes a size value of any supported unit into **gigabytes**,
4157
+ * using binary multiples (`1 KB = 1024 bytes`, `1 MB = 1024 KB`, etc.).
4158
+ *
4159
+ * @param value - Numeric value to convert (e.g., `512`, `"1.5"`, `"2048MB"`).
4160
+ * @param unit - Optional unit string indicating the scale of `value`.
4161
+ * Case-insensitive. Supported prefixes:
4162
+ * `"B"`, `"KB"`, `"MB"`, `"GB"`, `"TB"`, `"PB"`.
4163
+ *
4164
+ * @returns The value converted to gigabytes (`number`).
4165
+ *
4166
+ * @throws {Error}
4167
+ * Throws an error if the input value cannot be parsed as a finite number,
4168
+ * or if the computed result is `NaN` or `Infinity`.
4169
+ *
4170
+ * @remarks
4171
+ * ### Supported units
4172
+ * | Unit | Interpreted as | Conversion formula |
4173
+ * |------|----------------|--------------------|
4174
+ * | `b`, `B`, `bytes` | bytes | `v / GB` |
4175
+ * | `k`, `kb`, `kilobyte` | kilobytes | `v / MB` |
4176
+ * | `m`, `mb`, `megabyte` | megabytes | `v / GB` |
4177
+ * | `g`, `gb`, `gigabyte` | gigabytes | `v` |
4178
+ * | `t`, `tb`, `terabyte` | terabytes | `v * 1024` |
4179
+ * | `p`, `pb`, `petabyte` | petabytes | `v * (1024²)` |
4180
+ *
4181
+ * If no unit is provided, gigabytes (`GB`) are assumed by default.
4182
+ *
4183
+ * ### Normalization steps
4184
+ * 1. Convert `value` to a numeric value using {@link formatToNum}.
4185
+ * 2. Validate via {@link isNum} — must be finite.
4186
+ * 3. Normalize `unit`:
4187
+ * - Trim whitespace.
4188
+ * - Convert to lowercase.
4189
+ * - Extract first character (e.g., `'k'` for `"KB"`).
4190
+ * 4. Compute conversion factor depending on the first letter.
4191
+ * 5. Normalize `-0` to `0` before returning.
4192
+ *
4193
+ * ### Behavior notes
4194
+ * - Throws descriptive errors on invalid inputs.
4195
+ * - Supports string-based numeric inputs (`"2048"`, `"1.5"`, etc.).
4196
+ * - Ignores case and trailing spaces in the unit name.
4197
+ * - Uses binary (IEC-style) 1024-based units — not SI 1000-based.
4198
+ *
4199
+ * ### Performance
4200
+ * - Time complexity: **O(1)**.
4201
+ * - Space complexity: **O(1)**.
4202
+ *
4203
+ * ### Examples
4204
+ *
4205
+ * @example
4206
+ * // Basic conversions
4207
+ * toGB(1024, 'MB'); // => 1
4208
+ * toGB(1, 'GB'); // => 1
4209
+ * toGB(1, 'TB'); // => 1024
4210
+ * toGB(0.5, 'TB'); // => 512
4211
+ *
4212
+ * @example
4213
+ * // From bytes
4214
+ * toGB(1073741824, 'B'); // => 1
4215
+ * toGB('2147483648', 'b'); // => 2
4216
+ *
4217
+ * @example
4218
+ * // From petabytes
4219
+ * toGB(1, 'PB'); // => 1048576
4220
+ *
4221
+ * @example
4222
+ * // Auto-handling and normalization
4223
+ * toGB(' 1.5 ', ' mb '); // => 0.00146484375
4224
+ * toGB('2', ''); // => 2 (default is GB)
4225
+ *
4226
+ * @example
4227
+ * // Invalid inputs
4228
+ * toGB('abc', 'GB'); // throws Error("toGB: value "abc" is not numeric")
4229
+ * toGB(NaN, 'MB'); // throws Error("toGB: result is not finite...")
4230
+ *
4231
+ * @see isNum
4232
+ * @see formatToNum
4233
+ *
4234
+ * @category Conversion
4235
+ * @public
4236
+ * @since 2.0.0
4237
+ */
4238
+ declare function toGB(value: unknown, unit?: string): number;
4239
+
4240
+ /**
4241
+ * Converts a hashrate (or similar magnitude value) into **gigahashes per second** (`GH/s`).
4242
+ *
4243
+ * @summary
4244
+ * Normalizes a numeric value expressed in various hash rate units (e.g., `kH/s`, `MH/s`, `TH/s`)
4245
+ * to **gigahashes (GH)**, using standard decimal scaling (`×1000` between adjacent prefixes).
4246
+ *
4247
+ * @param value - Input numeric value or string representing a number (e.g. `"1200"`, `3.5`).
4248
+ * @param unit - Optional unit string representing the magnitude (`H`, `kH`, `MH`, `GH`, `TH`, `PH`, `EH`).
4249
+ * Case-insensitive and automatically normalized via {@link normalizeUnit}.
4250
+ *
4251
+ * @returns The normalized value expressed in **gigahashes per second (GH/s)**.
4252
+ * Returns `0` if the input is invalid or non-numeric.
4253
+ *
4254
+ * @remarks
4255
+ * ### Conversion logic
4256
+ * 1. **Parsing:**
4257
+ * Uses {@link formatToNum} to safely convert `value` into a number.
4258
+ *
4259
+ * 2. **Validation:**
4260
+ * If the parsed number is not finite (`NaN`, `Infinity`, etc.), returns `0`.
4261
+ *
4262
+ * 3. **Unit normalization:**
4263
+ * Calls {@link normalizeUnit} to clean up and simplify the unit name (e.g. `" MH/s "` → `"mh"`).
4264
+ * Then takes the first character (`m`, `g`, `t`, etc.) to determine scale.
4265
+ *
4266
+ * 4. **Factor lookup:**
4267
+ * Applies the following conversion factors relative to gigahashes:
4268
+ *
4269
+ * | Prefix | Unit | Factor (to GH) | Example conversion |
4270
+ * |---------|-----------|----------------|--------------------------------|
4271
+ * | `h` | hashes/s | `1e-9` | `1e9 H/s` = `1 GH/s` |
4272
+ * | `k` | kilohash | `1e-6` | `1e6 kH/s` = `1 GH/s` |
4273
+ * | `m` | megahash | `1e-3` | `1e3 MH/s` = `1 GH/s` |
4274
+ * | `g` | gigahash | `1` | identity |
4275
+ * | `t` | terahash | `1e3` | `1 TH/s` = `1000 GH/s` |
4276
+ * | `p` | petahash | `1e6` | `1 PH/s` = `1,000,000 GH/s` |
4277
+ * | `e` | exahash | `1e9` | `1 EH/s` = `1,000,000,000 GH/s`|
4278
+ *
4279
+ * 5. **Result validation:**
4280
+ * If the final result is not a finite number, throws an error.
4281
+ * Otherwise returns the computed gigahashes value (with `-0` normalized to `0`).
4282
+ *
4283
+ * ### Behavior notes
4284
+ * - Returns `0` instead of throwing when the input cannot be parsed as a number.
4285
+ * - Uses **decimal scaling** (`×1000`), not binary (`×1024`).
4286
+ * - Handles both numeric and string inputs seamlessly.
4287
+ * - Automatically ignores plural or rate suffixes (like `/s`, `hashes`).
4288
+ *
4289
+ * ### Performance
4290
+ * - Time complexity: **O(1)**.
4291
+ * - Space complexity: **O(1)**.
4292
+ *
4293
+ * ### Examples
4294
+ *
4295
+ * @example
4296
+ * // Basic conversions
4297
+ * toGH(1, 'GH'); // => 1
4298
+ * toGH(1, 'TH'); // => 1000
4299
+ * toGH(1, 'MH'); // => 0.001
4300
+ * toGH(1, 'kH'); // => 0.000001
4301
+ * toGH(1, 'PH'); // => 1_000_000
4302
+ * toGH(1, 'EH'); // => 1_000_000_000
4303
+ *
4304
+ * @example
4305
+ * // String inputs and normalization
4306
+ * toGH('1200', 'mh/s'); // => 1.2
4307
+ * toGH('3.5', 'TH/s'); // => 3500
4308
+ *
4309
+ * @example
4310
+ * // Invalid or edge inputs
4311
+ * toGH('', 'GH'); // => 0
4312
+ * toGH(null, 'GH'); // => 0
4313
+ * toGH(NaN, 'MH'); // => 0
4314
+ *
4315
+ * @example
4316
+ * // Custom normalization of unit formatting
4317
+ * toGH(5, ' khash / s '); // => 0.000005
4318
+ * toGH(2, 'T'); // => 2000
4319
+ *
4320
+ * @see formatToNum
4321
+ * @see isNum
4322
+ * @see normalizeUnit
4323
+ *
4324
+ * @category Conversion
4325
+ * @public
4326
+ * @since 2.0.0
4327
+ */
4328
+ declare function toGH(value: any, unit?: string): number;
4329
+
4330
+ /**
4331
+ * Converts a rate value expressed with SI hash-rate prefixes into **hashes per second** (`H/s`).
4332
+ *
4333
+ * @summary
4334
+ * Normalizes a numeric value given in `kH/s`, `MH/s`, `GH/s`, `TH/s`, `PH/s`, or `EH/s`
4335
+ * to plain **hashes per second** using **decimal scaling** (×1000 between adjacent prefixes).
4336
+ * Units are case-insensitive and sanitized via {@link normalizeUnit}.
4337
+ *
4338
+ * @param value - Input value to convert (number or number-like string, e.g. `3.5`, `"1200"`).
4339
+ * @param unit - Optional unit string (e.g. `"kH/s"`, `"MH"`, `"ghashes"`).
4340
+ * If omitted or empty, the function assumes **`h`** (hashes).
4341
+ *
4342
+ * @returns The value converted to **H/s** (`number`). Returns `0` if `value` is not numeric.
4343
+ *
4344
+ * @remarks
4345
+ * ### Unit handling
4346
+ * `unit` is first cleaned by {@link normalizeUnit} (trim, lowercase, remove spaces and `"/s"`, `"hash(es)"`),
4347
+ * then the **first character** determines the scale:
4348
+ *
4349
+ * | Prefix | Interpreted as | Multiplier to H/s |
4350
+ * |:------:|-----------------|-------------------|
4351
+ * | `h` | hashes | `1` |
4352
+ * | `k` | kilohashes | `1e3` |
4353
+ * | `m` | megahashes | `1e6` |
4354
+ * | `g` | gigahashes | `1e9` |
4355
+ * | `t` | terahashes | `1e12` |
4356
+ * | `p` | petahashes | `1e15` |
4357
+ * | `e` | exahashes | `1e18` |
4358
+ *
4359
+ * Unknown or empty prefixes default to `h` (no scaling).
4360
+ *
4361
+ * ### Parsing & validation
4362
+ * - Uses {@link formatToNum} to parse `value`.
4363
+ * - If parsed value is not a finite number, returns `0`.
4364
+ * - After conversion, if the result is not finite, throws an error with details.
4365
+ * - Normalizes `-0` to `0` before returning.
4366
+ *
4367
+ * ### Decimal vs binary
4368
+ * This function uses **decimal** (SI) steps (×1000) common for hashrates.
4369
+ * For byte/size conversions use binary (×1024) helpers like `toGB`.
4370
+ *
4371
+ * ### Performance
4372
+ * - Time complexity: **O(1)**
4373
+ * - Space complexity: **O(1)**
4374
+ *
4375
+ * ### Examples
4376
+ *
4377
+ * @example
4378
+ * // Identity and basic scales
4379
+ * toH(1, 'H'); // => 1
4380
+ * toH(1, 'kH'); // => 1_000
4381
+ * toH(1, 'MH'); // => 1_000_000
4382
+ * toH(1, 'GH'); // => 1_000_000_000
4383
+ * toH(2.5, 'TH'); // => 2_500_000_000_000
4384
+ *
4385
+ * @example
4386
+ * // Large magnitudes
4387
+ * toH(1, 'PH'); // => 1_000_000_000_000_000
4388
+ * toH(0.01, 'EH'); // => 10_000_000_000_000_000
4389
+ *
4390
+ * @example
4391
+ * // Flexible, noisy units and strings
4392
+ * toH('1200', ' mh/s '); // => 1_200_000
4393
+ * toH(3.2, 'khashes'); // => 3_200
4394
+ * toH('5', ''); // => 5 (defaults to hashes)
4395
+ *
4396
+ * @example
4397
+ * // Invalid inputs
4398
+ * toH('', 'GH'); // => 0
4399
+ * toH(null, 'MH'); // => 0
4400
+ * toH(NaN, 'kH'); // => 0
4401
+ *
4402
+ * @see normalizeUnit
4403
+ * @see formatToNum
4404
+ * @see isNum
4405
+ *
4406
+ * @category Conversion
4407
+ * @public
4408
+ * @since 2.0.0
4409
+ */
4410
+ declare function toH(value: any, unit?: string): number;
4411
+
4412
+ /**
4413
+ * Extracts the **hostname** (IPv4, IPv6, or domain) from a URL-like string.
4414
+ *
4415
+ * @summary
4416
+ * Parses a given string as a URL or host reference and returns the **host component**
4417
+ * (without protocol, port, path, query, or credentials).
4418
+ * Handles both valid URLs (via {@link URL}) and malformed or scheme-less inputs using fallback parsing.
4419
+ *
4420
+ * @param value - Any string that may represent a URL, host, or address.
4421
+ *
4422
+ * @returns
4423
+ * The hostname (domain or IP address) as a plain string.
4424
+ * Returns an empty string (`""`) if the input is blank or cannot be parsed.
4425
+ *
4426
+ * @remarks
4427
+ * ### Parsing strategy
4428
+ * 1. **Scheme detection:**
4429
+ * - If the input starts with a protocol scheme (e.g., `http:`, `ftp:`), it is parsed directly.
4430
+ * - Otherwise, a default `http://` prefix is prepended so the built-in {@link URL} parser can process it.
4431
+ *
4432
+ * 2. **Primary parsing:**
4433
+ * - Uses the native {@link URL} class to extract `hostname`.
4434
+ * - Automatically handles IPv6 literals, punycode domains, and IDNs.
4435
+ *
4436
+ * 3. **Fallback parsing (for invalid URLs):**
4437
+ * - Strips credentials (`user:pass@`).
4438
+ * - Extracts the first segment before `/`, `?`, or `#`.
4439
+ * - If the result looks like `[::1]` or `[2001:db8::1]`, returns the IPv6 address inside brackets.
4440
+ * - Otherwise, takes everything before the first colon (`:`) as the hostname.
4441
+ *
4442
+ * ### Supported formats
4443
+ * - Full URLs:
4444
+ * `"https://user:pass@sub.example.com:8080/path"` → `"sub.example.com"`
4445
+ * - Host with port:
4446
+ * `"example.com:3000"` → `"example.com"`
4447
+ * - IPv4:
4448
+ * `"192.168.1.1:4028"` → `"192.168.1.1"`
4449
+ * - IPv6 (with or without brackets):
4450
+ * `"[2001:db8::1]:4028"` → `"2001:db8::1"`
4451
+ * - Without scheme:
4452
+ * `"example.com/test?q=1"` → `"example.com"`
4453
+ *
4454
+ * ### Behavior notes
4455
+ * - Returns an empty string if `value` is empty, blank, or unparsable.
4456
+ * - Never throws — all exceptions are caught and handled gracefully.
4457
+ * - Does **not** include port numbers or authentication info.
4458
+ * - Automatically trims whitespace before parsing.
4459
+ *
4460
+ * ### Performance
4461
+ * - Time complexity: **O(n)** (linear in string length).
4462
+ * - Space complexity: **O(n)** (creates trimmed and split substrings).
4463
+ *
4464
+ * ### Examples
4465
+ *
4466
+ * @example
4467
+ * // Standard URLs
4468
+ * extractHost('https://example.com/path'); // => "example.com"
4469
+ * extractHost('http://user:pass@site.org:8080'); // => "site.org"
4470
+ *
4471
+ * @example
4472
+ * // Without scheme
4473
+ * extractHost('example.com/foo/bar'); // => "example.com"
4474
+ * extractHost('sub.domain.net:3000'); // => "sub.domain.net"
4475
+ *
4476
+ * @example
4477
+ * // IP addresses
4478
+ * extractHost('192.168.0.10:4028'); // => "192.168.0.10"
4479
+ * extractHost('[2001:db8::1]:80'); // => "2001:db8::1"
4480
+ *
4481
+ * @example
4482
+ * // Invalid or blank input
4483
+ * extractHost(''); // => ""
4484
+ * extractHost('not a valid host'); // => "not"
4485
+ *
4486
+ * @see URL
4487
+ * @see isStrFilled
4488
+ *
4489
+ * @category Network
4490
+ * @public
4491
+ * @since 2.0.0
4492
+ */
4493
+ declare function extractHost(value?: string): string;
4494
+
4495
+ export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgs, formatToBool, formatToLowerCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, isArr, isArrFilled, isBool, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };