@whitesev/utils 1.3.1 → 1.3.2

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.
@@ -1522,6 +1522,7 @@ declare class Utils {
1522
1522
  * console.log($div); // div => HTMLDivELement
1523
1523
  * })
1524
1524
  */
1525
+ waitNode<K extends keyof HTMLElementTagNameMap>(selector: K, parent?: Node | Element | Document | HTMLElement): Promise<HTMLElementTagNameMap[K]>;
1525
1526
  waitNode<T extends Element>(selector: string, parent?: Node | Element | Document | HTMLElement): Promise<T>;
1526
1527
  /**
1527
1528
  * 等待元素出现
@@ -1535,6 +1536,7 @@ declare class Utils {
1535
1536
  * console.log($div); // div => HTMLDivELement[]
1536
1537
  * })
1537
1538
  */
1539
+ waitNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise<HTMLElementTagNameMap[K][]>;
1538
1540
  waitNode<T extends Element[]>(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise<T>;
1539
1541
  /**
1540
1542
  * 等待元素出现
@@ -1546,6 +1548,7 @@ declare class Utils {
1546
1548
  * console.log($div); // $div => HTMLDivELement | null
1547
1549
  * })
1548
1550
  */
1551
+ waitNode<K extends keyof HTMLElementTagNameMap>(selector: K, parent: Node | Element | Document | HTMLElement, timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1549
1552
  waitNode<T extends Element>(selector: string, parent: Node | Element | Document | HTMLElement, timeout: number): Promise<T | null>;
1550
1553
  /**
1551
1554
  * 等待元素出现
@@ -1557,6 +1560,7 @@ declare class Utils {
1557
1560
  * console.log($div); // $div => HTMLDivELement[] | null
1558
1561
  * })
1559
1562
  */
1563
+ waitNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1560
1564
  waitNode<T extends Element[]>(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<T | null>;
1561
1565
  /**
1562
1566
  * 等待元素出现
@@ -1567,6 +1571,7 @@ declare class Utils {
1567
1571
  * console.log($div); // $div => HTMLDivELement | null
1568
1572
  * })
1569
1573
  */
1574
+ waitNode<K extends keyof HTMLElementTagNameMap>(selector: K, timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1570
1575
  waitNode<T extends Element>(selector: string, timeout: number): Promise<T | null>;
1571
1576
  /**
1572
1577
  * 等待元素出现
@@ -1577,6 +1582,7 @@ declare class Utils {
1577
1582
  * console.log($div); // $div => HTMLDivELement[] | null
1578
1583
  * })
1579
1584
  */
1585
+ waitNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1580
1586
  waitNode<T extends Element[]>(selectorList: string[], timeout: number): Promise<T | null>;
1581
1587
  /**
1582
1588
  * 等待任意元素出现
@@ -1590,6 +1596,7 @@ declare class Utils {
1590
1596
  * console.log($a); // $a => HTMLAnchorElement 这里是第一个
1591
1597
  * })
1592
1598
  */
1599
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise<HTMLElementTagNameMap[K]>;
1593
1600
  waitAnyNode<T extends Element>(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise<T>;
1594
1601
  /**
1595
1602
  * 等待任意元素出现
@@ -1601,6 +1608,7 @@ declare class Utils {
1601
1608
  * console.log($div); // $div => HTMLDivELement | null
1602
1609
  * })
1603
1610
  */
1611
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1604
1612
  waitAnyNode<T extends Element>(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<T | null>;
1605
1613
  /**
1606
1614
  * 等待任意元素出现
@@ -1611,6 +1619,7 @@ declare class Utils {
1611
1619
  * console.log($div); // $div => HTMLDivELement | null
1612
1620
  * })
1613
1621
  */
1622
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(selectorList: K[], timeout: number): Promise<HTMLElementTagNameMap[K] | null>;
1614
1623
  waitAnyNode<T extends Element>(selectorList: string[], timeout: number): Promise<T | null>;
1615
1624
  /**
1616
1625
  * 等待元素数组出现
@@ -1624,6 +1633,7 @@ declare class Utils {
1624
1633
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
1625
1634
  * })
1626
1635
  */
1636
+ waitNodeList<T extends keyof HTMLElementTagNameMap>(selector: T, parent?: Node | Element | Document | HTMLElement): Promise<NodeListOf<HTMLElementTagNameMap[T]>>;
1627
1637
  waitNodeList<T extends NodeListOf<Element>>(selector: string, parent?: Node | Element | Document | HTMLElement): Promise<T>;
1628
1638
  /**
1629
1639
  * 等待元素数组出现
@@ -1637,6 +1647,7 @@ declare class Utils {
1637
1647
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[]
1638
1648
  * })
1639
1649
  */
1650
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise<NodeListOf<HTMLElementTagNameMap[K]>[]>;
1640
1651
  waitNodeList<T extends NodeListOf<Element>[]>(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise<T>;
1641
1652
  /**
1642
1653
  * 等待元素数组出现
@@ -1649,6 +1660,7 @@ declare class Utils {
1649
1660
  * })
1650
1661
  */
1651
1662
  waitNodeList<T extends NodeListOf<Element>>(selector: string, parent: Node | Element | Document | HTMLElement, timeout: number): Promise<T | null>;
1663
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(selector: K, parent: Node | Element | Document | HTMLElement, timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
1652
1664
  /**
1653
1665
  * 等待元素数组出现
1654
1666
  * @param selectorList CSS选择器数组
@@ -1659,6 +1671,7 @@ declare class Utils {
1659
1671
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
1660
1672
  * })
1661
1673
  */
1674
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
1662
1675
  waitNodeList<T extends NodeListOf<Element>[]>(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<T | null>;
1663
1676
  /**
1664
1677
  * 等待元素数组出现
@@ -1669,6 +1682,7 @@ declare class Utils {
1669
1682
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
1670
1683
  * })
1671
1684
  */
1685
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(selector: K[], timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
1672
1686
  waitNodeList<T extends NodeListOf<Element>>(selector: string[], timeout: number): Promise<T | null>;
1673
1687
  /**
1674
1688
  * 等待元素数组出现
@@ -1679,6 +1693,7 @@ declare class Utils {
1679
1693
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
1680
1694
  * })
1681
1695
  */
1696
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
1682
1697
  waitNodeList<T extends NodeListOf<Element>>(selectorList: string[], timeout: number): Promise<T[] | null>;
1683
1698
  /**
1684
1699
  * 等待任意元素数组出现
@@ -1692,6 +1707,7 @@ declare class Utils {
1692
1707
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
1693
1708
  * })
1694
1709
  */
1710
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise<NodeListOf<HTMLElementTagNameMap[K]>>;
1695
1711
  waitAnyNodeList<T extends Element>(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise<NodeListOf<T>>;
1696
1712
  /**
1697
1713
  * 等待任意元素数组出现
@@ -1703,6 +1719,7 @@ declare class Utils {
1703
1719
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
1704
1720
  * })
1705
1721
  */
1722
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
1706
1723
  waitAnyNodeList<T extends Element>(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise<NodeListOf<T> | null>;
1707
1724
  /**
1708
1725
  * 等待任意元素出现
@@ -1713,6 +1730,7 @@ declare class Utils {
1713
1730
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
1714
1731
  * })
1715
1732
  */
1733
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(selectorList: K[], timeout: number): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
1716
1734
  waitAnyNodeList<T extends Element>(selectorList: string[], timeout: number): Promise<NodeListOf<T> | null>;
1717
1735
  /**
1718
1736
  * 等待对象上的属性出现
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
package/src/Utils.ts CHANGED
@@ -3998,6 +3998,10 @@ class Utils {
3998
3998
  * console.log($div); // div => HTMLDivELement
3999
3999
  * })
4000
4000
  */
4001
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4002
+ selector: K,
4003
+ parent?: Node | Element | Document | HTMLElement
4004
+ ): Promise<HTMLElementTagNameMap[K]>;
4001
4005
  waitNode<T extends Element>(
4002
4006
  selector: string,
4003
4007
  parent?: Node | Element | Document | HTMLElement
@@ -4014,6 +4018,10 @@ class Utils {
4014
4018
  * console.log($div); // div => HTMLDivELement[]
4015
4019
  * })
4016
4020
  */
4021
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4022
+ selectorList: K[],
4023
+ parent?: Node | Element | Document | HTMLElement
4024
+ ): Promise<HTMLElementTagNameMap[K][]>;
4017
4025
  waitNode<T extends Element[]>(
4018
4026
  selectorList: string[],
4019
4027
  parent?: Node | Element | Document | HTMLElement
@@ -4028,6 +4036,11 @@ class Utils {
4028
4036
  * console.log($div); // $div => HTMLDivELement | null
4029
4037
  * })
4030
4038
  */
4039
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4040
+ selector: K,
4041
+ parent: Node | Element | Document | HTMLElement,
4042
+ timeout: number
4043
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4031
4044
  waitNode<T extends Element>(
4032
4045
  selector: string,
4033
4046
  parent: Node | Element | Document | HTMLElement,
@@ -4043,6 +4056,11 @@ class Utils {
4043
4056
  * console.log($div); // $div => HTMLDivELement[] | null
4044
4057
  * })
4045
4058
  */
4059
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4060
+ selectorList: K[],
4061
+ parent: Node | Element | Document | HTMLElement,
4062
+ timeout: number
4063
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4046
4064
  waitNode<T extends Element[]>(
4047
4065
  selectorList: string[],
4048
4066
  parent: Node | Element | Document | HTMLElement,
@@ -4057,6 +4075,10 @@ class Utils {
4057
4075
  * console.log($div); // $div => HTMLDivELement | null
4058
4076
  * })
4059
4077
  */
4078
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4079
+ selector: K,
4080
+ timeout: number
4081
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4060
4082
  waitNode<T extends Element>(
4061
4083
  selector: string,
4062
4084
  timeout: number
@@ -4070,6 +4092,10 @@ class Utils {
4070
4092
  * console.log($div); // $div => HTMLDivELement[] | null
4071
4093
  * })
4072
4094
  */
4095
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4096
+ selectorList: K[],
4097
+ timeout: number
4098
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4073
4099
  waitNode<T extends Element[]>(
4074
4100
  selectorList: string[],
4075
4101
  timeout: number
@@ -4181,6 +4207,10 @@ class Utils {
4181
4207
  * console.log($a); // $a => HTMLAnchorElement 这里是第一个
4182
4208
  * })
4183
4209
  */
4210
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4211
+ selectorList: K[],
4212
+ parent?: Node | Element | Document | HTMLElement
4213
+ ): Promise<HTMLElementTagNameMap[K]>;
4184
4214
  waitAnyNode<T extends Element>(
4185
4215
  selectorList: string[],
4186
4216
  parent?: Node | Element | Document | HTMLElement
@@ -4195,6 +4225,11 @@ class Utils {
4195
4225
  * console.log($div); // $div => HTMLDivELement | null
4196
4226
  * })
4197
4227
  */
4228
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4229
+ selectorList: K[],
4230
+ parent: Node | Element | Document | HTMLElement,
4231
+ timeout: number
4232
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4198
4233
  waitAnyNode<T extends Element>(
4199
4234
  selectorList: string[],
4200
4235
  parent: Node | Element | Document | HTMLElement,
@@ -4209,6 +4244,10 @@ class Utils {
4209
4244
  * console.log($div); // $div => HTMLDivELement | null
4210
4245
  * })
4211
4246
  */
4247
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4248
+ selectorList: K[],
4249
+ timeout: number
4250
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4212
4251
  waitAnyNode<T extends Element>(
4213
4252
  selectorList: string[],
4214
4253
  timeout: number
@@ -4279,6 +4318,10 @@ class Utils {
4279
4318
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
4280
4319
  * })
4281
4320
  */
4321
+ waitNodeList<T extends keyof HTMLElementTagNameMap>(
4322
+ selector: T,
4323
+ parent?: Node | Element | Document | HTMLElement
4324
+ ): Promise<NodeListOf<HTMLElementTagNameMap[T]>>;
4282
4325
  waitNodeList<T extends NodeListOf<Element>>(
4283
4326
  selector: string,
4284
4327
  parent?: Node | Element | Document | HTMLElement
@@ -4295,6 +4338,10 @@ class Utils {
4295
4338
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[]
4296
4339
  * })
4297
4340
  */
4341
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4342
+ selectorList: K[],
4343
+ parent?: Node | Element | Document | HTMLElement
4344
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[]>;
4298
4345
  waitNodeList<T extends NodeListOf<Element>[]>(
4299
4346
  selectorList: string[],
4300
4347
  parent?: Node | Element | Document | HTMLElement
@@ -4314,6 +4361,11 @@ class Utils {
4314
4361
  parent: Node | Element | Document | HTMLElement,
4315
4362
  timeout: number
4316
4363
  ): Promise<T | null>;
4364
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4365
+ selector: K,
4366
+ parent: Node | Element | Document | HTMLElement,
4367
+ timeout: number
4368
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4317
4369
  /**
4318
4370
  * 等待元素数组出现
4319
4371
  * @param selectorList CSS选择器数组
@@ -4324,6 +4376,11 @@ class Utils {
4324
4376
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
4325
4377
  * })
4326
4378
  */
4379
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4380
+ selectorList: K[],
4381
+ parent: Node | Element | Document | HTMLElement,
4382
+ timeout: number
4383
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
4327
4384
  waitNodeList<T extends NodeListOf<Element>[]>(
4328
4385
  selectorList: string[],
4329
4386
  parent: Node | Element | Document | HTMLElement,
@@ -4338,6 +4395,10 @@ class Utils {
4338
4395
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4339
4396
  * })
4340
4397
  */
4398
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4399
+ selector: K[],
4400
+ timeout: number
4401
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4341
4402
  waitNodeList<T extends NodeListOf<Element>>(
4342
4403
  selector: string[],
4343
4404
  timeout: number
@@ -4351,6 +4412,10 @@ class Utils {
4351
4412
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
4352
4413
  * })
4353
4414
  */
4415
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4416
+ selectorList: K[],
4417
+ timeout: number
4418
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
4354
4419
  waitNodeList<T extends NodeListOf<Element>>(
4355
4420
  selectorList: string[],
4356
4421
  timeout: number
@@ -4469,6 +4534,10 @@ class Utils {
4469
4534
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
4470
4535
  * })
4471
4536
  */
4537
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4538
+ selectorList: K[],
4539
+ parent?: Node | Element | Document | HTMLElement
4540
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>>;
4472
4541
  waitAnyNodeList<T extends Element>(
4473
4542
  selectorList: string[],
4474
4543
  parent?: Node | Element | Document | HTMLElement
@@ -4483,6 +4552,11 @@ class Utils {
4483
4552
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4484
4553
  * })
4485
4554
  */
4555
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4556
+ selectorList: K[],
4557
+ parent: Node | Element | Document | HTMLElement,
4558
+ timeout: number
4559
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4486
4560
  waitAnyNodeList<T extends Element>(
4487
4561
  selectorList: string[],
4488
4562
  parent: Node | Element | Document | HTMLElement,
@@ -4497,6 +4571,10 @@ class Utils {
4497
4571
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4498
4572
  * })
4499
4573
  */
4574
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4575
+ selectorList: K[],
4576
+ timeout: number
4577
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4500
4578
  waitAnyNodeList<T extends Element>(
4501
4579
  selectorList: string[],
4502
4580
  timeout: number