@lntvow/utils 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -243,84 +243,84 @@ interface PickOptions {
243
243
  }
244
244
 
245
245
  /**
246
- * 生成随机数组
246
+ * Generate random array
247
247
  * @example generateRandomArray(4, () => 1) => [1, 1, 1, 1]
248
248
  * */
249
249
  declare function generateRandomArray<T>(num: number, cb: (item?: unknown, index?: number) => T): T[];
250
250
 
251
251
  /**
252
- * 生成随机颜色
252
+ * Generate random color
253
253
  * @example generateRandomColor() => '#f36a38'
254
254
  * */
255
255
  declare function generateRandomColor(): string;
256
256
 
257
257
  /**
258
- * 生成随机时间
258
+ * Generate random date
259
259
  * @example generateRandomDate() => '2021-07-01 08:51:34'
260
260
  * */
261
261
  declare function generateRandomDate(options?: GenerateRandomDate): string;
262
262
  interface GenerateRandomDate {
263
263
  /**
264
- * 开始时间
264
+ * Start time
265
265
  * @default 1800-01-01 00:00:00
266
266
  */
267
267
  start?: string | Date;
268
268
  /**
269
- * 结束时间
270
- * @default 当前时间
269
+ * End time
270
+ * @default Current time
271
271
  */
272
272
  end?: string | Date;
273
273
  /**
274
- * 时间格式
274
+ * Date format
275
275
  * @default YYYY-MM-DD HH:mm:ss
276
276
  */
277
277
  format?: string;
278
278
  }
279
279
 
280
280
  /**
281
- * 生成随机邮箱
281
+ * Generate random email
282
282
  * @example generateRandomEmail() => lZtJqMl0dyTO3WDGzFDO@gmail.com
283
283
  */
284
284
  declare function generateRandomEmail(): string;
285
285
 
286
286
  /**
287
- * 生成范围内的随机浮点数
287
+ * Generate random float number within range
288
288
  * @example generateRandomFloat() => 0.35
289
289
  * */
290
290
  declare function generateRandomFloat(options?: GenerateRandomFloat): number;
291
291
  type GenerateRandomFloat = number | {
292
292
  /**
293
- * 最大值
293
+ * Maximum value
294
294
  * @default 1.00
295
295
  */
296
296
  max?: number;
297
297
  /**
298
- * 最小值
298
+ * Minimum value
299
299
  * @default 0.00
300
300
  */
301
301
  min?: number;
302
302
  /**
303
- * 小数位数
303
+ * Fraction digits
304
304
  * @default 2
305
305
  */
306
306
  fractionDigits?: number;
307
307
  };
308
308
 
309
309
  /**
310
- * 生成随机二代身份证号
310
+ * Generate random Chinese ID card number
311
311
  * @example generateRandomIdCard() => '410304200210165258'
312
312
  */
313
313
  declare function generateRandomIdCard(): string;
314
314
 
315
315
  /**
316
- * 生成随机手机号码
316
+ * Generate random mobile phone number
317
317
  * @example generateRandomMobilePhone() => 13012345678
318
318
  */
319
319
  declare function generateRandomMobilePhone(): string;
320
320
 
321
321
  /**
322
- * 生成随机数据从数据源中
323
- * @param num 随机获取数据源子项次数
322
+ * Generate random string from source
323
+ * @param num Number of times to randomly get items from source
324
324
  * @example generateRandomStringFromSource(4, ['1', 'b', 'c', 'd', 'e']) => 'dea1'
325
325
  * */
326
326
  declare function generateRandomStringFromSource(num: number, source: (number | string)[]): string;
