full-utils 2.0.5 → 3.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.
package/dist/index.d.cts CHANGED
@@ -27,9 +27,9 @@
27
27
  * - **Macro / call marker**: If a token starts with `$`, contains `(`, and ends
28
28
  * with `)`, it is returned unchanged (e.g., `"$env(PATH)"`).
29
29
  * - **Literals**: `null` → `null`, `undefined` → `undefined`.
30
- * - **Booleans**: Using {@link isStrBool} + {@link formatToBool} (e.g., `"true"`,
30
+ * - **Booleans**: Using {@link isStrBool} + {@link boolNormalize} (e.g., `"true"`,
31
31
  * `"False"`, `"yes"`, `"0"` depending on your implementation).
32
- * - **Numbers**: Using {@link formatToNum}. If the result is finite, it is returned.
32
+ * - **Numbers**: Using {@link numNormalize}. If the result is finite, it is returned.
33
33
  * Explicit `"Infinity"` and `"-Infinity"` are also supported.
34
34
  * - **Quoted strings**: `'text'` or `"text"` → inner text with escapes processed
35
35
  * (`\\` → `\`, `\'` → `'`, `\"` → `"`).
@@ -54,44 +54,44 @@
54
54
  * do so in a sandbox with explicit allow-lists.
55
55
  *
56
56
  * ### Limitations
57
- * - Numerical parsing relies on {@link formatToNum}. Extremely large or high-precision
57
+ * - Numerical parsing relies on {@link numNormalize}. Extremely large or high-precision
58
58
  * decimals may still be subject to JavaScript `number` precision limits unless your
59
- * `formatToNum` converts to a safer representation.
59
+ * `numNormalize` converts to a safer representation.
60
60
  * - Only basic backslash escapes are handled in quoted strings (no `\uXXXX` decoding here).
61
61
  * - Whitespace outside quotes is trimmed from each token; internal whitespace is preserved.
62
62
  *
63
63
  * @example
64
64
  * // Basic values
65
- * formatStrToFuncArgsArr('1, true, "hello"'); // => [1, true, "hello"]
65
+ * arrFuncArgs('1, true, "hello"'); // => [1, true, "hello"]
66
66
  *
67
67
  * @example
68
68
  * // Bracket-wrapped list
69
- * formatStrToFuncArgsArr('[1, 2, 3]'); // => [1, 2, 3]
69
+ * arrFuncArgs('[1, 2, 3]'); // => [1, 2, 3]
70
70
  *
71
71
  * @example
72
72
  * // Nested structures and quoting
73
- * formatStrToFuncArgsArr('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
73
+ * arrFuncArgs('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
74
74
  *
75
75
  * @example
76
76
  * // Booleans, null/undefined, and Infinity
77
- * formatStrToFuncArgsArr('yes, NO, null, undefined, Infinity, -Infinity');
77
+ * arrFuncArgs('yes, NO, null, undefined, Infinity, -Infinity');
78
78
  * // => [true, false, null, undefined, Infinity, -Infinity]
79
79
  *
80
80
  * @example
81
81
  * // Macro-like token (returned as-is)
82
- * formatStrToFuncArgsArr('$env(PATH)'); // => ["$env(PATH)"]
82
+ * arrFuncArgs('$env(PATH)'); // => ["$env(PATH)"]
83
83
  *
84
84
  * @example
85
85
  * // Escapes inside quotes
86
- * formatStrToFuncArgsArr('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
86
+ * arrFuncArgs('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
87
87
  * // => ['He said: "Hi"', "It's ok", "\\path"]
88
88
  *
89
89
  * @example
90
90
  * // Empty and whitespace inputs
91
- * formatStrToFuncArgsArr(' '); // => []
92
- * formatStrToFuncArgsArr('[]'); // => []
93
- * formatStrToFuncArgsArr('[ ]'); // => []
94
- * formatStrToFuncArgsArr(' [ a , b ] '); // => ["a", "b"]
91
+ * arrFuncArgs(' '); // => []
92
+ * arrFuncArgs('[]'); // => []
93
+ * arrFuncArgs('[ ]'); // => []
94
+ * arrFuncArgs(' [ a , b ] '); // => ["a", "b"]
95
95
  *
96
96
  * @param value - Raw string containing comma-separated arguments.
97
97
  * If `value` is **not** a string, the function returns `[value]` unchanged.
@@ -99,14 +99,14 @@
99
99
  * @returns An array of coerced values (`unknown[]`). Each item is one parsed token.
100
100
  *
101
101
  * @see isStrBool
102
- * @see formatToBool
103
- * @see formatToNum
102
+ * @see boolNormalize
103
+ * @see numNormalize
104
104
  * @see jsonDecode
105
105
  *
106
106
  * @public
107
107
  * @since 2.0.0
108
108
  */
109
- declare function formatStrToFuncArgsArr(value: string): unknown[];
109
+ declare function arrFuncArgs(value: string): unknown[];
110
110
 
111
111
  /**
112
112
  * Splits an input array into smaller subarrays (portions) of a given fixed size.
@@ -145,31 +145,31 @@ declare function formatStrToFuncArgsArr(value: string): unknown[];
145
145
  *
146
146
  * @example
147
147
  * // Split an array into groups of 3
148
- * splitArrToPortions([1, 2, 3, 4, 5, 6, 7], 3);
148
+ * arrSplitPortions([1, 2, 3, 4, 5, 6, 7], 3);
149
149
  * // => [[1, 2, 3], [4, 5, 6], [7]]
150
150
  *
151
151
  * @example
152
152
  * // Portion length larger than array
153
- * splitArrToPortions(['a', 'b'], 5);
153
+ * arrSplitPortions(['a', 'b'], 5);
154
154
  * // => [['a', 'b']]
155
155
  *
156
156
  * @example
157
157
  * // Non-integer or invalid sizes
158
- * splitArrToPortions([1, 2, 3], 0); // => []
159
- * splitArrToPortions([1, 2, 3], -2); // => []
160
- * splitArrToPortions([1, 2, 3], NaN); // => []
158
+ * arrSplitPortions([1, 2, 3], 0); // => []
159
+ * arrSplitPortions([1, 2, 3], -2); // => []
160
+ * arrSplitPortions([1, 2, 3], NaN); // => []
161
161
  *
162
162
  * @example
163
163
  * // Works with readonly arrays
164
164
  * const input = [10, 20, 30, 40] as const;
165
- * const result = splitArrToPortions(input, 2);
165
+ * const result = arrSplitPortions(input, 2);
166
166
  * // result: [[10, 20], [30, 40]]
167
167
  *
168
168
  * @category Array
169
169
  * @public
170
170
  * @since 2.0.0
171
171
  */
172
- declare function splitArrToPortions<T>(arr: readonly T[], portionLength: number): T[][];
172
+ declare function arrSplitPortions<T>(arr: readonly T[], portionLength: number): T[][];
173
173
 
174
174
  /**
175
175
  * Converts any given value into a normalized boolean (`true` / `false`).
@@ -228,31 +228,31 @@ declare function splitArrToPortions<T>(arr: readonly T[], portionLength: number)
228
228
  *
229
229
  * @example
230
230
  * // Native booleans
231
- * formatToBool(true); // => true
232
- * formatToBool(false); // => false
231
+ * boolNormalize(true); // => true
232
+ * boolNormalize(false); // => false
233
233
  *
234
234
  * @example
235
235
  * // Numeric values
236
- * formatToBool(1); // => true
237
- * formatToBool(0); // => false
238
- * formatToBool(-5); // => false
236
+ * boolNormalize(1); // => true
237
+ * boolNormalize(0); // => false
238
+ * boolNormalize(-5); // => false
239
239
  *
240
240
  * @example
241
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
242
+ * boolNormalize('yes'); // => true
243
+ * boolNormalize('No'); // => false
244
+ * boolNormalize('TRUE'); // => true
245
+ * boolNormalize('false'); // => false
246
+ * boolNormalize('on'); // => true
247
+ * boolNormalize('off'); // => false
248
248
  *
249
249
  * @example
250
250
  * // Mixed and invalid inputs
251
- * formatToBool(null); // => false
252
- * formatToBool(undefined); // => false
253
- * formatToBool([]); // => false
254
- * formatToBool({}); // => false
255
- * formatToBool('maybe'); // => false
251
+ * boolNormalize(null); // => false
252
+ * boolNormalize(undefined); // => false
253
+ * boolNormalize([]); // => false
254
+ * boolNormalize({}); // => false
255
+ * boolNormalize('maybe'); // => false
256
256
  *
257
257
  * @see isBool
258
258
  * @see isNumP
@@ -263,7 +263,7 @@ declare function splitArrToPortions<T>(arr: readonly T[], portionLength: number)
263
263
  * @public
264
264
  * @since 2.0.0
265
265
  */
266
- declare function formatToBool(value: unknown): boolean;
266
+ declare function boolNormalize(value: unknown): boolean;
267
267
 
268
268
  /**
269
269
  * Waits asynchronously for the specified amount of time.
@@ -353,12 +353,12 @@ declare function wait(timeout?: number): Promise<void>;
353
353
  *
354
354
  * @remarks
355
355
  * This interface is used by time utility functions such as
356
- * {@link secondsToParts} and {@link partsToSeconds} to represent durations
356
+ * {@link dateSecParts} and {@link datePartsSec} to represent durations
357
357
  * in a normalized structure that is easy to read, format, or serialize.
358
358
  *
359
359
  * Each field is an **integer number** representing the whole count of that unit.
360
360
  * None of the fields are fractional, and they are expected to follow
361
- * these conventional bounds when generated by {@link secondsToParts}:
361
+ * these conventional bounds when generated by {@link dateSecParts}:
362
362
  *
363
363
  * ```
364
364
  * days ≥ 0
@@ -376,8 +376,8 @@ declare function wait(timeout?: number): Promise<void>;
376
376
  * const t: TimeParts = { days: 1, hours: 2, minutes: 30, seconds: 45 };
377
377
  *
378
378
  * // Example 2: Used with utility converters
379
- * const total = partsToSeconds(t); // -> 95445
380
- * const back = secondsToParts(total); // -> same structure again
379
+ * const total = datePartsSec(t); // -> 95445
380
+ * const back = dateSecParts(total); // -> same structure again
381
381
  * ```
382
382
  *
383
383
  * @example
@@ -393,8 +393,8 @@ declare function wait(timeout?: number): Promise<void>;
393
393
  * @property minutes - Whole number of minutes (0–59 typical).
394
394
  * @property seconds - Whole number of seconds (0–59 typical).
395
395
  *
396
- * @see {@link secondsToParts} — converts total seconds into this structure.
397
- * @see {@link partsToSeconds} — converts this structure back into total seconds.
396
+ * @see {@link dateSecParts} — converts total seconds into this structure.
397
+ * @see {@link datePartsSec} — converts this structure back into total seconds.
398
398
  *
399
399
  * @public
400
400
  * @category Date & Time
@@ -441,22 +441,22 @@ interface TimeParts {
441
441
  * ```ts
442
442
  * // Example 1: Floor to the nearest 15-minute mark
443
443
  * const d = new Date('2025-10-18T10:43:27');
444
- * floorDateToMinutes(15, d);
444
+ * dateFloorMin(15, d);
445
445
  * // -> 2025-10-18T10:30:00.000Z
446
446
  * ```
447
447
  *
448
448
  * @example
449
449
  * ```ts
450
450
  * // Example 2: Using default date (current time)
451
- * const nowFloored = floorDateToMinutes(10);
451
+ * const nowFloored = dateFloorMin(10);
452
452
  * // -> e.g. 2025-10-18T09:20:00.000Z
453
453
  * ```
454
454
  *
455
455
  * @example
456
456
  * ```ts
457
457
  * // Example 3: Clamp behavior
458
- * floorDateToMinutes(-5, new Date()); // treated as 1 minute
459
- * floorDateToMinutes(999, new Date()); // treated as 60 minutes
458
+ * dateFloorMin(-5, new Date()); // treated as 1 minute
459
+ * dateFloorMin(999, new Date()); // treated as 60 minutes
460
460
  * ```
461
461
  *
462
462
  * @throws Never throws — invalid step values are automatically normalized.
@@ -468,7 +468,7 @@ interface TimeParts {
468
468
  * @category Date & Time
469
469
  * @since 2.0.0
470
470
  */
471
- declare function floorDateToMinutes(everyMinutes?: number, date?: Date): Date;
471
+ declare function dateFloorMin(everyMinutes?: number, date?: Date): Date;
472
472
 
473
473
  /**
474
474
  * Formats a {@link Date} object into a human-readable timestamp string
@@ -502,14 +502,14 @@ declare function floorDateToMinutes(everyMinutes?: number, date?: Date): Date;
502
502
  * ```ts
503
503
  * // Example 1: Specific date
504
504
  * const d = new Date('2025-10-18T10:43:27Z');
505
- * formatDateToString(d);
505
+ * dateStr(d);
506
506
  * // -> "2025-10-18 10:43:27"
507
507
  * ```
508
508
  *
509
509
  * @example
510
510
  * ```ts
511
511
  * // Example 2: Default (current) date
512
- * formatDateToString();
512
+ * dateStr();
513
513
  * // -> e.g. "2025-10-18 12:07:55"
514
514
  * ```
515
515
  *
@@ -517,7 +517,7 @@ declare function floorDateToMinutes(everyMinutes?: number, date?: Date): Date;
517
517
  * ```ts
518
518
  * // Example 3: Padding behavior
519
519
  * const d = new Date('2025-03-07T09:04:02');
520
- * formatDateToString(d);
520
+ * dateStr(d);
521
521
  * // -> "2025-03-07 09:04:02"
522
522
  * ```
523
523
  *
@@ -530,7 +530,7 @@ declare function floorDateToMinutes(everyMinutes?: number, date?: Date): Date;
530
530
  * @category Date & Time
531
531
  * @since 2.0.0
532
532
  */
533
- declare function formatDateToString(date?: Date): string;
533
+ declare function dateStr(date?: Date): string;
534
534
 
535
535
  /**
536
536
  * Converts a partial {@link TimeParts} structure (days, hours, minutes, seconds)
@@ -564,38 +564,33 @@ declare function formatDateToString(date?: Date): string;
564
564
  * @example
565
565
  * ```ts
566
566
  * // Example 1: Simple conversion
567
- * partsToSeconds({ hours: 1, minutes: 30 }); // -> 5400
567
+ * datePartsSec({ hours: 1, minutes: 30 }); // -> 5400
568
568
  *
569
569
  * // Example 2: Full time span
570
- * partsToSeconds({ days: 2, hours: 3, minutes: 5, seconds: 10 });
570
+ * datePartsSec({ days: 2, hours: 3, minutes: 5, seconds: 10 });
571
571
  * // -> 183910
572
572
  *
573
573
  * // Example 3: Partial / missing fields
574
- * partsToSeconds({}); // -> 0
575
- * partsToSeconds({ minutes: 5 }); // -> 300
574
+ * datePartsSec({}); // -> 0
575
+ * datePartsSec({ minutes: 5 }); // -> 300
576
576
  * ```
577
577
  *
578
578
  * @throws Never throws.
579
579
  *
580
- * @see {@link secondsToParts} — the inverse operation that expands seconds back into components.
580
+ * @see {@link dateSecParts} — the inverse operation that expands seconds back into components.
581
581
  *
582
582
  * @public
583
583
  * @category Date & Time
584
584
  * @since 2.0.0
585
585
  */
586
- declare function partsToSeconds(parts: {
587
- days?: number;
588
- hours?: number;
589
- minutes?: number;
590
- seconds?: number;
591
- }): number;
586
+ declare function datePartsSec(parts: TimeParts): number;
592
587
 
593
588
  /**
594
589
  * Decomposes a total number of seconds into discrete time components:
595
590
  * **days**, **hours**, **minutes**, and **seconds**.
596
591
  *
597
592
  * @remarks
598
- * This is the inverse operation of {@link partsToSeconds}.
593
+ * This is the inverse operation of {@link datePartsSec}.
599
594
  * It converts a flat duration (in seconds) into a more human-readable structure
600
595
  * suitable for display, logging, or formatting.
601
596
  *
@@ -627,130 +622,35 @@ declare function partsToSeconds(parts: {
627
622
  * @example
628
623
  * ```ts
629
624
  * // Example 1: Basic conversion
630
- * secondsToParts(3661);
625
+ * dateSecParts(3661);
631
626
  * // -> { days: 0, hours: 1, minutes: 1, seconds: 1 }
632
627
  * ```
633
628
  *
634
629
  * @example
635
630
  * ```ts
636
631
  * // Example 2: Multi-day value
637
- * secondsToParts(90061);
632
+ * dateSecParts(90061);
638
633
  * // -> { days: 1, hours: 1, minutes: 1, seconds: 1 }
639
634
  * ```
640
635
  *
641
636
  * @example
642
637
  * ```ts
643
638
  * // Example 3: Invalid input
644
- * secondsToParts(-10); // throws Error("Invalid total seconds")
645
- * secondsToParts(NaN); // throws Error("Invalid total seconds")
639
+ * dateSecParts(-10); // throws Error("Invalid total seconds")
640
+ * dateSecParts(NaN); // throws Error("Invalid total seconds")
646
641
  * ```
647
642
  *
648
643
  * @throws {Error}
649
644
  * Thrown when `total` is not a finite, non-negative number.
650
645
  *
651
- * @see {@link partsToSeconds} — the complementary function that aggregates components into seconds.
646
+ * @see {@link datePartsSec} — the complementary function that aggregates components into seconds.
652
647
  * @see {@link TimeParts} — the return type describing the breakdown of time.
653
648
  *
654
649
  * @public
655
650
  * @category Date & Time
656
651
  * @since 2.0.0
657
652
  */
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;
653
+ declare function dateSecParts(total: number): TimeParts;
754
654
 
755
655
  /**
756
656
  * Converts a dotted-decimal IPv4 address string (e.g. `"192.168.0.1"`)
@@ -783,20 +683,20 @@ declare function cidrToRange(cidr: string): [string, string] | null;
783
683
  * @example
784
684
  * ```ts
785
685
  * // Example 1: Simple conversion
786
- * ipAddrToNum("192.168.0.1");
686
+ * ipStrNum("192.168.0.1");
787
687
  * // -> 3232235521
788
688
  *
789
689
  * // Example 2: Edge values
790
- * ipAddrToNum("0.0.0.0"); // -> 0
791
- * ipAddrToNum("255.255.255.255"); // -> 4294967295
690
+ * ipStrNum("0.0.0.0"); // -> 0
691
+ * ipStrNum("255.255.255.255"); // -> 4294967295
792
692
  * ```
793
693
  *
794
694
  * @example
795
695
  * ```ts
796
696
  * // 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")
697
+ * ipStrNum("192.168.1"); // throws Error("Invalid IPv4 address")
698
+ * ipStrNum("256.0.0.1"); // throws Error("Invalid IPv4 address")
699
+ * ipStrNum("abc.def.ghi.jkl"); // throws Error("Invalid IPv4 address")
800
700
  * ```
801
701
  *
802
702
  * @throws {Error}
@@ -811,14 +711,14 @@ declare function cidrToRange(cidr: string): [string, string] | null;
811
711
  * @category Network & IP
812
712
  * @since 2.0.0
813
713
  */
814
- declare function ipAddrToNum(ip: string): number;
714
+ declare function ipStrNum(ip: string): number;
815
715
 
816
716
  /**
817
717
  * Converts a 32-bit unsigned integer (numeric IPv4 representation)
818
718
  * back into its dotted-decimal string form (e.g. `"192.168.0.1"`).
819
719
  *
820
720
  * @remarks
821
- * This is the inverse of {@link ipAddrToNum}.
721
+ * This is the inverse of {@link ipStrNum}.
822
722
  * It interprets the input number as a **big-endian (network-byte-order)**
823
723
  * IPv4 value, extracting each of the four octets and joining them into
824
724
  * the standard dotted-quad notation.
@@ -832,7 +732,7 @@ declare function ipAddrToNum(ip: string): number;
832
732
  * - Internally uses {@link DataView} to ensure consistent big-endian behavior
833
733
  * across all platforms.
834
734
  * - The output format is always normalized (no leading zeros, no spaces).
835
- * - For the forward direction (string → number), see {@link ipAddrToNum}.
735
+ * - For the forward direction (string → number), see {@link ipStrNum}.
836
736
  *
837
737
  * @param num - The 32-bit unsigned integer representing an IPv4 address.
838
738
  *
@@ -842,195 +742,32 @@ declare function ipAddrToNum(ip: string): number;
842
742
  * @example
843
743
  * ```ts
844
744
  * // Example 1: Basic conversion
845
- * numToIpAddr(3232235521);
745
+ * ipNumStr(3232235521);
846
746
  * // -> "192.168.0.1"
847
747
  *
848
748
  * // Example 2: Edge values
849
- * numToIpAddr(0); // -> "0.0.0.0"
850
- * numToIpAddr(4294967295); // -> "255.255.255.255"
749
+ * ipNumStr(0); // -> "0.0.0.0"
750
+ * ipNumStr(4294967295); // -> "255.255.255.255"
851
751
  * ```
852
752
  *
853
753
  * @example
854
754
  * ```ts
855
755
  * // Example 3: Invalid inputs
856
- * numToIpAddr(NaN); // -> ""
857
- * numToIpAddr(Infinity); // -> ""
858
- * numToIpAddr(-5); // -> ""
756
+ * ipNumStr(NaN); // -> ""
757
+ * ipNumStr(Infinity); // -> ""
758
+ * ipNumStr(-5); // -> ""
859
759
  * ```
860
760
  *
861
761
  * @throws Never throws; invalid inputs simply return an empty string.
862
762
  *
863
- * @see {@link ipAddrToNum} — converts dotted IPv4 strings to numeric form.
763
+ * @see {@link ipStrNum} — converts dotted IPv4 strings to numeric form.
864
764
  * @see {@link parseIPv4} — alternative parser using bitwise arithmetic.
865
765
  *
866
766
  * @public
867
767
  * @category Network & IP
868
768
  * @since 2.0.0
869
769
  */
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;
770
+ declare function ipNumStr(num: number): string;
1034
771
 
1035
772
  /**
1036
773
  * Configuration options that define password validation rules.
@@ -2852,7 +2589,7 @@ type JSONLike = null | boolean | number | string | JSONLike[] | {
2852
2589
  * @remarks
2853
2590
  * The parsing order is:
2854
2591
  *
2855
- * 1. Try JSON via {@link tryParseJSON}. If it works, return the parsed value.
2592
+ * 1. Try JSON via {@link jsonParse}. If it works, return the parsed value.
2856
2593
  * 2. If not JSON, check if the string is quoted with `'`, `"` or `` ` ``.
2857
2594
  * If quoted, return the **unquoted** inner text.
2858
2595
  * 3. If not quoted:
@@ -2869,15 +2606,15 @@ type JSONLike = null | boolean | number | string | JSONLike[] | {
2869
2606
  *
2870
2607
  * @example
2871
2608
  * ```ts
2872
- * parseStringLike('{"a":1}', false); // -> { a: 1 }
2873
- * parseStringLike('"hello"', false); // -> "hello"
2874
- * parseStringLike('hello', false); // -> null
2875
- * parseStringLike('hello', true); // -> "hello"
2609
+ * jsonStrLike('{"a":1}', false); // -> { a: 1 }
2610
+ * jsonStrLike('"hello"', false); // -> "hello"
2611
+ * jsonStrLike('hello', false); // -> null
2612
+ * jsonStrLike('hello', true); // -> "hello"
2876
2613
  * ```
2877
2614
  *
2878
2615
  * @internal
2879
2616
  */
2880
- declare function parseStringLike(s: string, allowString: boolean): JSONLike | null;
2617
+ declare function jsonStrLike(s: string, allowString: boolean): JSONLike | null;
2881
2618
 
2882
2619
  /**
2883
2620
  * Attempts to parse a string using native {@link JSON.parse}.
@@ -2892,13 +2629,13 @@ declare function parseStringLike(s: string, allowString: boolean): JSONLike | nu
2892
2629
  *
2893
2630
  * @example
2894
2631
  * ```ts
2895
- * tryParseJSON('{"a":1}'); // { ok: true, value: { a: 1 } }
2896
- * tryParseJSON('not json'); // { ok: false }
2632
+ * jsonParse('{"a":1}'); // { ok: true, value: { a: 1 } }
2633
+ * jsonParse('not json'); // { ok: false }
2897
2634
  * ```
2898
2635
  *
2899
2636
  * @internal
2900
2637
  */
2901
- declare function tryParseJSON(str: string): {
2638
+ declare function jsonParse(str: string): {
2902
2639
  ok: true;
2903
2640
  value: JSONLike;
2904
2641
  } | {
@@ -2914,10 +2651,10 @@ declare function tryParseJSON(str: string): {
2914
2651
  *
2915
2652
  * - **Primitive passthrough**: `null`, numbers, and booleans are returned as-is.
2916
2653
  * - **Arrays/Objects (filled)**: for each string element/property, we attempt to decode
2917
- * it via {@link parseStringLike} (JSON → unquoted string → raw string if `allowString`).
2654
+ * it via {@link jsonStrLike} (JSON → unquoted string → raw string if `allowString`).
2918
2655
  * Non-string items are passed through unchanged (cast to `JSONLike`).
2919
2656
  * - **Arrays/Objects (empty)**: returned as-is (they’re valid JSON).
2920
- * - **Standalone strings**: decoded via {@link parseStringLike}.
2657
+ * - **Standalone strings**: decoded via {@link jsonStrLike}.
2921
2658
  * - **Other values**: return `null`.
2922
2659
  *
2923
2660
  * The function is **non-throwing**; any JSON parse errors are swallowed internally
@@ -3026,381 +2763,6 @@ declare function jsonDecode<T = JSONLike>(value: unknown, allowString?: boolean)
3026
2763
  */
3027
2764
  declare function jsonEncode(value: unknown): string;
3028
2765
 
3029
- /**
3030
- * Represents a **fixed-precision decimal number** using exact integer arithmetic.
3031
- *
3032
- * @remarks
3033
- * JavaScript’s native `number` type uses 64-bit IEEE-754 floating-point representation,
3034
- * which introduces rounding errors for many decimal values
3035
- * (for example, `0.1 + 0.2 !== 0.3`).
3036
- *
3037
- * `FixedDecimal` provides a lossless, predictable alternative by separating
3038
- * the number into three explicit components:
3039
- *
3040
- * - **`sign`** → numeric sign (`1` for positive values, `-1` for negative ones)
3041
- * - **`digitsInteger`** → all digits of the number stored as a `BigInt`
3042
- * (the decimal point is removed)
3043
- * - **`scale`** → number of digits that were originally after the decimal point
3044
- *
3045
- * Together, these three parts allow precise decimal math, rounding,
3046
- * and string/number conversions without losing accuracy.
3047
- *
3048
- * ---
3049
- * **Conceptual example**
3050
- *
3051
- * The decimal value:
3052
- * ```
3053
- * -123.456
3054
- * ```
3055
- * would be represented as:
3056
- * ```ts
3057
- * {
3058
- * sign: -1,
3059
- * digitsInteger: 123456n,
3060
- * scale: 3
3061
- * }
3062
- * ```
3063
- *
3064
- * which mathematically equals:
3065
- * ```
3066
- * sign × (digitsInteger / 10^scale)
3067
- * = -1 × (123456 / 10^3)
3068
- * = -123.456
3069
- * ```
3070
- *
3071
- * ---
3072
- * **Usage**
3073
- *
3074
- * Instances of `FixedDecimal` are typically produced and consumed by utility functions:
3075
- * - {@link parseToFixedDecimal} — converts arbitrary input (`string`/`number`/`bigint`) to `FixedDecimal`
3076
- * - {@link roundFixedDecimal} — rounds to a target number of fractional digits
3077
- * - {@link fixedDecimalToStr} — converts back to a human-readable string
3078
- * - {@link fixedDecimalToNum} — converts to a JavaScript `number` (with possible precision loss)
3079
- *
3080
- * ---
3081
- * @property sign - Numeric sign of the value.
3082
- * `1` for positive and zero values, `-1` for negative ones.
3083
- *
3084
- * @property digitsInteger - A `BigInt` holding all digits of the number
3085
- * without any decimal separator.
3086
- * Example: `"123.45"` → `digitsInteger = 12345n`.
3087
- *
3088
- * @property scale - Number of digits that appear after the decimal point
3089
- * in the original value.
3090
- * Example: `"123.45"` → `scale = 2`.
3091
- *
3092
- * ---
3093
- * @example
3094
- * // Example: 0.034 represented as FixedDecimal
3095
- * const fd: FixedDecimal = {
3096
- * sign: 1,
3097
- * digitsInteger: 34n,
3098
- * scale: 3
3099
- * };
3100
- * // mathematically: 1 × (34 / 10³) = 0.034
3101
- *
3102
- * @example
3103
- * // Example: -987000.00 → same magnitude, different scale
3104
- * const fd2: FixedDecimal = {
3105
- * sign: -1,
3106
- * digitsInteger: 98700000n,
3107
- * scale: 2
3108
- * };
3109
- * // -987000.00
3110
- *
3111
- * @example
3112
- * // Zero value representation
3113
- * const zero: FixedDecimal = {
3114
- * sign: 1,
3115
- * digitsInteger: 0n,
3116
- * scale: 0
3117
- * };
3118
- *
3119
- * @see parseToFixedDecimal
3120
- * @see roundFixedDecimal
3121
- * @see fixedDecimalToStr
3122
- * @see fixedDecimalToNum
3123
- *
3124
- * @category Types
3125
- * @since 2.0.0
3126
- * @public
3127
- */
3128
- interface FixedDecimal {
3129
- /**
3130
- * The numeric sign of the value:
3131
- * `1` for positive or zero, `-1` for negative.
3132
- */
3133
- sign: 1 | -1;
3134
- /**
3135
- * All digits of the number stored as a `BigInt`,
3136
- * with the decimal point removed.
3137
- */
3138
- digitsInteger: bigint;
3139
- /**
3140
- * The number of digits that originally appeared
3141
- * after the decimal point.
3142
- */
3143
- scale: number;
3144
- }
3145
-
3146
- /**
3147
- * Adjusts the **scale** (i.e., number of fractional digits) of a {@link FixedDecimal}
3148
- * by a given offset without altering its numeric meaning.
3149
- *
3150
- * @remarks
3151
- * A `FixedDecimal` represents a decimal number as:
3152
- * ```ts
3153
- * { sign: 1 | -1, digitsInteger: bigint, scale: number }
3154
- * ```
3155
- * where `digitsInteger × 10^(-scale)` yields the real value.
3156
- *
3157
- * This helper changes the `scale` while keeping the numerical value consistent.
3158
- * When `scaleDelta > 0`, the function *increases* the scale (adds more fractional
3159
- * digits of precision) **without changing** `digitsInteger`.
3160
- * When `scaleDelta < 0`, it *reduces* the scale by multiplying `digitsInteger`
3161
- * to preserve the same actual numeric value.
3162
- *
3163
- * O(1) time and space, except for the BigInt multiplication when `scaleDelta < 0`.
3164
- *
3165
- * @param value - The {@link FixedDecimal} to adjust.
3166
- * Should contain:
3167
- * - `sign`: either `1` (positive) or `-1` (negative),
3168
- * - `digitsInteger`: the integer form of all digits without a decimal point,
3169
- * - `scale`: the number of fractional digits currently represented.
3170
- *
3171
- * @param scaleDelta - The number of fractional places to add or remove.
3172
- * Positive values mean **increase precision** (more digits after the decimal point);
3173
- * negative values mean **reduce precision**, scaling the integer part accordingly.
3174
- *
3175
- * @returns A new {@link FixedDecimal} with the adjusted `scale` and appropriately
3176
- * modified `digitsInteger` if needed.
3177
- *
3178
- * @throws {RangeError} If the operation would cause an invalid scale
3179
- * (e.g., non-integer `scaleDelta`), though `Math.trunc` is used to normalize inputs.
3180
- *
3181
- * @example
3182
- * ```ts
3183
- * const num: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3184
- * // Represents 123.45
3185
- *
3186
- * // Increase scale by +2 → same numeric value but more fractional digits
3187
- * const up = changeFixedDecimalScale(num, +2);
3188
- * // up = { sign: 1, digitsInteger: 12345n, scale: 4 } → 1.2345 × 10^2 = 123.45
3189
- *
3190
- * // Decrease scale by -2 → multiply digitsInteger to preserve value
3191
- * const down = changeFixedDecimalScale(num, -2);
3192
- * // down = { sign: 1, digitsInteger: 1234500n, scale: 0 } → 1234500 × 10^0 = 123.45
3193
- * ```
3194
- *
3195
- * @example
3196
- * ```ts
3197
- * // No change when delta = 0
3198
- * const same = changeFixedDecimalScale(num, 0);
3199
- * // same === { sign: 1, digitsInteger: 12345n, scale: 2 }
3200
- * ```
3201
- *
3202
- * @since 2.0.0
3203
- */
3204
- declare function changeFixedDecimalScale(value: FixedDecimal, scaleDelta: number): FixedDecimal;
3205
-
3206
- /**
3207
- * Converts a number expressed in normalized exponential/scientific notation
3208
- * (e.g., `"1.23e+5"`, `"4e-7"`, `"0009.500e2"`) into its **sign**, **integer**,
3209
- * and **fractional** parts as plain decimal digit strings — **without** any
3210
- * decimal point or leading `+`/`-` characters.
3211
- *
3212
- * @remarks
3213
- * - This function does **not** perform numeric arithmetic; instead it does a
3214
- * textual normalization that preserves all significant digits exactly.
3215
- * - It accepts the `sign` separately so that callers can pre-parse signs from
3216
- * inputs like `"-1.23e3"` and pass `sign = -1` with `exponentialString = "1.23e3"`.
3217
- * (If you already have a positive string, pass `sign = 1`.)
3218
- * - The function normalizes the coefficient and exponent first, then uses a
3219
- * single regex match to validate the shape:
3220
- * - Coefficient: `([0-9]+)(?:\.([0-9]*))?`
3221
- * - Exponent: `e([+\-]?[0-9]+)`
3222
- * - Trailing zeros are added to the **integer** side for positive net exponents,
3223
- * while leading zeros are added to the **fractional** side for negative net exponents.
3224
- * - All returned parts (`integerPart`, `fractionalPart`) contain only ASCII digits.
3225
- * The decimal point is **not** returned; you can re-insert it if needed by
3226
- * placing it between `integerPart` and `fractionalPart`.
3227
- *
3228
- * Time O(n) and space O(n), where n is the number of digits in the coefficient,
3229
- * due to string concatenation and slicing.
3230
- *
3231
- * @param sign - The pre-parsed sign of the number: `1` for positive, `-1` for negative.
3232
- * @param exponentialString - A string in exponential notation.
3233
- * Examples: `"1e3"`, `"1.23e+5"`, `"4.560e-2"`, `"0009.500e2"`.
3234
- * The function is case-insensitive for the `'e'` and tolerates leading zeros in the coefficient.
3235
- *
3236
- * @returns An object with three properties:
3237
- * - `sign`: Echo of the input sign (`1` | `-1`).
3238
- * - `integerPart`: All digits to the left of the decimal point after expansion.
3239
- * - `fractionalPart`: All digits to the right of the decimal point after expansion.
3240
- *
3241
- * @throws {Error} If `exponentialString` cannot be parsed as scientific notation.
3242
- *
3243
- * @example
3244
- * ```ts
3245
- * // 1.23 × 10^5 = 123000
3246
- * convertExponentialToParts(1, "1.23e5");
3247
- * // => { sign: 1, integerPart: "123000", fractionalPart: "" }
3248
- * ```
3249
- *
3250
- * @example
3251
- * ```ts
3252
- * // 4.5 × 10^-3 = 0.0045
3253
- * convertExponentialToParts(1, "4.5e-3");
3254
- * // => { sign: 1, integerPart: "0", fractionalPart: "0045" }
3255
- * ```
3256
- *
3257
- * @example
3258
- * ```ts
3259
- * // -7.00e+0 = -7
3260
- * convertExponentialToParts(-1, "7.00e0");
3261
- * // => { sign: -1, integerPart: "7", fractionalPart: "" }
3262
- * ```
3263
- *
3264
- * @example
3265
- * ```ts
3266
- * // Leading zeros in coefficient are handled; fractional length adjusts exponent
3267
- * convertExponentialToParts(1, "0009.500e2"); // 9.500 × 10^2 = 950
3268
- * // => { sign: 1, integerPart: "950", fractionalPart: "" }
3269
- * ```
3270
- *
3271
- * @example
3272
- * ```ts
3273
- * // You can reconstruct a normalized decimal string yourself:
3274
- * const { sign, integerPart, fractionalPart } = convertExponentialToParts(-1, "1.234e-2");
3275
- * const signChar = sign < 0 ? "-" : "";
3276
- * const plain = fractionalPart ? `${integerPart}.${fractionalPart}` : integerPart;
3277
- * // plain == "0.01234"
3278
- * const result = signChar + plain; // "-0.01234"
3279
- * ```
3280
- *
3281
- * @see isNumPZ — utility used here to detect non-negative integers (exponent ≥ 0).
3282
- *
3283
- * @since 2.0.0
3284
- */
3285
- declare function convertExponentialToParts(sign: 1 | -1, exponentialString: string): {
3286
- sign: 1 | -1;
3287
- integerPart: string;
3288
- fractionalPart: string;
3289
- };
3290
-
3291
- /**
3292
- * Converts a {@link FixedDecimal} — an exact decimal representation —
3293
- * into a native JavaScript `number` (IEEE 754 double precision).
3294
- *
3295
- * @remarks
3296
- * This function is a **lossy** conversion when `value` contains
3297
- * more precision than JavaScript’s floating-point format can represent.
3298
- * It internally calls {@link fixedDecimalToStr} to produce a normalized
3299
- * string such as `"-123.4567"` and then passes it to the built-in
3300
- * `Number()` constructor.
3301
- *
3302
- * O(n) relative to the number of digits in `digitsInteger`
3303
- * (due to string creation in {@link fixedDecimalToStr}).
3304
- *
3305
- * @param value - The {@link FixedDecimal} instance to convert.
3306
- * Must contain:
3307
- * - `sign`: either `1` or `-1`;
3308
- * - `digitsInteger`: a `bigint` representing all digits without any decimal point;
3309
- * - `scale`: how many digits belong after the decimal point.
3310
- *
3311
- * @returns The approximate numeric value as a JavaScript `number`.
3312
- * If the string form is too large or too precise, the result may be
3313
- * rounded or become `Infinity`.
3314
- *
3315
- * @example
3316
- * ```ts
3317
- * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3318
- * // Represents exactly 123.45
3319
- * const num = fixedDecimalToNum(fd); // 123.45 (Number)
3320
- * ```
3321
- *
3322
- * @example
3323
- * ```ts
3324
- * // Handles negative numbers as well
3325
- * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };
3326
- * const n = fixedDecimalToNum(neg); // -0.987
3327
- * ```
3328
- *
3329
- * @example
3330
- * ```ts
3331
- * // Extreme precision may lose digits beyond ~15–17 significant figures
3332
- * const big: FixedDecimal = { sign: 1, digitsInteger: 12345678901234567890n, scale: 10 };
3333
- * const approx = fixedDecimalToNum(big);
3334
- * console.log(approx); // ~1234567890.1234567 (rounded)
3335
- * ```
3336
- *
3337
- * @see fixedDecimalToStr — for the exact string representation
3338
- * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number#precision JavaScript number precision
3339
- *
3340
- * @since 2.0.0
3341
- */
3342
- declare function fixedDecimalToNum(value: FixedDecimal): number;
3343
-
3344
- /**
3345
- * Converts a {@link FixedDecimal} — an exact, integer-based decimal structure —
3346
- * into its canonical string representation (e.g. `"-123.456"`).
3347
- *
3348
- * @remarks
3349
- * This function is **exact and reversible**: no precision loss occurs because it
3350
- * operates on the raw digit string (`digitsInteger`) and inserts the decimal point
3351
- * purely by string manipulation.
3352
- *
3353
- * The algorithm:
3354
- * 1. Converts the `digitsInteger` `BigInt` to a string of digits.
3355
- * 2. If `scale` is `0`, returns the signed integer directly.
3356
- * 3. If `scale` is positive:
3357
- * - Pads with leading zeros when the number of digits is smaller than `scale`.
3358
- * - Otherwise, splits at the appropriate boundary between integer and fractional parts.
3359
- *
3360
- * O(n) where `n` is the number of digits in `digitsInteger.toString()`.
3361
- *
3362
- * @param value - The {@link FixedDecimal} object:
3363
- * - `sign`: `1` for positive or `-1` for negative numbers.
3364
- * - `digitsInteger`: All digits as a `BigInt` without a decimal point.
3365
- * - `scale`: The number of digits after the decimal point.
3366
- *
3367
- * @returns A string representation of the number, including a `-` sign if negative.
3368
- * If the number is fractional, a single `.` separates integer and fractional parts.
3369
- *
3370
- * @example
3371
- * ```ts
3372
- * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };
3373
- * fixedDecimalToStr(fd); // "123.45"
3374
- * ```
3375
- *
3376
- * @example
3377
- * ```ts
3378
- * // Negative number
3379
- * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };
3380
- * fixedDecimalToStr(neg); // "-0.987"
3381
- * ```
3382
- *
3383
- * @example
3384
- * ```ts
3385
- * // Small fractional with fewer digits than scale
3386
- * const tiny: FixedDecimal = { sign: 1, digitsInteger: 12n, scale: 5 };
3387
- * fixedDecimalToStr(tiny); // "0.00012"
3388
- * ```
3389
- *
3390
- * @example
3391
- * ```ts
3392
- * // Whole number (scale = 0)
3393
- * const whole: FixedDecimal = { sign: 1, digitsInteger: 42n, scale: 0 };
3394
- * fixedDecimalToStr(whole); // "42"
3395
- * ```
3396
- *
3397
- * @see changeFixedDecimalScale — for adjusting the scale value safely
3398
- * @see fixedDecimalToNum — for converting to a JavaScript number
3399
- *
3400
- * @since 2.0.0
3401
- */
3402
- declare function fixedDecimalToStr(value: FixedDecimal): string;
3403
-
3404
2766
  /**
3405
2767
  * Converts an arbitrary numeric input to a JavaScript `number`, optionally rounding
3406
2768
  * it to a fixed number of fractional digits using **half-up** rounding.
@@ -3442,23 +2804,23 @@ declare function fixedDecimalToStr(value: FixedDecimal): string;
3442
2804
  *
3443
2805
  * @example
3444
2806
  * // No rounding (default `round = 1` → passthrough)
3445
- * formatToNum("123.456"); // => 123.456
3446
- * formatToNum(0.034); // => 0.034
2807
+ * numNormalize("123.456"); // => 123.456
2808
+ * numNormalize(0.034); // => 0.034
3447
2809
  *
3448
2810
  * @example
3449
2811
  * // Round to 2 fractional digits (half-up)
3450
- * formatToNum("123.456", 2); // => 123.46 (because .456 → .46)
3451
- * formatToNum("-1.235", 2); // => -1.24 (half-up away from zero)
2812
+ * numNormalize("123.456", 2); // => 123.46 (because .456 → .46)
2813
+ * numNormalize("-1.235", 2); // => -1.24 (half-up away from zero)
3452
2814
  *
3453
2815
  * @example
3454
2816
  * // Large values: parsed and rounded in fixed precision, then converted to number
3455
- * formatToNum("234893249238948.000003432", 6); // precise rounding in fixed space,
2817
+ * numNormalize("234893249238948.000003432", 6); // precise rounding in fixed space,
3456
2818
  * // final result as JS number
3457
2819
  *
3458
2820
  * @example
3459
2821
  * // Explicit passthrough (any `round <= 1` behaves the same)
3460
- * formatToNum("1000.555", 1); // => 1000.555 (no rounding step invoked)
3461
- * formatToNum("1000.555", 0); // => 1000.555 (still no rounding)
2822
+ * numNormalize("1000.555", 1); // => 1000.555 (no rounding step invoked)
2823
+ * numNormalize("1000.555", 0); // => 1000.555 (still no rounding)
3462
2824
  *
3463
2825
  * @see parseToFixedDecimal
3464
2826
  * @see fixedDecimalToNum
@@ -3468,278 +2830,7 @@ declare function fixedDecimalToStr(value: FixedDecimal): string;
3468
2830
  * @since 2.0.0
3469
2831
  * @public
3470
2832
  */
3471
- declare function formatToNum(value: unknown, round?: number, throwError?: boolean): number;
3472
-
3473
- /**
3474
- * Normalizes an arbitrary numeric input into sign, integer, and fractional string parts
3475
- * without losing precision, preparing it for exact fixed-decimal processing.
3476
- *
3477
- * @remarks
3478
- * This utility accepts `bigint`, `number`, and `string` inputs and returns a tuple-like
3479
- * object with three fields:
3480
- *
3481
- * - `sign`: `1` for non-negative values, `-1` for negative values.
3482
- * - `integerPart`: the digits before the decimal point as a string (no sign, no separators).
3483
- * - `fractionalPart`: the digits after the decimal point as a string (no sign, no separators).
3484
- *
3485
- * For JavaScript `number`s, the function first checks finiteness and then converts the
3486
- * absolute value to an exponential string (via `toExponential(30)`) to avoid
3487
- * floating-point artifacts when extracting digits. It delegates parsing of that exponential
3488
- * form to {@link convertExponentialToParts}.
3489
- *
3490
- * For `string`s, the function:
3491
- * - Trims whitespace and replaces a comma `,` decimal separator with a dot `.`.
3492
- * - Parses and removes a leading `+`/`-` sign (if present).
3493
- * - Validates the remaining characters with a permissive numeric pattern that allows:
3494
- * - optional integer digits,
3495
- * - an optional decimal point with digits,
3496
- * - an optional scientific exponent (`e` or `E` with optional `+`/`-` and digits).
3497
- * - If an exponent is present, it delegates to {@link convertExponentialToParts};
3498
- * otherwise it splits on the decimal point.
3499
- *
3500
- * **Important:** This function does not strip leading zeros in `integerPart` or trailing
3501
- * zeros in `fractionalPart`. If you need canonicalized output (e.g., remove leading/trailing
3502
- * zeros), do that in a later step (e.g., when building your fixed-decimal representation).
3503
- *
3504
- * @param input - The numeric input to normalize. Supported types:
3505
- * - `bigint` (e.g., `123n`, `-9007199254740993n`)
3506
- * - `number` (finite only; `NaN`, `Infinity`, `-Infinity` will throw)
3507
- * - `string` (e.g., `"42"`, `"-0.034"`, `"1.2e-5"`, with optional leading sign, optional
3508
- * decimal part, optional exponent; commas are allowed as decimal separators and are
3509
- * converted to dots)
3510
- *
3511
- * @returns An object with the normalized components:
3512
- * ```ts
3513
- * {
3514
- * sign: 1 | -1;
3515
- * integerPart: string;
3516
- * fractionalPart: string;
3517
- * }
3518
- * ```
3519
- * The `integerPart` and `fractionalPart` contain only ASCII digits (`0`–`9`) and
3520
- * **never** include sign or exponent markers.
3521
- *
3522
- * @throws {Error}
3523
- * - If `input` is a `number` but not finite (`NaN`, `Infinity`, `-Infinity`).
3524
- * - If `input` is a `string` that is empty after trimming/replacement.
3525
- * - If `input` is a `string` that fails the numeric validation regex.
3526
- * - If `input` is of an unsupported type (not `bigint`, `number`, or `string`).
3527
- * - Any errors propagated from {@link convertExponentialToParts} when parsing exponential forms.
3528
- *
3529
- * @example
3530
- * // bigint input → fractional part is empty
3531
- * normalizeToDecimalComponents(123n);
3532
- * // => { sign: 1, integerPart: "123", fractionalPart: "" }
3533
- *
3534
- * @example
3535
- * // negative bigint
3536
- * normalizeToDecimalComponents(-987654321n);
3537
- * // => { sign: -1, integerPart: "987654321", fractionalPart: "" }
3538
- *
3539
- * @example
3540
- * // finite number input; uses exponential internally to avoid FP artifacts
3541
- * normalizeToDecimalComponents(0.0000034);
3542
- * // => { sign: 1, integerPart: "0", fractionalPart: "0000034" } // exact digits
3543
- *
3544
- * @example
3545
- * // string with decimal comma and explicit sign
3546
- * normalizeToDecimalComponents("+1,250");
3547
- * // => { sign: 1, integerPart: "1", fractionalPart: "250" }
3548
- *
3549
- * @example
3550
- * // scientific notation string
3551
- * normalizeToDecimalComponents("-1.234e+3");
3552
- * // => { sign: -1, integerPart: "1234", fractionalPart: "" }
3553
- *
3554
- * @example
3555
- * // invalid string (throws)
3556
- * normalizeToDecimalComponents("12.34.56"); // Error: Invalid numeric string.
3557
- *
3558
- * @see convertExponentialToParts
3559
- * @category Parsing
3560
- * @since 2.0.0
3561
- * @public
3562
- */
3563
- declare function normalizeToDecimalComponents(input: unknown): {
3564
- sign: 1 | -1;
3565
- integerPart: string;
3566
- fractionalPart: string;
3567
- };
3568
-
3569
- /**
3570
- * Parses any numeric input (`number`, `bigint`, or `string`) into an exact {@link FixedDecimal}
3571
- * representation, preserving all digits without floating-point rounding errors.
3572
- *
3573
- * @remarks
3574
- * This function transforms arbitrary numeric input into a **fixed-precision decimal structure**
3575
- * that can safely represent extremely large or small values without losing information.
3576
- * It achieves this by first decomposing the input using {@link normalizeToDecimalComponents}
3577
- * and then constructing a `FixedDecimal` object consisting of:
3578
- *
3579
- * - `sign` → `1` for positive values, `-1` for negative values.
3580
- * - `digitsInteger` → a `BigInt` that encodes *all digits* of the number as if
3581
- * the decimal point were removed.
3582
- * - `scale` → the count of digits that were originally after the decimal point.
3583
- *
3584
- * The resulting value can later be precisely converted back to a string or to a
3585
- * JavaScript `number` using helpers like `fixedDecimalToStr` or `fixedDecimalToNum`.
3586
- *
3587
- * This process **avoids IEEE-754 floating-point artifacts**, ensuring mathematically
3588
- * exact handling of decimal fractions (e.g. `"0.1" + "0.2" → 0.3` instead of `0.30000000000000004`).
3589
- *
3590
- * @param input - Any numeric source value. Supported types:
3591
- * - `number` — finite only (`NaN`, `Infinity`, `-Infinity` will throw).
3592
- * - `bigint` — directly converted without fractional digits.
3593
- * - `string` — may contain optional sign, decimal point, or exponential notation (`1.23e-5`).
3594
- * Commas `,` as decimal separators are also supported and converted to dots `.`.
3595
- *
3596
- * @returns A normalized {@link FixedDecimal} object:
3597
- * ```ts
3598
- * {
3599
- * sign: 1 | -1; // the numeric sign
3600
- * digitsInteger: bigint; // all digits as a BigInt, no decimal point
3601
- * scale: number; // number of digits after the decimal
3602
- * }
3603
- * ```
3604
- *
3605
- * @throws {Error}
3606
- * - If the input is not a supported type (`number`, `bigint`, or `string`).
3607
- * - If the string cannot be parsed as a valid numeric representation.
3608
- * - If the number is not finite.
3609
- * - Any error propagated from {@link normalizeToDecimalComponents}.
3610
- *
3611
- * @example
3612
- * // Simple integer number
3613
- * parseToFixedDecimal(42);
3614
- * // => { sign: 1, digitsInteger: 42n, scale: 0 }
3615
- *
3616
- * @example
3617
- * // Decimal fraction
3618
- * parseToFixedDecimal("123.456");
3619
- * // => { sign: 1, digitsInteger: 123456n, scale: 3 }
3620
- *
3621
- * @example
3622
- * // Number in exponential notation
3623
- * parseToFixedDecimal("-1.23e-4");
3624
- * // => { sign: -1, digitsInteger: 123n, scale: 6 } // represents -0.000123
3625
- *
3626
- * @example
3627
- * // Leading zeros and trailing fractional zeros are trimmed internally
3628
- * parseToFixedDecimal("00045.67000");
3629
- * // => { sign: 1, digitsInteger: 4567n, scale: 2 } // "45.67"
3630
- *
3631
- * @example
3632
- * // Very large integer input using bigint
3633
- * parseToFixedDecimal(123456789012345678901234567890n);
3634
- * // => { sign: 1, digitsInteger: 123456789012345678901234567890n, scale: 0 }
3635
- *
3636
- * @example
3637
- * // Negative value with high precision fraction
3638
- * parseToFixedDecimal("-0.00000003432");
3639
- * // => { sign: -1, digitsInteger: 3432n, scale: 11 }
3640
- *
3641
- * @see normalizeToDecimalComponents
3642
- * @see FixedDecimal
3643
- * @see fixedDecimalToNum
3644
- * @see fixedDecimalToStr
3645
- *
3646
- * @category Parsing
3647
- * @since 2.0.0
3648
- * @public
3649
- */
3650
- declare function parseToFixedDecimal(input: unknown): FixedDecimal;
3651
-
3652
- /**
3653
- * Rounds a {@link FixedDecimal} value to the specified number of fractional digits,
3654
- * using either **half-up** (standard rounding) or **truncation** (cut-off without rounding).
3655
- *
3656
- * @remarks
3657
- * This function operates entirely in fixed-precision integer space (`BigInt` arithmetic),
3658
- * so rounding is mathematically exact — it never suffers from floating-point errors.
3659
- *
3660
- * Internally, it determines how many fractional digits must be removed from
3661
- * `source.digitsInteger` to reach the desired precision (`decimalPlaces`), divides
3662
- * by `10 ** digitsToRemove`, and conditionally increments the result depending on
3663
- * the remainder and rounding mode.
3664
- *
3665
- * It preserves the original `sign` and returns a new {@link FixedDecimal} object
3666
- * with an updated `scale` (number of digits after the decimal point).
3667
- *
3668
- * ---
3669
- * **Rounding modes:**
3670
- * - `'half-up'` — standard rounding to nearest neighbor; `.5` rounds **away from zero**.
3671
- * Example: `1.235 → 1.24`, `-1.235 → -1.24`.
3672
- * - `'trunc'` — truncates digits beyond the target precision (rounds **toward zero**).
3673
- * Example: `1.239 → 1.23`, `-1.239 → -1.23`.
3674
- *
3675
- * ---
3676
- * @param source - The input {@link FixedDecimal} to round.
3677
- * Must contain a valid combination of:
3678
- * - `sign`: `1` or `-1`
3679
- * - `digitsInteger`: a `BigInt` representing all digits (no decimal point)
3680
- * - `scale`: number of digits after the decimal
3681
- *
3682
- * @param decimalPlaces - Target number of digits to keep **after the decimal point**.
3683
- * Values less than 0 are treated as 0.
3684
- * For example, rounding to `2` means "keep two digits after the decimal".
3685
- *
3686
- * @param roundMode - Rounding algorithm to use:
3687
- * - `'half-up'` (default) → rounds 0.5 and higher up.
3688
- * - `'trunc'` → simply removes extra digits without rounding up.
3689
- *
3690
- * @defaultValue `'half-up'`
3691
- *
3692
- * @returns A **new** {@link FixedDecimal} with the adjusted `digitsInteger`
3693
- * and `scale` equal to `decimalPlaces`.
3694
- * If the requested precision is greater than or equal to `source.scale`,
3695
- * the source value is returned unchanged (shallow copy).
3696
- *
3697
- * @throws {Error}
3698
- * - Never throws directly in normal use, but may propagate errors if invalid
3699
- * numeric parameters are passed (e.g., non-integer `decimalPlaces`).
3700
- *
3701
- * ---
3702
- * @example
3703
- * // Half-up rounding
3704
- * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 }; // 123.456
3705
- * roundFixedDecimal(value, 2, 'half-up');
3706
- * // => { sign: 1, digitsInteger: 12346n, scale: 2 } // 123.46
3707
- *
3708
- * @example
3709
- * // Truncation (cut-off)
3710
- * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 };
3711
- * roundFixedDecimal(value, 2, 'trunc');
3712
- * // => { sign: 1, digitsInteger: 12345n, scale: 2 } // 123.45
3713
- *
3714
- * @example
3715
- * // No rounding needed (scale already smaller)
3716
- * const v: FixedDecimal = { sign: -1, digitsInteger: 1234n, scale: 1 }; // -123.4
3717
- * roundFixedDecimal(v, 3);
3718
- * // => identical copy: { sign: -1, digitsInteger: 1234n, scale: 1 }
3719
- *
3720
- * @example
3721
- * // Rounding very small values
3722
- * const v: FixedDecimal = { sign: 1, digitsInteger: 123n, scale: 6 }; // 0.000123
3723
- * roundFixedDecimal(v, 4);
3724
- * // => { sign: 1, digitsInteger: 1n, scale: 4 } // 0.0001
3725
- *
3726
- * @example
3727
- * // Rounding negative numbers (half-up → away from zero)
3728
- * const v: FixedDecimal = { sign: -1, digitsInteger: 125n, scale: 2 }; // -1.25
3729
- * roundFixedDecimal(v, 1, 'half-up');
3730
- * // => { sign: -1, digitsInteger: 13n, scale: 1 } // -1.3
3731
- *
3732
- * @see FixedDecimal
3733
- * @see parseToFixedDecimal
3734
- * @see fixedDecimalToNum
3735
- * @see fixedDecimalToStr
3736
- * @see formatToNum
3737
- *
3738
- * @category Math
3739
- * @since 2.0.0
3740
- * @public
3741
- */
3742
- declare function roundFixedDecimal(source: FixedDecimal, decimalPlaces: number, roundMode?: 'half-up' | 'trunc'): FixedDecimal;
2833
+ declare function numNormalize(value: unknown, round?: number, throwError?: boolean): number;
3743
2834
 
3744
2835
  /**
3745
2836
  * Converts any given string-like value into a lower-cased, trimmed string.
@@ -3755,7 +2846,7 @@ declare function roundFixedDecimal(source: FixedDecimal, decimalPlaces: number,
3755
2846
  * @remarks
3756
2847
  * ### Processing steps
3757
2848
  * 1. **Type check** — ensures the input is a string using {@link isStr}.
3758
- * 2. **Trimming** — removes leading and trailing whitespace via {@link formatToTrim}.
2849
+ * 2. **Trimming** — removes leading and trailing whitespace via {@link strTrim}.
3759
2850
  * 3. **Validation** — ensures the result is non-empty with {@link isStrFilled}.
3760
2851
  * 4. **Lowercasing** — calls `String.prototype.toLowerCase()` on the trimmed text.
3761
2852
  * 5. If the string is empty or not valid at any step, returns `""`.
@@ -3765,7 +2856,7 @@ declare function roundFixedDecimal(source: FixedDecimal, decimalPlaces: number,
3765
2856
  * - Non-string inputs (numbers, booleans, objects, arrays, `null`, `undefined`) all yield `""`.
3766
2857
  *
3767
2858
  * ### Use cases
3768
- * - Case-insensitive string comparison (normalize both sides with `formatToLowerCase`).
2859
+ * - Case-insensitive string comparison (normalize both sides with `strLowerCase`).
3769
2860
  * - Normalizing user input before storing or indexing.
3770
2861
  * - Simplifying logic where optional strings may be `null` or empty.
3771
2862
  *
@@ -3777,35 +2868,35 @@ declare function roundFixedDecimal(source: FixedDecimal, decimalPlaces: number,
3777
2868
  *
3778
2869
  * @example
3779
2870
  * // Basic strings
3780
- * formatToLowerCase('HELLO'); // => "hello"
3781
- * formatToLowerCase(' TEST '); // => "test"
2871
+ * strLowerCase('HELLO'); // => "hello"
2872
+ * strLowerCase(' TEST '); // => "test"
3782
2873
  *
3783
2874
  * @example
3784
2875
  * // Mixed types
3785
- * formatToLowerCase(123); // => ""
3786
- * formatToLowerCase(true); // => ""
3787
- * formatToLowerCase(null); // => ""
2876
+ * strLowerCase(123); // => ""
2877
+ * strLowerCase(true); // => ""
2878
+ * strLowerCase(null); // => ""
3788
2879
  *
3789
2880
  * @example
3790
2881
  * // Empty or whitespace inputs
3791
- * formatToLowerCase(' '); // => ""
3792
- * formatToLowerCase(''); // => ""
2882
+ * strLowerCase(' '); // => ""
2883
+ * strLowerCase(''); // => ""
3793
2884
  *
3794
2885
  * @example
3795
2886
  * // Already lowercase
3796
- * formatToLowerCase('data'); // => "data"
2887
+ * strLowerCase('data'); // => "data"
3797
2888
  *
3798
2889
  * @see isStr
3799
2890
  * @see isStrFilled
3800
- * @see formatToTrim
2891
+ * @see strTrim
3801
2892
  *
3802
2893
  * @category String
3803
2894
  * @public
3804
2895
  * @since 2.0.0
3805
2896
  */
3806
- declare function formatToLowerCase(value?: unknown): string;
2897
+ declare function strLowerCase(value?: unknown): string;
3807
2898
 
3808
- declare function formatToNormalCase(value?: unknown): string;
2899
+ declare function strNormalCase(value?: unknown): string;
3809
2900
 
3810
2901
  /**
3811
2902
  * Converts `undefined` or empty (whitespace-only) strings into `null`.
@@ -3821,14 +2912,14 @@ declare function formatToNormalCase(value?: unknown): string;
3821
2912
  * @returns
3822
2913
  * - `null` if:
3823
2914
  * - The input is `undefined`, or
3824
- * - The input is a string that becomes empty after trimming (using {@link formatToTrim}).
2915
+ * - The input is a string that becomes empty after trimming (using {@link strTrim}).
3825
2916
  * - Otherwise returns the original `value`.
3826
2917
  *
3827
2918
  * @remarks
3828
2919
  * ### Processing steps
3829
2920
  * 1. If `value` is `undefined`, returns `null`.
3830
2921
  * 2. If `value` is a string:
3831
- * - Trims it with {@link formatToTrim}, removing whitespace and invisible characters.
2922
+ * - Trims it with {@link strTrim}, removing whitespace and invisible characters.
3832
2923
  * - If the trimmed result is empty (`''`), returns `null`.
3833
2924
  * 3. Otherwise returns the original value unchanged.
3834
2925
  *
@@ -3837,8 +2928,8 @@ declare function formatToNormalCase(value?: unknown): string;
3837
2928
  * - The function is **pure** (non-mutating) and safe for use in JSON or ORM normalization.
3838
2929
  * - Often used to prepare form data, REST payloads, or DB entities for consistent nullability.
3839
2930
  *
3840
- * ### Comparison with {@link formatToUndefined}
3841
- * | Case | `formatToNull` | `formatToUndefined` |
2931
+ * ### Comparison with {@link strUndefined}
2932
+ * | Case | `strNull` | `strUndefined` |
3842
2933
  * |------|----------------|----------------------|
3843
2934
  * | `undefined` | `null` | `undefined` |
3844
2935
  * | `''` (empty string) | `null` | `undefined` |
@@ -3858,34 +2949,34 @@ declare function formatToNormalCase(value?: unknown): string;
3858
2949
  *
3859
2950
  * @example
3860
2951
  * // Empty and whitespace strings
3861
- * formatToNull(''); // => null
3862
- * formatToNull(' '); // => null
2952
+ * strNull(''); // => null
2953
+ * strNull(' '); // => null
3863
2954
  *
3864
2955
  * @example
3865
2956
  * // Undefined also becomes null
3866
- * formatToNull(undefined); // => null
2957
+ * strNull(undefined); // => null
3867
2958
  *
3868
2959
  * @example
3869
2960
  * // Non-empty strings remain as-is
3870
- * formatToNull('Hello'); // => "Hello"
3871
- * formatToNull(' Data '); // => " Data "
2961
+ * strNull('Hello'); // => "Hello"
2962
+ * strNull(' Data '); // => " Data "
3872
2963
  *
3873
2964
  * @example
3874
2965
  * // Non-string types are preserved
3875
- * formatToNull(0); // => 0
3876
- * formatToNull(false); // => false
3877
- * formatToNull([]); // => []
3878
- * formatToNull({}); // => {}
2966
+ * strNull(0); // => 0
2967
+ * strNull(false); // => false
2968
+ * strNull([]); // => []
2969
+ * strNull({}); // => {}
3879
2970
  *
3880
2971
  * @see isStr
3881
- * @see formatToTrim
3882
- * @see formatToUndefined
2972
+ * @see strTrim
2973
+ * @see strUndefined
3883
2974
  *
3884
2975
  * @category String
3885
2976
  * @public
3886
2977
  * @since 2.0.0
3887
2978
  */
3888
- declare function formatToNull(value: unknown): {} | null;
2979
+ declare function strNull(value: unknown): {} | null;
3889
2980
 
3890
2981
  /**
3891
2982
  * Normalizes and validates a phone number into international format (`E.164` style).
@@ -3978,7 +3069,7 @@ declare function formatToNull(value: unknown): {} | null;
3978
3069
  * formatToPhone(true); // => null
3979
3070
  *
3980
3071
  * @see isStr
3981
- * @see formatToTrim
3072
+ * @see strTrim
3982
3073
  *
3983
3074
  * @category String
3984
3075
  * @public
@@ -4043,23 +3134,23 @@ declare function formatToPhone(value?: unknown, defaultCountry?: string): string
4043
3134
  *
4044
3135
  * @example
4045
3136
  * // Basic trimming
4046
- * formatToTrim(' Hello '); // => "Hello"
3137
+ * strTrim(' Hello '); // => "Hello"
4047
3138
  *
4048
3139
  * @example
4049
3140
  * // Removes zero-width characters
4050
- * formatToTrim('word\u200B'); // => "word"
3141
+ * strTrim('word\u200B'); // => "word"
4051
3142
  *
4052
3143
  * @example
4053
3144
  * // Unicode normalization
4054
- * formatToTrim('ABC'); // => "ABC"
4055
- * formatToTrim('e\u0301'); // => "é"
3145
+ * strTrim('ABC'); // => "ABC"
3146
+ * strTrim('e\u0301'); // => "é"
4056
3147
  *
4057
3148
  * @example
4058
3149
  * // Non-string inputs
4059
- * formatToTrim(123); // => ""
4060
- * formatToTrim(null); // => ""
4061
- * formatToTrim(undefined); // => ""
4062
- * formatToTrim({ text: 'hi' }); // => ""
3150
+ * strTrim(123); // => ""
3151
+ * strTrim(null); // => ""
3152
+ * strTrim(undefined); // => ""
3153
+ * strTrim({ text: 'hi' }); // => ""
4063
3154
  *
4064
3155
  * @see isStr
4065
3156
  * @see String.prototype.normalize
@@ -4068,7 +3159,7 @@ declare function formatToPhone(value?: unknown, defaultCountry?: string): string
4068
3159
  * @public
4069
3160
  * @since 2.0.0
4070
3161
  */
4071
- declare function formatToTrim(value: unknown): string;
3162
+ declare function strTrim(value: unknown): string;
4072
3163
 
4073
3164
  /**
4074
3165
  * Converts `null` or empty (whitespace-only) strings into `undefined`.
@@ -4084,25 +3175,25 @@ declare function formatToTrim(value: unknown): string;
4084
3175
  * @returns
4085
3176
  * - `undefined` if:
4086
3177
  * - The value is `null`, or
4087
- * - The value is a string that becomes empty after trimming (via {@link formatToTrim}).
3178
+ * - The value is a string that becomes empty after trimming (via {@link strTrim}).
4088
3179
  * - Otherwise returns the original value.
4089
3180
  *
4090
3181
  * @remarks
4091
3182
  * ### Processing steps
4092
3183
  * 1. If `value` is `null`, return `undefined`.
4093
3184
  * 2. If `value` is a string:
4094
- * - Trim using {@link formatToTrim} to remove whitespace and invisible characters.
3185
+ * - Trim using {@link strTrim} to remove whitespace and invisible characters.
4095
3186
  * - If trimmed result is empty, return `undefined`.
4096
3187
  * 3. Otherwise, return the original value unchanged.
4097
3188
  *
4098
3189
  * ### Behavior notes
4099
3190
  * - Non-string, non-null values (`0`, `false`, `{}`, `[]`, etc.) are **not modified**.
4100
3191
  * - The function is **non-mutating** — it never changes the original reference.
4101
- * - It complements {@link formatToNull}, depending on whether your system
3192
+ * - It complements {@link strNull}, depending on whether your system
4102
3193
  * prefers `undefined` (omit field) or `null` (explicit empty value).
4103
3194
  *
4104
- * ### Comparison with {@link formatToNull}
4105
- * | Case | `formatToNull` | `formatToUndefined` |
3195
+ * ### Comparison with {@link strNull}
3196
+ * | Case | `strNull` | `strUndefined` |
4106
3197
  * |------|----------------|----------------------|
4107
3198
  * | `null` | `null` | `undefined` |
4108
3199
  * | `undefined` | `null` | `undefined` |
@@ -4124,376 +3215,44 @@ declare function formatToTrim(value: unknown): string;
4124
3215
  *
4125
3216
  * @example
4126
3217
  * // Empty and whitespace-only strings
4127
- * formatToUndefined(''); // => undefined
4128
- * formatToUndefined(' '); // => undefined
3218
+ * strUndefined(''); // => undefined
3219
+ * strUndefined(' '); // => undefined
4129
3220
  *
4130
3221
  * @example
4131
3222
  * // null is also normalized
4132
- * formatToUndefined(null); // => undefined
3223
+ * strUndefined(null); // => undefined
4133
3224
  *
4134
3225
  * @example
4135
3226
  * // Non-empty strings remain unchanged
4136
- * formatToUndefined('Hello'); // => "Hello"
3227
+ * strUndefined('Hello'); // => "Hello"
4137
3228
  *
4138
3229
  * @example
4139
3230
  * // Non-string types are preserved
4140
- * formatToUndefined(0); // => 0
4141
- * formatToUndefined(false); // => false
4142
- * formatToUndefined([]); // => []
4143
- * formatToUndefined({}); // => {}
3231
+ * strUndefined(0); // => 0
3232
+ * strUndefined(false); // => false
3233
+ * strUndefined([]); // => []
3234
+ * strUndefined({}); // => {}
4144
3235
  *
4145
3236
  * @see isStr
4146
- * @see formatToTrim
4147
- * @see formatToNull
3237
+ * @see strTrim
3238
+ * @see strNull
4148
3239
  *
4149
3240
  * @category String
4150
3241
  * @public
4151
3242
  * @since 2.0.0
4152
3243
  */
4153
- declare function formatToUndefined(value: unknown): {} | undefined;
3244
+ declare function strUndefined(value: unknown): {} | undefined;
4154
3245
 
4155
- /**
4156
- * Converts a numeric value with a given unit (bytes, KB, MB, GB, TB, PB)
4157
- * into gigabytes (`GB`).
4158
- *
4159
- * @summary
4160
- * Safely normalizes a size value of any supported unit into **gigabytes**,
4161
- * using binary multiples (`1 KB = 1024 bytes`, `1 MB = 1024 KB`, etc.).
4162
- *
4163
- * @param value - Numeric value to convert (e.g., `512`, `"1.5"`, `"2048MB"`).
4164
- * @param unit - Optional unit string indicating the scale of `value`.
4165
- * Case-insensitive. Supported prefixes:
4166
- * `"B"`, `"KB"`, `"MB"`, `"GB"`, `"TB"`, `"PB"`.
4167
- *
4168
- * @returns The value converted to gigabytes (`number`).
4169
- *
4170
- * @throws {Error}
4171
- * Throws an error if the input value cannot be parsed as a finite number,
4172
- * or if the computed result is `NaN` or `Infinity`.
4173
- *
4174
- * @remarks
4175
- * ### Supported units
4176
- * | Unit | Interpreted as | Conversion formula |
4177
- * |------|----------------|--------------------|
4178
- * | `b`, `B`, `bytes` | bytes | `v / GB` |
4179
- * | `k`, `kb`, `kilobyte` | kilobytes | `v / MB` |
4180
- * | `m`, `mb`, `megabyte` | megabytes | `v / GB` |
4181
- * | `g`, `gb`, `gigabyte` | gigabytes | `v` |
4182
- * | `t`, `tb`, `terabyte` | terabytes | `v * 1024` |
4183
- * | `p`, `pb`, `petabyte` | petabytes | `v * (1024²)` |
4184
- *
4185
- * If no unit is provided, gigabytes (`GB`) are assumed by default.
4186
- *
4187
- * ### Normalization steps
4188
- * 1. Convert `value` to a numeric value using {@link formatToNum}.
4189
- * 2. Validate via {@link isNum} — must be finite.
4190
- * 3. Normalize `unit`:
4191
- * - Trim whitespace.
4192
- * - Convert to lowercase.
4193
- * - Extract first character (e.g., `'k'` for `"KB"`).
4194
- * 4. Compute conversion factor depending on the first letter.
4195
- * 5. Normalize `-0` to `0` before returning.
4196
- *
4197
- * ### Behavior notes
4198
- * - Throws descriptive errors on invalid inputs.
4199
- * - Supports string-based numeric inputs (`"2048"`, `"1.5"`, etc.).
4200
- * - Ignores case and trailing spaces in the unit name.
4201
- * - Uses binary (IEC-style) 1024-based units — not SI 1000-based.
4202
- *
4203
- * ### Performance
4204
- * - Time complexity: **O(1)**.
4205
- * - Space complexity: **O(1)**.
4206
- *
4207
- * ### Examples
4208
- *
4209
- * @example
4210
- * // Basic conversions
4211
- * toGB(1024, 'MB'); // => 1
4212
- * toGB(1, 'GB'); // => 1
4213
- * toGB(1, 'TB'); // => 1024
4214
- * toGB(0.5, 'TB'); // => 512
4215
- *
4216
- * @example
4217
- * // From bytes
4218
- * toGB(1073741824, 'B'); // => 1
4219
- * toGB('2147483648', 'b'); // => 2
4220
- *
4221
- * @example
4222
- * // From petabytes
4223
- * toGB(1, 'PB'); // => 1048576
4224
- *
4225
- * @example
4226
- * // Auto-handling and normalization
4227
- * toGB(' 1.5 ', ' mb '); // => 0.00146484375
4228
- * toGB('2', ''); // => 2 (default is GB)
4229
- *
4230
- * @example
4231
- * // Invalid inputs
4232
- * toGB('abc', 'GB'); // throws Error("toGB: value "abc" is not numeric")
4233
- * toGB(NaN, 'MB'); // throws Error("toGB: result is not finite...")
4234
- *
4235
- * @see isNum
4236
- * @see formatToNum
4237
- *
4238
- * @category Conversion
4239
- * @public
4240
- * @since 2.0.0
4241
- */
4242
- declare function toGB(value: unknown, unit?: string): number;
4243
-
4244
- /**
4245
- * Converts a hashrate (or similar magnitude value) into **gigahashes per second** (`GH/s`).
4246
- *
4247
- * @summary
4248
- * Normalizes a numeric value expressed in various hash rate units (e.g., `kH/s`, `MH/s`, `TH/s`)
4249
- * to **gigahashes (GH)**, using standard decimal scaling (`×1000` between adjacent prefixes).
4250
- *
4251
- * @param value - Input numeric value or string representing a number (e.g. `"1200"`, `3.5`).
4252
- * @param unit - Optional unit string representing the magnitude (`H`, `kH`, `MH`, `GH`, `TH`, `PH`, `EH`).
4253
- * Case-insensitive and automatically normalized via {@link normalizeUnit}.
4254
- *
4255
- * @returns The normalized value expressed in **gigahashes per second (GH/s)**.
4256
- * Returns `0` if the input is invalid or non-numeric.
4257
- *
4258
- * @remarks
4259
- * ### Conversion logic
4260
- * 1. **Parsing:**
4261
- * Uses {@link formatToNum} to safely convert `value` into a number.
4262
- *
4263
- * 2. **Validation:**
4264
- * If the parsed number is not finite (`NaN`, `Infinity`, etc.), returns `0`.
4265
- *
4266
- * 3. **Unit normalization:**
4267
- * Calls {@link normalizeUnit} to clean up and simplify the unit name (e.g. `" MH/s "` → `"mh"`).
4268
- * Then takes the first character (`m`, `g`, `t`, etc.) to determine scale.
4269
- *
4270
- * 4. **Factor lookup:**
4271
- * Applies the following conversion factors relative to gigahashes:
4272
- *
4273
- * | Prefix | Unit | Factor (to GH) | Example conversion |
4274
- * |---------|-----------|----------------|--------------------------------|
4275
- * | `h` | hashes/s | `1e-9` | `1e9 H/s` = `1 GH/s` |
4276
- * | `k` | kilohash | `1e-6` | `1e6 kH/s` = `1 GH/s` |
4277
- * | `m` | megahash | `1e-3` | `1e3 MH/s` = `1 GH/s` |
4278
- * | `g` | gigahash | `1` | identity |
4279
- * | `t` | terahash | `1e3` | `1 TH/s` = `1000 GH/s` |
4280
- * | `p` | petahash | `1e6` | `1 PH/s` = `1,000,000 GH/s` |
4281
- * | `e` | exahash | `1e9` | `1 EH/s` = `1,000,000,000 GH/s`|
4282
- *
4283
- * 5. **Result validation:**
4284
- * If the final result is not a finite number, throws an error.
4285
- * Otherwise returns the computed gigahashes value (with `-0` normalized to `0`).
4286
- *
4287
- * ### Behavior notes
4288
- * - Returns `0` instead of throwing when the input cannot be parsed as a number.
4289
- * - Uses **decimal scaling** (`×1000`), not binary (`×1024`).
4290
- * - Handles both numeric and string inputs seamlessly.
4291
- * - Automatically ignores plural or rate suffixes (like `/s`, `hashes`).
4292
- *
4293
- * ### Performance
4294
- * - Time complexity: **O(1)**.
4295
- * - Space complexity: **O(1)**.
4296
- *
4297
- * ### Examples
4298
- *
4299
- * @example
4300
- * // Basic conversions
4301
- * toGH(1, 'GH'); // => 1
4302
- * toGH(1, 'TH'); // => 1000
4303
- * toGH(1, 'MH'); // => 0.001
4304
- * toGH(1, 'kH'); // => 0.000001
4305
- * toGH(1, 'PH'); // => 1_000_000
4306
- * toGH(1, 'EH'); // => 1_000_000_000
4307
- *
4308
- * @example
4309
- * // String inputs and normalization
4310
- * toGH('1200', 'mh/s'); // => 1.2
4311
- * toGH('3.5', 'TH/s'); // => 3500
4312
- *
4313
- * @example
4314
- * // Invalid or edge inputs
4315
- * toGH('', 'GH'); // => 0
4316
- * toGH(null, 'GH'); // => 0
4317
- * toGH(NaN, 'MH'); // => 0
4318
- *
4319
- * @example
4320
- * // Custom normalization of unit formatting
4321
- * toGH(5, ' khash / s '); // => 0.000005
4322
- * toGH(2, 'T'); // => 2000
4323
- *
4324
- * @see formatToNum
4325
- * @see isNum
4326
- * @see normalizeUnit
4327
- *
4328
- * @category Conversion
4329
- * @public
4330
- * @since 2.0.0
4331
- */
4332
- declare function toGH(value: any, unit?: string): number;
3246
+ declare const strNormalize: (v: unknown) => unknown;
4333
3247
 
4334
- /**
4335
- * Converts a rate value expressed with SI hash-rate prefixes into **hashes per second** (`H/s`).
4336
- *
4337
- * @summary
4338
- * Normalizes a numeric value given in `kH/s`, `MH/s`, `GH/s`, `TH/s`, `PH/s`, or `EH/s`
4339
- * to plain **hashes per second** using **decimal scaling** (×1000 between adjacent prefixes).
4340
- * Units are case-insensitive and sanitized via {@link normalizeUnit}.
4341
- *
4342
- * @param value - Input value to convert (number or number-like string, e.g. `3.5`, `"1200"`).
4343
- * @param unit - Optional unit string (e.g. `"kH/s"`, `"MH"`, `"ghashes"`).
4344
- * If omitted or empty, the function assumes **`h`** (hashes).
4345
- *
4346
- * @returns The value converted to **H/s** (`number`). Returns `0` if `value` is not numeric.
4347
- *
4348
- * @remarks
4349
- * ### Unit handling
4350
- * `unit` is first cleaned by {@link normalizeUnit} (trim, lowercase, remove spaces and `"/s"`, `"hash(es)"`),
4351
- * then the **first character** determines the scale:
4352
- *
4353
- * | Prefix | Interpreted as | Multiplier to H/s |
4354
- * |:------:|-----------------|-------------------|
4355
- * | `h` | hashes | `1` |
4356
- * | `k` | kilohashes | `1e3` |
4357
- * | `m` | megahashes | `1e6` |
4358
- * | `g` | gigahashes | `1e9` |
4359
- * | `t` | terahashes | `1e12` |
4360
- * | `p` | petahashes | `1e15` |
4361
- * | `e` | exahashes | `1e18` |
4362
- *
4363
- * Unknown or empty prefixes default to `h` (no scaling).
4364
- *
4365
- * ### Parsing & validation
4366
- * - Uses {@link formatToNum} to parse `value`.
4367
- * - If parsed value is not a finite number, returns `0`.
4368
- * - After conversion, if the result is not finite, throws an error with details.
4369
- * - Normalizes `-0` to `0` before returning.
4370
- *
4371
- * ### Decimal vs binary
4372
- * This function uses **decimal** (SI) steps (×1000) common for hashrates.
4373
- * For byte/size conversions use binary (×1024) helpers like `toGB`.
4374
- *
4375
- * ### Performance
4376
- * - Time complexity: **O(1)**
4377
- * - Space complexity: **O(1)**
4378
- *
4379
- * ### Examples
4380
- *
4381
- * @example
4382
- * // Identity and basic scales
4383
- * toH(1, 'H'); // => 1
4384
- * toH(1, 'kH'); // => 1_000
4385
- * toH(1, 'MH'); // => 1_000_000
4386
- * toH(1, 'GH'); // => 1_000_000_000
4387
- * toH(2.5, 'TH'); // => 2_500_000_000_000
4388
- *
4389
- * @example
4390
- * // Large magnitudes
4391
- * toH(1, 'PH'); // => 1_000_000_000_000_000
4392
- * toH(0.01, 'EH'); // => 10_000_000_000_000_000
4393
- *
4394
- * @example
4395
- * // Flexible, noisy units and strings
4396
- * toH('1200', ' mh/s '); // => 1_200_000
4397
- * toH(3.2, 'khashes'); // => 3_200
4398
- * toH('5', ''); // => 5 (defaults to hashes)
4399
- *
4400
- * @example
4401
- * // Invalid inputs
4402
- * toH('', 'GH'); // => 0
4403
- * toH(null, 'MH'); // => 0
4404
- * toH(NaN, 'kH'); // => 0
4405
- *
4406
- * @see normalizeUnit
4407
- * @see formatToNum
4408
- * @see isNum
4409
- *
4410
- * @category Conversion
4411
- * @public
4412
- * @since 2.0.0
4413
- */
4414
- declare function toH(value: any, unit?: string): number;
3248
+ type UrlObj = {
3249
+ protocol: string;
3250
+ user: string;
3251
+ url: string;
3252
+ port: number;
3253
+ path: string;
3254
+ };
4415
3255
 
4416
- /**
4417
- * Extracts the **hostname** (IPv4, IPv6, or domain) from a URL-like string.
4418
- *
4419
- * @summary
4420
- * Parses a given string as a URL or host reference and returns the **host component**
4421
- * (without protocol, port, path, query, or credentials).
4422
- * Handles both valid URLs (via {@link URL}) and malformed or scheme-less inputs using fallback parsing.
4423
- *
4424
- * @param value - Any string that may represent a URL, host, or address.
4425
- *
4426
- * @returns
4427
- * The hostname (domain or IP address) as a plain string.
4428
- * Returns an empty string (`""`) if the input is blank or cannot be parsed.
4429
- *
4430
- * @remarks
4431
- * ### Parsing strategy
4432
- * 1. **Scheme detection:**
4433
- * - If the input starts with a protocol scheme (e.g., `http:`, `ftp:`), it is parsed directly.
4434
- * - Otherwise, a default `http://` prefix is prepended so the built-in {@link URL} parser can process it.
4435
- *
4436
- * 2. **Primary parsing:**
4437
- * - Uses the native {@link URL} class to extract `hostname`.
4438
- * - Automatically handles IPv6 literals, punycode domains, and IDNs.
4439
- *
4440
- * 3. **Fallback parsing (for invalid URLs):**
4441
- * - Strips credentials (`user:pass@`).
4442
- * - Extracts the first segment before `/`, `?`, or `#`.
4443
- * - If the result looks like `[::1]` or `[2001:db8::1]`, returns the IPv6 address inside brackets.
4444
- * - Otherwise, takes everything before the first colon (`:`) as the hostname.
4445
- *
4446
- * ### Supported formats
4447
- * - Full URLs:
4448
- * `"https://user:pass@sub.example.com:8080/path"` → `"sub.example.com"`
4449
- * - Host with port:
4450
- * `"example.com:3000"` → `"example.com"`
4451
- * - IPv4:
4452
- * `"192.168.1.1:4028"` → `"192.168.1.1"`
4453
- * - IPv6 (with or without brackets):
4454
- * `"[2001:db8::1]:4028"` → `"2001:db8::1"`
4455
- * - Without scheme:
4456
- * `"example.com/test?q=1"` → `"example.com"`
4457
- *
4458
- * ### Behavior notes
4459
- * - Returns an empty string if `value` is empty, blank, or unparsable.
4460
- * - Never throws — all exceptions are caught and handled gracefully.
4461
- * - Does **not** include port numbers or authentication info.
4462
- * - Automatically trims whitespace before parsing.
4463
- *
4464
- * ### Performance
4465
- * - Time complexity: **O(n)** (linear in string length).
4466
- * - Space complexity: **O(n)** (creates trimmed and split substrings).
4467
- *
4468
- * ### Examples
4469
- *
4470
- * @example
4471
- * // Standard URLs
4472
- * extractHost('https://example.com/path'); // => "example.com"
4473
- * extractHost('http://user:pass@site.org:8080'); // => "site.org"
4474
- *
4475
- * @example
4476
- * // Without scheme
4477
- * extractHost('example.com/foo/bar'); // => "example.com"
4478
- * extractHost('sub.domain.net:3000'); // => "sub.domain.net"
4479
- *
4480
- * @example
4481
- * // IP addresses
4482
- * extractHost('192.168.0.10:4028'); // => "192.168.0.10"
4483
- * extractHost('[2001:db8::1]:80'); // => "2001:db8::1"
4484
- *
4485
- * @example
4486
- * // Invalid or blank input
4487
- * extractHost(''); // => ""
4488
- * extractHost('not a valid host'); // => "not"
4489
- *
4490
- * @see URL
4491
- * @see isStrFilled
4492
- *
4493
- * @category Network
4494
- * @public
4495
- * @since 2.0.0
4496
- */
4497
- declare function extractHost(value?: string): string;
3256
+ declare function urlObj(value?: string): UrlObj;
4498
3257
 
4499
- export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgsArr, formatToBool, formatToLowerCase, formatToNormalCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, isArr, isArrFilled, isBool, isClass, 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 };
3258
+ export { type JSONLike, type PasswordOptions, type TimeParts, arrFuncArgs, arrSplitPortions, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, formatToPhone, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, jsonParse, jsonStrLike, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strTrim, strUndefined, urlObj, wait };