@pawover/kit 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { n as TypeUtil, r as _defineProperty, t as StringUtil } from "./string-DCWqoW4P.js";
1
+ import { n as TypeUtil, r as _defineProperty, t as StringUtil } from "./string-C_OCj9Lg.js";
2
2
  //#region src/array/arrayUtil.ts
3
3
  /**
4
4
  * 数组工具类
@@ -311,17 +311,50 @@ _defineProperty(DateTimeUtil, "FORMAT", {
311
311
  * 环境检查工具类
312
312
  */
313
313
  var EnvUtil = class {
314
+ /**
315
+ * 检测是否处于浏览器环境
316
+ *
317
+ * @returns 是否为浏览器环境
318
+ * @example
319
+ * ```ts
320
+ * EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
321
+ * ```
322
+ */
314
323
  static isBrowser() {
315
324
  return this._isBrowser;
316
325
  }
326
+ /**
327
+ * 检测是否处于 Web Worker 环境
328
+ *
329
+ * @returns 是否为 Web Worker 环境
330
+ * @example
331
+ * ```ts
332
+ * EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
333
+ * ```
334
+ */
317
335
  static isWebWorker() {
318
336
  return this._isWebWorker;
319
337
  }
338
+ /**
339
+ * 检测是否处于 React Native 环境
340
+ *
341
+ * @returns 是否为 React Native 环境
342
+ * @example
343
+ * ```ts
344
+ * EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
345
+ * ```
346
+ */
320
347
  static isReactNative() {
321
348
  return this._isReactNative;
322
349
  }
323
350
  /**
324
351
  * 检查是否在 iframe 环境中
352
+ *
353
+ * @returns 是否在 iframe 中
354
+ * @example
355
+ * ```ts
356
+ * EnvUtil.isIframe(); // true: 当前页面在 iframe 中
357
+ * ```
325
358
  */
326
359
  static isIframe() {
327
360
  if (typeof window === "undefined") return false;
@@ -523,6 +556,7 @@ var FunctionUtil = class {
523
556
  * @throws TypeError 如果 args 为 null 或 undefined
524
557
  *
525
558
  * @example
559
+ * ```ts
526
560
  * // 遗留代码场景
527
561
  * function legacyFn(a: number, b: string) {
528
562
  * const argsArray = FunctionUtil.toArgs(arguments);
@@ -539,6 +573,7 @@ var FunctionUtil = class {
539
573
  * const rest = FunctionUtil.toArgs(arguments, 1);
540
574
  * // rest: unknown[],跳过第一个参数
541
575
  * }
576
+ * ```
542
577
  */
543
578
  static toArgs(args, start) {
544
579
  if (args === null) throw new TypeError(`function [toArgs] Expected parameter [args] to be a arguments object, got ${typeof args}`);
@@ -553,6 +588,7 @@ var FunctionUtil = class {
553
588
  * @returns 标准化的 Promise
554
589
  *
555
590
  * @example
591
+ * ```ts
556
592
  * // 同步函数
557
593
  * FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
558
594
  *
@@ -561,6 +597,7 @@ var FunctionUtil = class {
561
597
  *
562
598
  * // 异常处理
563
599
  * FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
600
+ * ```
564
601
  */
565
602
  static toPromise(fn) {
566
603
  try {
@@ -591,8 +628,38 @@ _defineProperty(MimeUtil, "MIME", {
591
628
  XML: "text/xml",
592
629
  /** XHTML 文档(XML 严格格式的 HTML) */
593
630
  XHTML: "application/xhtml+xml",
594
- /** JavaScript 脚本文件(标准推荐) */
631
+ /** JavaScript 文件 */
595
632
  JS: "text/javascript",
633
+ /** TypeScript 文件 */
634
+ TS: "text/typescript",
635
+ /** Python 文件 */
636
+ PY: "text/x-python",
637
+ /** Shell 脚本 (.sh) */
638
+ SH: "text/x-sh",
639
+ /** C 语言源文件 */
640
+ C: "text/x-c",
641
+ /** C++ 源文件 */
642
+ CPP: "text/x-c++",
643
+ /** C# 源文件 */
644
+ CSHARP: "text/x-csharp",
645
+ /** Java 源文件 */
646
+ JAVA: "text/x-java",
647
+ /** Go 源文件 */
648
+ GO: "text/x-go",
649
+ /** Rust 源文件 */
650
+ RUST: "text/x-rust",
651
+ /** PHP 文件 */
652
+ PHP: "text/x-php",
653
+ /** Ruby 文件 */
654
+ RUBY: "text/x-ruby",
655
+ /** Swift 源文件 */
656
+ SWIFT: "text/x-swift",
657
+ /** YAML 文档 */
658
+ YAML: "text/vnd.yaml",
659
+ /** TOML 文档 */
660
+ TOML: "text/x-toml",
661
+ /** SQL 脚本 */
662
+ SQL: "text/x-sql",
596
663
  /** Markdown 格式文档 */
597
664
  MARKDOWN: "text/markdown",
598
665
  /** 富文本格式文档(.rtf) */
@@ -617,6 +684,12 @@ _defineProperty(MimeUtil, "MIME", {
617
684
  ICO: "image/vnd.microsoft.icon",
618
685
  /** WebP 图像(高效压缩) */
619
686
  WEBP: "image/webp",
687
+ /** TIFF 图像(.tif/.tiff) */
688
+ TIFF: "image/tiff",
689
+ /** HEIC 图像(高效编码) */
690
+ HEIC: "image/heic",
691
+ /** Adobe Photoshop 文件(.psd) */
692
+ PSD: "image/vnd.adobe.photoshop",
620
693
  /** MP3 音频(.mp3) */
621
694
  MP3: "audio/mpeg",
622
695
  /** AAC 音频(.aac) */
@@ -685,6 +758,8 @@ _defineProperty(MimeUtil, "MIME", {
685
758
  BZIP2: "application/x-bzip2",
686
759
  /** 7-Zip 压缩文件(.7z) */
687
760
  SEVEN_Z: "application/x-7z-compressed",
761
+ /** RAR 压缩文件(.rar) */
762
+ RAR: "application/vnd.rar",
688
763
  /** 通用二进制数据(默认类型) */
689
764
  OCTET_STREAM: "application/octet-stream",
690
765
  /** JSON 数据格式(.json) */
@@ -693,10 +768,18 @@ _defineProperty(MimeUtil, "MIME", {
693
768
  LD_JSON: "application/ld+json",
694
769
  /** Java 归档文件(.jar) */
695
770
  JAR: "application/java-archive",
771
+ /** WebAssembly 二进制指令格式(.wasm) */
772
+ WASM: "application/wasm",
696
773
  /** MS 嵌入式 OpenType 字体(.eot) */
697
774
  EOT: "application/vnd.ms-fontobject",
698
775
  /** OpenType 字体(.otf) */
699
776
  OTF: "font/otf",
777
+ /** WOFF 字体(.woff) */
778
+ WOFF: "font/woff",
779
+ /** WOFF2 字体(.woff2) */
780
+ WOFF2: "font/woff2",
781
+ /** TrueType 字体(.ttf) */
782
+ TTF: "font/ttf",
700
783
  /** Excel 97-2003 工作簿(.xls) */
701
784
  XLS: "application/vnd.ms-excel",
702
785
  /** Microsoft XPS 文档(.xps) */
@@ -760,7 +843,10 @@ var ObjectUtil = class {
760
843
  * @example
761
844
  * ```ts
762
845
  * const obj = { a: 1, b: 2 };
846
+ *
763
847
  * ObjectUtil.entriesMap(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
848
+ *
849
+ * ObjectUtil.entriesMap(obj, (k, v) => [`prefix_${String(k)}`, `${v}x`]); // { prefix_a: "1x", prefix_b: "2x" }
764
850
  * ```
765
851
  */
766
852
  static entriesMap(plainObject, toEntry) {
@@ -1301,192 +1387,320 @@ var TreeUtil = class {
1301
1387
  var ValidateUtil = class {
1302
1388
  /**
1303
1389
  * 验证是否为手机号码
1390
+ * @example
1391
+ * ```ts
1392
+ * ValidateUtil.isPhone("13800138000"); // true
1393
+ * ```
1304
1394
  */
1305
1395
  static isPhone(input) {
1306
1396
  return this._phone.test(input.toString());
1307
1397
  }
1308
1398
  /**
1309
1399
  * 验证是否为固定电话
1400
+ * @example
1401
+ * ```ts
1402
+ * ValidateUtil.isTelephone("010-12345678"); // true
1403
+ * ```
1310
1404
  */
1311
1405
  static isTelephone(input) {
1312
1406
  return this._telephone.test(input.toString());
1313
1407
  }
1314
1408
  /**
1315
1409
  * 验证是否为移动设备识别码
1410
+ * @example
1411
+ * ```ts
1412
+ * ValidateUtil.isIMEI("490154203237518"); // true
1413
+ * ```
1316
1414
  */
1317
1415
  static isIMEI(input) {
1318
1416
  return this._IMEI.test(input.toString());
1319
1417
  }
1320
1418
  /**
1321
1419
  * 验证是否为电子邮箱
1420
+ * @example
1421
+ * ```ts
1422
+ * ValidateUtil.isEmail("dev@example.com"); // true
1423
+ * ```
1322
1424
  */
1323
1425
  static isEmail(input) {
1324
1426
  return this._email.test(input.toString());
1325
1427
  }
1326
1428
  /**
1327
1429
  * 验证是否为 http(s) 链接
1430
+ * @example
1431
+ * ```ts
1432
+ * ValidateUtil.isHttpLink("https://example.com/path"); // true
1433
+ * ```
1328
1434
  */
1329
1435
  static isHttpLink(input) {
1330
1436
  return this._link.test(input.toString());
1331
1437
  }
1332
1438
  /**
1333
1439
  * 验证是否为端口号链接
1440
+ * @example
1441
+ * ```ts
1442
+ * ValidateUtil.isPortLink("http://example.com:8080"); // true
1443
+ * ```
1334
1444
  */
1335
1445
  static isPortLink(input) {
1336
1446
  return this._portLink.test(input.toString());
1337
1447
  }
1338
1448
  /**
1339
1449
  * 验证是否为迅雷链接
1450
+ * @example
1451
+ * ```ts
1452
+ * ValidateUtil.isThunderLink("thunder://QUFodHRwOi8vZXhhbXBsZS5jb20vZmlsZQ=="); // true
1453
+ * ```
1340
1454
  */
1341
1455
  static isThunderLink(input) {
1342
1456
  return this._thunderLink.test(input.toString());
1343
1457
  }
1344
1458
  /**
1345
1459
  * 验证是否为统一社会信用代码
1460
+ * @example
1461
+ * ```ts
1462
+ * ValidateUtil.isUSCC("91350100M000100Y43"); // true
1463
+ * ```
1346
1464
  */
1347
1465
  static isUSCC(input) {
1348
1466
  return this._uscc.test(input.toString());
1349
1467
  }
1350
1468
  /**
1351
1469
  * 验证是否为统一社会信用代码 - 15位/18位/20位数字/字母
1470
+ * @example
1471
+ * ```ts
1472
+ * ValidateUtil.isUSCCS("91350100M000100Y43"); // true
1473
+ * ```
1352
1474
  */
1353
1475
  static isUSCCS(input) {
1354
1476
  return this._usccs.test(input.toString());
1355
1477
  }
1356
1478
  /**
1357
1479
  * 验证是否为 Windows 系统文件夹路径
1480
+ * @example
1481
+ * ```ts
1482
+ * ValidateUtil.isDirPathWindows("C:\\Users\\pawover\\"); // true
1483
+ * ```
1358
1484
  */
1359
1485
  static isDirPathWindows(input) {
1360
1486
  return this._dirPathWindows.test(input.toString());
1361
1487
  }
1362
1488
  /**
1363
1489
  * 验证是否为 Windows 系统文件路径
1490
+ * @example
1491
+ * ```ts
1492
+ * ValidateUtil.isFilePathWindows("C:\\Users\\pawover\\a.txt"); // true
1493
+ * ```
1364
1494
  */
1365
1495
  static isFilePathWindows(input) {
1366
1496
  return this._filePathWindows.test(input.toString());
1367
1497
  }
1368
1498
  /**
1369
1499
  * 验证是否为 Linux 系统文件夹路径
1500
+ * @example
1501
+ * ```ts
1502
+ * ValidateUtil.isDirPathLinux("/usr/local/"); // true
1503
+ * ```
1370
1504
  */
1371
1505
  static isDirPathLinux(input) {
1372
1506
  return this._dirPathLinux.test(input.toString());
1373
1507
  }
1374
1508
  /**
1375
1509
  * 验证是否为 Linux 系统文件路径
1510
+ * @example
1511
+ * ```ts
1512
+ * ValidateUtil.isFilePathLinux("/usr/local/bin/node"); // true
1513
+ * ```
1376
1514
  */
1377
1515
  static isFilePathLinux(input) {
1378
1516
  return this._filePathLinux.test(input.toString());
1379
1517
  }
1380
1518
  /**
1381
1519
  * 验证是否为新能源车牌号
1520
+ * @example
1521
+ * ```ts
1522
+ * ValidateUtil.isEVCarNumber("粤AD12345"); // true
1523
+ * ```
1382
1524
  */
1383
1525
  static isEVCarNumber(input) {
1384
1526
  return this._EVCarNumber.test(input.toString());
1385
1527
  }
1386
1528
  /**
1387
1529
  * 验证是否为燃油车车牌号
1530
+ * @example
1531
+ * ```ts
1532
+ * ValidateUtil.isGVCarNumber("粤B12345"); // true
1533
+ * ```
1388
1534
  */
1389
1535
  static isGVCarNumber(input) {
1390
1536
  return this._GVCarNumber.test(input.toString());
1391
1537
  }
1392
1538
  /**
1393
1539
  * 验证是否为中文姓名
1540
+ * @example
1541
+ * ```ts
1542
+ * ValidateUtil.isChineseName("张三"); // true
1543
+ * ```
1394
1544
  */
1395
1545
  static isChineseName(input) {
1396
1546
  return this._chineseName.test(input.toString());
1397
1547
  }
1398
1548
  /**
1399
1549
  * 验证是否为中国身份证号
1550
+ * @example
1551
+ * ```ts
1552
+ * ValidateUtil.isChineseID("11010519491231002X"); // true
1553
+ * ```
1400
1554
  */
1401
1555
  static isChineseID(input) {
1402
1556
  return this._chineseId.test(input.toString());
1403
1557
  }
1404
1558
  /**
1405
1559
  * 验证是否为中国省份
1560
+ * @example
1561
+ * ```ts
1562
+ * ValidateUtil.isChineseProvince("浙江"); // true
1563
+ * ```
1406
1564
  */
1407
1565
  static isChineseProvince(input) {
1408
1566
  return this._chineseProvince.test(input.toString());
1409
1567
  }
1410
1568
  /**
1411
1569
  * 验证是否为中华民族
1570
+ * @example
1571
+ * ```ts
1572
+ * ValidateUtil.isChineseNation("汉族"); // true
1573
+ * ```
1412
1574
  */
1413
1575
  static isChineseNation(input) {
1414
1576
  return this._chineseNation.test(input.toString());
1415
1577
  }
1416
1578
  /**
1417
1579
  * 验证是否只包含字母
1580
+ * @example
1581
+ * ```ts
1582
+ * ValidateUtil.isLetter("abcDEF"); // true
1583
+ * ```
1418
1584
  */
1419
1585
  static isLetter(input) {
1420
1586
  return this._letter.test(input.toString());
1421
1587
  }
1422
1588
  /**
1423
1589
  * 验证是否只包含小写字母
1590
+ * @example
1591
+ * ```ts
1592
+ * ValidateUtil.isLetterLowercase("abc"); // true
1593
+ * ```
1424
1594
  */
1425
1595
  static isLetterLowercase(input) {
1426
1596
  return this._letterLowercase.test(input.toString());
1427
1597
  }
1428
1598
  /**
1429
1599
  * 验证是否只包含大写字母
1600
+ * @example
1601
+ * ```ts
1602
+ * ValidateUtil.isLetterUppercase("ABC"); // true
1603
+ * ```
1430
1604
  */
1431
1605
  static isLetterUppercase(input) {
1432
1606
  return this._letterUppercase.test(input.toString());
1433
1607
  }
1434
1608
  /**
1435
1609
  * 验证是否不包含字母
1610
+ * @example
1611
+ * ```ts
1612
+ * ValidateUtil.isLetterOmit("123_-"); // true
1613
+ * ```
1436
1614
  */
1437
1615
  static isLetterOmit(input) {
1438
1616
  return this._letterOmit.test(input.toString());
1439
1617
  }
1440
1618
  /**
1441
1619
  * 验证是否为数字和字母组合
1620
+ * @example
1621
+ * ```ts
1622
+ * ValidateUtil.isLetterAndNumber("A1B2"); // true
1623
+ * ```
1442
1624
  */
1443
1625
  static isLetterAndNumber(input) {
1444
1626
  return this._LetterAndNumber.test(input.toString());
1445
1627
  }
1446
1628
  /**
1447
1629
  * 验证是否为有符号浮点数
1630
+ * @example
1631
+ * ```ts
1632
+ * ValidateUtil.isSignedFloat("-12.34"); // true
1633
+ * ```
1448
1634
  */
1449
1635
  static isSignedFloat(input) {
1450
1636
  return this._signedFloat.test(input.toString());
1451
1637
  }
1452
1638
  /**
1453
1639
  * 验证是否为无符号浮点数
1640
+ * @example
1641
+ * ```ts
1642
+ * ValidateUtil.isUnsignedFloat("12.34"); // true
1643
+ * ```
1454
1644
  */
1455
1645
  static isUnsignedFloat(input) {
1456
1646
  return this._unsignedFloat.test(input.toString());
1457
1647
  }
1458
1648
  /**
1459
1649
  * 验证是否为有符号整数
1650
+ * @example
1651
+ * ```ts
1652
+ * ValidateUtil.isSignedInteger("-12"); // true
1653
+ * ```
1460
1654
  */
1461
1655
  static isSignedInteger(input) {
1462
1656
  return this._signedInteger.test(input.toString());
1463
1657
  }
1464
1658
  /**
1465
1659
  * 验证是否为无符号整数
1660
+ * @example
1661
+ * ```ts
1662
+ * ValidateUtil.isUnsignedInteger("12"); // true
1663
+ * ```
1466
1664
  */
1467
1665
  static isUnsignedInteger(input) {
1468
1666
  return this._unsignedInteger.test(input.toString());
1469
1667
  }
1470
1668
  /**
1471
1669
  * 验证是否包含空格
1670
+ * @example
1671
+ * ```ts
1672
+ * ValidateUtil.isSpaceInclude("a b"); // true
1673
+ * ```
1472
1674
  */
1473
1675
  static isSpaceInclude(input) {
1474
1676
  return this._spaceInclude.test(input.toString());
1475
1677
  }
1476
1678
  /**
1477
1679
  * 验证是否以空格开头
1680
+ * @example
1681
+ * ```ts
1682
+ * ValidateUtil.isSpaceStart(" abc"); // true
1683
+ * ```
1478
1684
  */
1479
1685
  static isSpaceStart(input) {
1480
1686
  return this._spaceStart.test(input.toString());
1481
1687
  }
1482
1688
  /**
1483
1689
  * 验证是否以空格结尾
1690
+ * @example
1691
+ * ```ts
1692
+ * ValidateUtil.isSpaceEnd("abc "); // true
1693
+ * ```
1484
1694
  */
1485
1695
  static isSpaceEnd(input) {
1486
1696
  return this._spaceEnd.test(input.toString());
1487
1697
  }
1488
1698
  /**
1489
1699
  * 验证是否以空格开头或结尾
1700
+ * @example
1701
+ * ```ts
1702
+ * ValidateUtil.isSpaceStartOrEnd(" abc"); // true
1703
+ * ```
1490
1704
  */
1491
1705
  static isSpaceStartOrEnd(input) {
1492
1706
  return this.isSpaceStart(input) || this.isSpaceEnd(input);
@@ -31,7 +31,11 @@ declare class MathUtil {
31
31
  * @returns 格式化后的字符串或 BigNumber
32
32
  * @example
33
33
  * ```ts
34
+ * // 重载 1: isFormat = true (默认)
34
35
  * MathUtil.toDecimal(math, 0.12345, 2); // "0.12"
36
+ *
37
+ * // 重载 2: isFormat = false
38
+ * MathUtil.toDecimal(math, 0.12345, 2, false); // BigNumber(0.12345)
35
39
  * ```
36
40
  */
37
41
  static toDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: true | undefined): string;
@@ -1,4 +1,4 @@
1
- import { n as TypeUtil, t as StringUtil } from "./string-DCWqoW4P.js";
1
+ import { n as TypeUtil, t as StringUtil } from "./string-C_OCj9Lg.js";
2
2
  //#region src/math/mathUtil.ts
3
3
  /**
4
4
  * 数学工具类