@@ -356,7 +356,7 @@ type Options$1 = {
356
356
  | number;
357
357
 
358
358
  /**
359
- * 获取数组中的随机元素
359
+ * Get random item from array
360
360
  * @example getRandomItem([0, 1, 2, 3, 4]) => 2
361
361
  */
362
362
  declare function getRandomItem<T>(list: T[]): T;
@@ -426,76 +426,125 @@ type Options = {
426
426
  declare function getRandomUrl(): string;
427
427
 
428
428
  /**
429
- * 十进制转二进制
429
+ * Convert decimal to binary
430
430
  * @example decimalToBinary(233) => '11101001'
431
431
  */
432
432
  declare function decimalToBinary(decNumber: number): string;
433
433
  /**
434
- * Base64 编码
434
+ * Base64 encode
435
435
  * @example base64Encode('hello') => 'aGVsbG8='
436
436
  */
437
437
  declare function base64Encode(str: string): string;
438
438
  /**
439
- * Base64 解码
439
+ * Base64 decode
440
440
  * @example base64Decode('aGVsbG8=') => 'hello'
441
441
  */
442
442
  declare function base64Decode(str: string): string;
443
443
 
444
444
  /**
445
445
  * compose
446
- * @param fns 任意函数
446
+ * @param fns Any functions
447
447
  */
448
448
  declare function compose(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
449
449
  /**
450
- * compose 从右到左
451
- * @param fns 任意函数
450
+ * Compose from right to left
451
+ * @param fns Any functions
452
452
  */
453
453
  declare function composeRight(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
454
454
 
455
455
  /**
456
- * 防抖函数
457
- * @param target 目标函数
458
- * @param wait 等待时间 默认 500ms
456
+ * Debounce function
457
+ * @param target Target function
458
+ * @param wait Wait time, default 500ms
459
459
  * @example debounce(() => console.log('debounce'), 500)
460
460
  */
461
461
  declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
462
462
 
463
463
  /**
464
- * Deeply clones an object
465
- * @param target The target object to clone
466
- * @example
464
+ * Creates a deep clone of any value, preserving object structure and references.
465
+ *
466
+ * This utility performs a complete deep copy of the input value, handling complex nested structures,
467
+ * circular references, and various JavaScript types. It preserves prototype chains, property descriptors,
468
+ * and handles special objects like Date, RegExp, Map, Set, and more.
467
469
  *
470
+ * @example
468
471
  * deepClone({ name: 'test' }) => { name: 'test' }
472
+ *
473
+ * @example
474
+ * deepClone({ user: { name: 'John', data: [1, 2] } }) => { user: { name: 'John', data: [1, 2] } }
475
+ *
476
+ * @returns A deep clone of the input value with all nested references copied
477
+ *
478
+ * @remarks
479
+ * - Handles circular references to prevent infinite loops
480
+ * - Preserves prototype chains for objects and arrays
481
+ * - Maintains property descriptors including getters and setters
482
+ * - Supports Symbol properties and Symbol keys
483
+ * - Clones Date objects to new Date instances with same time
484
+ * - Clones RegExp objects maintaining their behavior
485
+ * - Returns Promise objects as-is (promises are not cloned)
486
+ * - Recursively clones Map and Set collections including their keys/values
487
+ * - Handles non-object-like values (primitives) by returning them directly
488
+ * - Preserves array subclass prototypes and custom array-like objects
489
+ * - Maintains all property metadata and descriptors
469
490
  */
470
491
  declare function deepClone<T>(target: T): T;
471
492
 
472
493
  /**
473
- * Deeply merges two objects
474
- * @param template The template object, which serves as the default values
475
- * @param source The source object, which contains user-provided values
476
- * @param options Configuration options
494
+ * Recursively merges two objects into a single combined object.
495
+ *
496
+ * This utility performs a deep merge operation, combining properties from a template object
497
+ * (default values) with a source object (user-provided values). The function handles nested
498
+ * objects, arrays, and preserves property descriptors. It supports different merge strategies
499
+ * for arrays and optional deep cloning to prevent mutation of original objects.
500
+ *
477
501
  * @example
502
+ * deepMerge({ name: 'John', age: 25 }, { age: 30, city: 'NYC' }) => { name: 'John', age: 30, city: 'NYC' }
478
503
  *
479
- * deepMerge({ name: 1 }, { test: 'test' }) => { name: 1, test: 'test' }
504
+ * @example
505
+ * deepMerge({ data: { x: 1 } }, { data: { y: 2 } }) => { data: { x: 1, y: 2 } }
480
506
  *
481
- * deepMerge({ x: [1, 2] }, { y: [3, 4] }) => { x: [1, 2], y: [3, 4] }
507
+ * @returns A new merged object combining properties from both template and source
508
+ *
509
+ * @remarks
510
+ * - Template object provides default values and structure
511
+ * - Source object values override template values for matching keys
512
+ * - Nested objects are recursively merged rather than replaced
513
+ * - Arrays can be merged or replaced based on mergeStrategy option
514
+ * - Property descriptors (getters, setters, etc.) are preserved
515
+ * - Deep cloning is enabled by default to prevent original object mutation
516
+ * - Non-plain objects in source will replace corresponding template values
517
+ * - Supports Symbol properties and maintains prototype relationships
482
518
  */
483
519
  declare function deepMerge(template: AnyObject, source: AnyObject, options?: DeepMergeOptions): any;
484
520
  interface DeepMergeOptions {
485
521
  /**
486
- * Enable deep cloning
522
+ * Controls whether to create deep clones of input objects before merging.
523
+ *
524
+ * When enabled, both template and source objects are deep cloned before the merge
525
+ * operation, ensuring the original objects remain unmodified. When disabled,
526
+ * the merge operates directly on the provided objects, which may result in mutation.
527
+ *
487
528
  * @default true
488
529
  */
489
530
  deepClone?: boolean;
490
531
  /**
491
- * Merge strategy for arrays
532
+ * Determines how arrays should be handled during the merge process.
533
+ *
534
+ * - 'merge': Concatenates arrays from template and source (template + source)
535
+ * - 'replace': Source array completely replaces the template array
536
+ *
537
+ * This only applies when both template and source have arrays at the same key.
538
+ * If only one side has an array, it will be used as-is regardless of strategy.
539
+ *
492
540
  * @default 'replace'
493
- * - 'merge': Merges the arrays
494
- * - 'replace': Replaces the array with the new one
495
541
  */
496
542
  mergeStrategy?: 'merge' | 'replace';
497
543
  }
498
544
 
545
+ declare class UtilsError extends Error {
546
+ constructor(m: string, name?: string);
547
+ }
499
548
  declare function throwError(scope: string, message: string): void;
500
549
  declare function debugWarn(err: Error): void;
501
550
  declare function debugWarn(scope: string, message: string): void;
@@ -520,9 +569,9 @@ declare global {
520
569
  }
521
570
 
522
571
  /**
523
- * 解析查询字符串
524
- * @param str 转换的字符串
525
- * @return 转换后的对象
572
+ * Parse query string
573
+ * @param str String to convert
574
+ * @return Converted object
526
575
  * @example
527
576
  *
528
577
  * parse('a=1&b=2') => { a: '1', b: '2' }
@@ -537,9 +586,9 @@ declare global {
537
586
  */
538
587
  declare function parse(str: string, options?: ParseOptions): Record<string, string>;
539
588
  /**
540
- * 转换对象为查询字符串
541
- * @param obj 转换的对象
542
- * @return 转换后的字符串
589
+ * Convert object to query string
590
+ * @param obj Object to convert
591
+ * @return Converted string
543
592
  * @example
544
593
  * stringify({ a: '1', b: '2' }) => 'a=1&b=2'
545
594
  * stringify({ from: '中国' }) => 'from=%E4%B8%AD%E5%9B%BD'
@@ -547,10 +596,10 @@ declare function parse(str: string, options?: ParseOptions): Record<string, stri
547
596
  */
548
597
  declare function stringify(obj: AnyObject, options?: StringifyOptions): string;
549
598
  /**
550
- * url追加查询字符串
599
+ * Append query string to URL
551
600
  * @param url url
552
- * @param obj 查询字符串对象
553
- * @return 追加后的url
601
+ * @param obj Query string object
602
+ * @return URL with appended query string
554
603
  * @example
555
604
  * appendQueryString('https://www.baidu.com', { a: '1', b: '2' }) => 'https://www.baidu.com?a=1&b=2'
556
605
  * appendQueryString('/pages/index?id=10', { test:'23' }) => '/pages/index?id=10&test=23'
@@ -563,74 +612,171 @@ declare const qs: {
563
612
  };
564
613
  interface ParseOptions {
565
614
  /**
566
- * 是否解码
615
+ * Whether to decode
567
616
  * @default true
568
617
  */
569
618
  decode?: boolean;
570
619
  }
571
620
  interface StringifyOptions {
572
621
  /**
573
- * 是否编码
622
+ * Whether to encode
574
623
  * @default true
575
624
  */
576
625
  encode?: boolean;
577
626
  }
578
627
 
579
628
  /**
580
- * 节流函数
581
- * @param target 目标函数
582
- * @param wait 等待时间 默认 500ms
629
+ * Throttle function
630
+ * @param target Target function
631
+ * @param wait Wait time, default 500ms
583
632
  * @example throttle(() => console.log('hello world'), 500)
584
633
  */
585
634
  declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
586
635
 
587
636
  /**
588
- * 校验中文、字母、数字
637
+ * Validates Chinese characters, letters, and digits
589
638
  */
590
639
  declare function validatorChineseOrEnglishOrNumber(value: string): boolean;
591
640
  /**
592
- * 校验中英文
641
+ * Validates Chinese characters and English letters
593
642
  */
594
643
  declare function validatorChineseOrEnglish(value: string): boolean;
595
644
  /**
596
- * 校验大写字母、数字、特殊字符 特殊字符包括 !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
645
+ * Validates uppercase letters, digits, and special characters including !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
597
646
  */
598
647
  declare function validatorUppercaseOrNumbersOrSpecial(value: string): boolean;
599
648
  /**
600
- * 校验大写字母、数字、_
649
+ * Validates uppercase letters, digits, and underscore
601
650
  */
602
651
  declare function validatorUppercaseOrNumbersOrUnderline(value: string): boolean;
603
652
 
604
653
  /**
605
- * 校验是否为数字
654
+ * Executes an asynchronous function with retry logic.
655
+ *
656
+ * This utility attempts to execute the provided async function (`fn`) up to a specified number of times (`maxAttempts`).
657
+ * If the function fails (throws or rejects), it will retry after a delay (`retryDelay`), optionally using exponential backoff.
658
+ * The operation can be cancelled early by providing an `AbortSignal`.
659
+ *
660
+ * @example
661
+ * // Basic usage with default settings
662
+ * withRetry({ fn: () => fetch('https://api.example.com/data') })
663
+ *
664
+ * @example
665
+ * // Advanced usage with all options
666
+ * const controller = new AbortController();
667
+ * withRetry({
668
+ * fn: () => fetch('https://api.example.com/data'),
669
+ * maxAttempts: 5,
670
+ * retryDelay: 2000,
671
+ * enableExponentialBackoff: true,
672
+ * signal: controller.signal
673
+ * })
674
+ *
675
+ * @example
676
+ * // With exponential backoff (delays: 1s, 2s, 4s, 8s...)
677
+ * withRetry({
678
+ * fn: () => apiCall(),
679
+ * maxAttempts: 4,
680
+ * retryDelay: 1000,
681
+ * enableExponentialBackoff: true
682
+ * })
683
+ *
684
+ * @returns Promise that resolves with the result of the successful function execution
685
+ *
686
+ * @throws {Error} When `options` is not a plain object
687
+ * @throws {Error} When `fn` is not a function that returns a Promise
688
+ * @throws {Error} When `maxAttempts` is not a positive integer
689
+ * @throws {Error} When `retryDelay` is not a non-negative number
690
+ * @throws {Error} When `enableExponentialBackoff` is not a boolean
691
+ * @throws {Error} When `signal` is not an AbortSignal object
692
+ * @throws {Error} "Operation Cancelled" when the operation is aborted via AbortSignal
693
+ * @throws {any} The original error from `fn` when all retry attempts are exhausted
694
+ *
695
+ * @remarks
696
+ * - Uses exponential backoff when enabled: delay × 2^(attempt-1)
697
+ * - Supports cancellation via AbortSignal at any point during execution
698
+ * - Logs retry attempts for debugging purposes
699
+ * - Validates all input parameters and throws descriptive errors
700
+ * - Cleans up event listeners to prevent memory leaks
701
+ * - Returns immediately on first successful execution
702
+ * - Preserves the original error when all retries fail
703
+ */
704
+ declare function withRetry<T>(options: WithRetryOptions<T>): Promise<T>;
705
+ interface WithRetryOptions<T> {
706
+ /**
707
+ * The asynchronous function to execute with retry logic.
708
+ *
709
+ * This function should return a Promise and will be called up to `maxAttempts` times
710
+ * if it fails. Each call should be idempotent as it may be executed multiple times.
711
+ */
712
+ fn: () => Promise<T>;
713
+ /**
714
+ * Maximum number of attempts before failing.
715
+ *
716
+ * Must be a positive integer. If the function fails this many times,
717
+ * the original error from the last attempt will be thrown.
718
+ *
719
+ * @default 3
720
+ */
721
+ maxAttempts?: number;
722
+ /**
723
+ * Delay in milliseconds before each retry.
724
+ *
725
+ * Must be a non-negative number. When `enableExponentialBackoff` is true,
726
+ * this serves as the base delay for exponential backoff calculation.
727
+ *
728
+ * @default 1000
729
+ */
730
+ retryDelay?: number;
731
+ /**
732
+ * Whether to use exponential backoff for delays.
733
+ *
734
+ * When enabled, the actual delay will be calculated as: `retryDelay × 2^(attempt-1)`.
735
+ * For example, with retryDelay=1000: 1s, 2s, 4s, 8s, etc.
736
+ *
737
+ * @default false
738
+ */
739
+ enableExponentialBackoff?: boolean;
740
+ /**
741
+ * Optional AbortSignal to cancel the retry operation early.
742
+ *
743
+ * When the signal is aborted, the operation will be cancelled immediately
744
+ * and an "Operation Cancelled" error will be thrown. The signal is checked
745
+ * before each attempt and during execution via Promise.race.
746
+ */
747
+ signal?: AbortSignal;
748
+ }
749
+
750
+ /**
751
+ * Validates if the value contains only digits
606
752
  */
607
753
  declare function isNumberOrNumberString(val: string): boolean;
608
754
  /**
609
- * 校验是否为英文字母
755
+ * Validates if the value contains only English letters
610
756
  */
611
757
  declare function isEnglishAphabet(val: string): boolean;
612
758
  /**
613
- * 校验是否为大写字母
759
+ * Validates if the value contains only uppercase letters
614
760
  */
615
761
  declare function isUpperCase(val: string): boolean;
616
762
  /**
617
- * 校验是否为大写字母和数字
763
+ * Validates if the value contains only uppercase letters and digits
618
764
  */
619
765
  declare function isUpperCaseAndNumber(val: string): boolean;
620
766
  /**
621
- * 校验是否为大写字母数字和中文
767
+ * Validates if the value contains only uppercase letters, digits and Chinese characters
622
768
  */
623
769
  declare function isUpperCaseAndNumberAndChinese(val: string): boolean;
624
770
  /**
625
- * 校验是否为小写字母
771
+ * Validates if the value contains only lowercase letters
626
772
  */
627
773
  declare function isLowerCase(val: string): boolean;
628
774
  /**
629
- * 校验是否为小写字母和数字
775
+ * Validates if the value contains only lowercase letters and digits
630
776
  */
631
777
  declare function isLowerCaseAndNumber(val: string): boolean;
632
778
  /**
633
- * 校验是否为小写字母数字和中文
779
+ * Validates if the value contains only lowercase letters, digits and Chinese characters
634
780
  */
635
781
  declare function isLowerCaseAndNumberAndChinese(val: string): boolean;
636
782
  /**
@@ -645,145 +791,279 @@ declare function isLowerCaseAndNumberAndChinese(val: string): boolean;
645
791
  declare function isChineseString(val: string): boolean;
646
792
 
647
793
  /**
648
- * Validates whether the value is a float.
794
+ * Validates whether a string represents a valid float number.
649
795
  *
650
- * @example
796
+ * This utility checks if the input string represents a valid float,
797
+ * including positive and negative decimal numbers. It uses strict validation
798
+ * that only accepts decimal float format with at least one digit after the decimal point.
651
799
  *
800
+ * @example
652
801
  * isFloat('1.23') => true
653
- *
654
802
  * isFloat('-4.56') => true
655
- *
656
803
  * isFloat('0.0') => true
657
804
  *
658
- * isFloat('7') => false
805
+ * @example
806
+ * isFloat('7') => false (integer)
807
+ * isFloat('1.') => false (no decimal digits)
808
+ * isFloat('abc') => false (non-numeric)
809
+ *
810
+ * @returns Returns `true` if the string is a valid float, `false` otherwise
811
+ *
812
+ * @remarks
813
+ * - Accepts positive floats (e.g., "1.23", "999.5")
814
+ * - Accepts negative floats (e.g., "-1.23", "-999.5")
815
+ * - Accepts zero with decimal point (e.g., "0.0", "-0.0")
816
+ * - Rejects integers without decimal point (e.g., "7", "-7")
817
+ * - Rejects numbers with no digits after decimal (e.g., "1.", "-2.")
818
+ * - Rejects non-numeric strings (e.g., "abc", "1.2a")
659
819
  */
660
820
  declare function isFloat(val: string): boolean;
661
821
  /**
662
- * Validates whether the value is a positive float.
822
+ * Validates whether a string represents a positive float (greater than zero).
663
823
  *
664
- * @example
824
+ * This utility checks if the input string represents a positive float,
825
+ * which excludes zero, negative numbers, and integers. It uses strict validation
826
+ * that only accepts decimal numbers greater than zero.
665
827
  *
828
+ * @example
666
829
  * isPositiveFloat('1.23') => true
830
+ * isPositiveFloat('0.1') => true
667
831
  *
668
- * isPositiveFloat('-4.56') => false
832
+ * @example
833
+ * isPositiveFloat('-4.56') => false (negative)
834
+ * isPositiveFloat('0.0') => false (zero)
835
+ * isPositiveFloat('7') => false (integer)
669
836
  *
670
- * isPositiveFloat('0.0') => false
837
+ * @returns Returns `true` if the string is a positive float, `false` otherwise
671
838
  *
672
- * isPositiveFloat('7') => false
839
+ * @remarks
840
+ * - Accepts only positive floats greater than zero (e.g., "1.23", "0.5")
841
+ * - Rejects zero with decimal point (e.g., "0.0", "0.00")
842
+ * - Rejects negative floats (e.g., "-1.23", "-0.5")
843
+ * - Rejects integers (e.g., "7", "-7")
844
+ * - Rejects non-numeric strings (e.g., "abc", "1.2a")
673
845
  */
674
846
  declare function isPositiveFloat(val: string): boolean;
675
847
  /**
676
- * Validates whether the value is a non-negative float.
848
+ * Validates whether a string represents a non-negative float (zero or greater).
677
849
  *
678
- * @example
850
+ * This utility checks if the input string represents a non-negative float,
851
+ * which includes zero and all positive decimal numbers. It excludes negative numbers
852
+ * and integers without decimal points.
679
853
  *
854
+ * @example
680
855
  * isNonNegativeFloat('1.23') => true
856
+ * isNonNegativeFloat('0.0') => true
681
857
  *
682
- * isNonNegativeFloat('-4.56') => false
858
+ * @example
859
+ * isNonNegativeFloat('-4.56') => false (negative)
860
+ * isNonNegativeFloat('7') => false (integer)
861
+ * isNonNegativeFloat('abc') => false (non-numeric)
683
862
  *
684
- * isNonNegativeFloat('0.0') => true
863
+ * @returns Returns `true` if the string is a non-negative float, `false` otherwise
685
864
  *
686
- * isNonNegativeFloat('7') => false
865
+ * @remarks
866
+ * - Accepts zero with decimal point (e.g., "0.0", "0.00")
867
+ * - Accepts positive floats (e.g., "1.23", "999.5")
868
+ * - Rejects negative floats (e.g., "-1.23", "-0.5")
869
+ * - Rejects integers without decimal point (e.g., "7", "0")
870
+ * - Rejects non-numeric strings (e.g., "abc", "1.2a")
687
871
  */
688
872
  declare function isNonNegativeFloat(val: string): boolean;
689
873
  /**
690
- * Validates whether the value is a negative float.
874
+ * Validates whether a string represents a negative float (less than zero).
691
875
  *
692
- * @example
693
- *
694
- * isNegativeFloat('1.23') => false
876
+ * This utility checks if the input string represents a negative float,
877
+ * which excludes zero, positive numbers, and integers. It uses strict validation
878
+ * that only accepts decimal numbers less than zero.
695
879
  *
880
+ * @example
696
881
  * isNegativeFloat('-4.56') => true
882
+ * isNegativeFloat('-0.1') => true
697
883
  *
698
- * isNegativeFloat('0.0') => false
884
+ * @example
885
+ * isNegativeFloat('1.23') => false (positive)
886
+ * isNegativeFloat('0.0') => false (zero)
887
+ * isNegativeFloat('-7') => false (integer)
888
+ *
889
+ * @returns Returns `true` if the string is a negative float, `false` otherwise
699
890
  *
700
- * isNegativeFloat('-7') => false
891
+ * @remarks
892
+ * - Accepts only negative floats less than zero (e.g., "-1.23", "-0.5")
893
+ * - Rejects zero with decimal point (e.g., "0.0", "-0.0")
894
+ * - Rejects positive floats (e.g., "1.23", "0.5")
895
+ * - Rejects integers (e.g., "-7", "7")
896
+ * - Rejects non-numeric strings (e.g., "abc", "-1.2a")
701
897
  */
702
898
  declare function isNegativeFloat(val: string): boolean;
703
899
  /**
704
- * Validates whether the value is a non-positive float.
900
+ * Validates whether a string represents a non-positive float (zero or less).
705
901
  *
706
- * @example
707
- *
708
- * isNonPositiveFloat('1.23') => false
902
+ * This utility checks if the input string represents a non-positive float,
903
+ * which includes zero and all negative decimal numbers. It excludes positive numbers
904
+ * and integers without decimal points.
709
905
  *
906
+ * @example
710
907
  * isNonPositiveFloat('-4.56') => true
711
- *
712
908
  * isNonPositiveFloat('0.0') => true
713
909
  *
714
- * isNonPositiveFloat('-7') => false
910
+ * @example
911
+ * isNonPositiveFloat('1.23') => false (positive)
912
+ * isNonPositiveFloat('-7') => false (integer)
913
+ * isNonPositiveFloat('abc') => false (non-numeric)
914
+ *
915
+ * @returns Returns `true` if the string is a non-positive float, `false` otherwise
916
+ *
917
+ * @remarks
918
+ * - Accepts zero with decimal point (e.g., "0.0", "-0.0")
919
+ * - Accepts negative floats (e.g., "-1.23", "-999.5")
920
+ * - Rejects positive floats (e.g., "1.23", "0.5")
921
+ * - Rejects integers without decimal point (e.g., "-7", "0")
922
+ * - Rejects non-numeric strings (e.g., "abc", "-1.2a")
715
923
  */
716
924
  declare function isNonPositiveFloat(val: string): boolean;
717
925
 
718
926
  /**
719
- * Validates whether the value is an integer.
927
+ * Validates whether a string represents a valid integer number.
928
+ *
929
+ * This utility checks if the input string represents a valid integer,
930
+ * including positive numbers, negative numbers, and zero. It uses strict validation
931
+ * that only accepts decimal integer format without leading zeros (except for "0" itself).
720
932
  *
721
933
  * @example
934
+ * isInteger('123') => true
935
+ * isInteger('-456') => true
936
+ * isInteger('0') => true
722
937
  *
723
- * isInteger('546') => true
938
+ * @example
939
+ * isInteger('12.5') => false (decimal)
940
+ * isInteger('01') => false (leading zero)
941
+ * isInteger('abc') => false (non-numeric)
724
942
  *
725
- * isInteger('-123') => true
943
+ * @returns Returns `true` if the string is a valid integer, `false` otherwise
726
944
  *
727
- * isInteger('45.5') => false
945
+ * @remarks
946
+ * - Accepts positive integers (e.g., "1", "123", "999")
947
+ * - Accepts negative integers (e.g., "-1", "-123", "-999")
948
+ * - Accepts zero as "0"
949
+ * - Rejects decimal numbers (e.g., "1.5", "-2.3")
950
+ * - Rejects numbers with leading zeros (e.g., "01", "-02")
951
+ * - Rejects non-numeric strings (e.g., "abc", "12a")
728
952
  */
729
953
  declare function isInteger(val: string): boolean;
730
954
  /**
731
- * Validates whether the value is a positive integer.
955
+ * Validates whether a string represents a positive integer (greater than zero).
732
956
  *
733
- * @example
957
+ * This utility checks if the input string represents a positive integer,
958
+ * which excludes zero, negative numbers, and decimal values. It uses strict validation
959
+ * that only accepts integers starting from 1 and above.
734
960
  *
961
+ * @example
735
962
  * isPositiveInteger('123') => true
963
+ * isPositiveInteger('999') => true
736
964
  *
737
- * isPositiveInteger('0') => false
965
+ * @example
966
+ * isPositiveInteger('0') => false (zero)
967
+ * isPositiveInteger('-1') => false (negative)
968
+ * isPositiveInteger('1.5') => false (decimal)
738
969
  *
739
- * isPositiveInteger('-45') => false
970
+ * @returns Returns `true` if the string is a positive integer, `false` otherwise
740
971
  *
741
- * isPositiveInteger('45.5') => false
972
+ * @remarks
973
+ * - Accepts only positive integers greater than zero (e.g., "1", "123", "999")
974
+ * - Rejects zero ("0")
975
+ * - Rejects negative integers (e.g., "-1", "-123")
976
+ * - Rejects decimal numbers (e.g., "1.5", "2.0")
977
+ * - Rejects numbers with leading zeros (e.g., "01", "02")
978
+ * - Rejects non-numeric strings (e.g., "abc", "12a")
742
979
  */
743
980
  declare function isPositiveInteger(val: string): boolean;
744
981
  /**
745
- * Validates whether the value is a non-negative integer.
982
+ * Validates whether a string represents a non-negative integer (zero or greater).
746
983
  *
747
- * @example
984
+ * This utility checks if the input string represents a non-negative integer,
985
+ * which includes zero and all positive integers. It excludes negative numbers and decimal
986
+ * values, and handles the special case of negative zero.
748
987
  *
988
+ * @example
749
989
  * isNonNegativeInteger('456') => true
750
- *
751
990
  * isNonNegativeInteger('0') => true
752
991
  *
753
- * isNonNegativeInteger('-1') => false
992
+ * @example
993
+ * isNonNegativeInteger('-1') => false (negative)
994
+ * isNonNegativeInteger('1.5') => false (decimal)
995
+ * isNonNegativeInteger('01') => false (leading zero)
996
+ *
997
+ * @returns Returns `true` if the string is a non-negative integer, `false` otherwise
754
998
  *
755
- * isNonNegativeInteger('45.5') => false
999
+ * @remarks
1000
+ * - Accepts zero ("0")
1001
+ * - Accepts positive integers (e.g., "1", "123", "999")
1002
+ * - Rejects negative integers (e.g., "-1", "-123")
1003
+ * - Rejects decimal numbers (e.g., "1.5", "-2.3")
1004
+ * - Rejects numbers with leading zeros (e.g., "01", "02")
1005
+ * - Handles negative zero (-0) correctly by rejecting it
1006
+ * - Rejects non-numeric strings (e.g., "abc", "12a")
756
1007
  */
757
1008
  declare function isNonNegativeInteger(val: string): boolean;
758
1009
  /**
759
- * Validates whether the value is a negative integer.
1010
+ * Validates whether a string represents a negative integer (less than zero).
760
1011
  *
761
- * @example
1012
+ * This utility checks if the input string represents a negative integer,
1013
+ * which excludes zero, positive numbers, and decimal values. It uses strict validation
1014
+ * that only accepts integers less than zero.
762
1015
  *
1016
+ * @example
763
1017
  * isNegativeInteger('-123') => true
1018
+ * isNegativeInteger('-1') => true
764
1019
  *
765
- * isNegativeInteger('123') => false
1020
+ * @example
1021
+ * isNegativeInteger('123') => false (positive)
1022
+ * isNegativeInteger('0') => false (zero)
1023
+ * isNegativeInteger('-1.5') => false (decimal)
766
1024
  *
767
- * isNegativeInteger('0') => false
1025
+ * @returns Returns `true` if the string is a negative integer, `false` otherwise
768
1026
  *
769
- * isNegativeInteger('-45.5') => false
1027
+ * @remarks
1028
+ * - Accepts only negative integers less than zero (e.g., "-1", "-123", "-999")
1029
+ * - Rejects zero ("0")
1030
+ * - Rejects positive integers (e.g., "1", "123")
1031
+ * - Rejects decimal numbers (e.g., "-1.5", "2.3")
1032
+ * - Rejects numbers with leading zeros (e.g., "-01", "-02")
1033
+ * - Rejects non-numeric strings (e.g., "abc", "-12a")
770
1034
  */
771
1035
  declare function isNegativeInteger(val: string): boolean;
772
1036
  /**
773
- * Validates whether the value is a non-positive integer.
1037
+ * Validates whether a string represents a non-positive integer (zero or less).
774
1038
  *
775
- * @example
1039
+ * This utility checks if the input string represents a non-positive integer,
1040
+ * which includes zero and all negative integers. It excludes positive numbers and decimal
1041
+ * values, and handles the special case of negative zero.
776
1042
  *
1043
+ * @example
777
1044
  * isNonPositiveInteger('-456') => true
778
- *
779
1045
  * isNonPositiveInteger('0') => true
780
1046
  *
781
- * isNonPositiveInteger('123') => false
1047
+ * @example
1048
+ * isNonPositiveInteger('123') => false (positive)
1049
+ * isNonPositiveInteger('1.5') => false (decimal)
1050
+ * isNonPositiveInteger('-01') => false (leading zero)
1051
+ *
1052
+ * @returns Returns `true` if the string is a non-positive integer, `false` otherwise
782
1053
  *
783
- * isNonPositiveInteger('-45.5') => false
1054
+ * @remarks
1055
+ * - Accepts zero ("0")
1056
+ * - Accepts negative integers (e.g., "-1", "-123", "-999")
1057
+ * - Rejects positive integers (e.g., "1", "123")
1058
+ * - Rejects decimal numbers (e.g., "-1.5", "2.3")
1059
+ * - Rejects numbers with leading zeros (e.g., "-01", "-02")
1060
+ * - Handles negative zero (-0) correctly by accepting it
1061
+ * - Rejects non-numeric strings (e.g., "abc", "-12a")
784
1062
  */
785
1063
  declare function isNonPositiveInteger(val: string): boolean;
786
1064
 
1065
+ declare const isStringNumber: (val: string) => boolean;
1066
+
787
1067
  /**
788
1068
  * Validates whether the value is a mobile phone number.
789
1069
  *
@@ -819,15 +1099,15 @@ declare function isEmail(val: string): boolean;
819
1099
  */
820
1100
  declare function isEmptyString(val: unknown): val is "";
821
1101
  /**
822
- * 校验是否为合法时间格式
823
- * @param format 时间格式
1102
+ * Validates if the value is a valid date string
1103
+ * @param format Date format
824
1104
  * @default 'YYYY-MM-DD HH:mm:ss'
825
1105
  * @see https://day.js.org/docs/zh-CN/parse/string-format
826
1106
  */
827
1107
  declare function isDateString(val: string, format?: string): boolean;
828
1108
  /**
829
- * 校验是否为二代身份证号
1109
+ * Validates if the value is a valid Chinese ID card number
830
1110
  */
831
1111
  declare function isIdCard(val: string): boolean;
832
1112
 
833
- export { type AnyObject, type ArrayItem, type Arrayable, type ParseOptions, type PlainObject, type StringNumber, type StringifyOptions, base64Decode, base64Encode, castArray, compose, composeRight, debounce, debugWarn, debugWarnInvalidTypeMessage, decimalToBinary, deepClone, deepMerge, deprecated, generateRandomArray, generateRandomColor, generateRandomDate, generateRandomEmail, generateRandomFloat, generateRandomIdCard, generateRandomMobilePhone, generateRandomStringFromSource, getRandomInt, getRandomItem, getRandomString, getRandomUrl, hasChanged, isArray, isBoolean, isChineseString, isDate, isDateString, isDef, isEmail, isEmptyString, isEnglishAphabet, isFloat, isFunction, isIdCard, isInteger, isLowerCase, isLowerCaseAndNumber, isLowerCaseAndNumberAndChinese, isMap, isMobilePhone, isNegativeFloat, isNegativeInteger, isNonNegativeFloat, isNonNegativeInteger, isNonPositiveFloat, isNonPositiveInteger, isNull, isNumber, isNumberOrNumberString, isObject, isObjectLike, isPlainObject, isPositiveFloat, isPositiveInteger, isPromise, isRegExp, isSet, isString, isSymbol, isURL, isUndef, isUndefined, isUpperCase, isUpperCaseAndNumber, isUpperCaseAndNumberAndChinese, objectToString, omit, pick, qs, throttle, throwError, throwErrorInvalidTypeMessage, toTypeString, toTypeValue, validatorChineseOrEnglish, validatorChineseOrEnglishOrNumber, validatorUppercaseOrNumbersOrSpecial, validatorUppercaseOrNumbersOrUnderline };
1113
+ export { type AnyObject, type ArrayItem, type Arrayable, type DeepMergeOptions, type ParseOptions, type PlainObject, type StringNumber, type StringifyOptions, UtilsError, type WithRetryOptions, base64Decode, base64Encode, castArray, compose, composeRight, debounce, debugWarn, debugWarnInvalidTypeMessage, decimalToBinary, deepClone, deepMerge, deprecated, generateRandomArray, generateRandomColor, generateRandomDate, generateRandomEmail, generateRandomFloat, generateRandomIdCard, generateRandomMobilePhone, generateRandomStringFromSource, getRandomInt, getRandomItem, getRandomString, getRandomUrl, hasChanged, isArray, isBoolean, isChineseString, isDate, isDateString, isDef, isEmail, isEmptyString, isEnglishAphabet, isFloat, isFunction, isIdCard, isInteger, isLowerCase, isLowerCaseAndNumber, isLowerCaseAndNumberAndChinese, isMap, isMobilePhone, isNegativeFloat, isNegativeInteger, isNonNegativeFloat, isNonNegativeInteger, isNonPositiveFloat, isNonPositiveInteger, isNull, isNumber, isNumberOrNumberString, isObject, isObjectLike, isPlainObject, isPositiveFloat, isPositiveInteger, isPromise, isRegExp, isSet, isString, isStringNumber, isSymbol, isURL, isUndef, isUndefined, isUpperCase, isUpperCaseAndNumber, isUpperCaseAndNumberAndChinese, objectToString, omit, pick, qs, throttle, throwError, throwErrorInvalidTypeMessage, toTypeString, toTypeValue, validatorChineseOrEnglish, validatorChineseOrEnglishOrNumber, validatorUppercaseOrNumbersOrSpecial, validatorUppercaseOrNumbersOrUnderline, withRetry };