@whitesev/utils 1.3.1 → 1.3.3

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.3",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
package/src/Utils.ts CHANGED
@@ -3256,12 +3256,15 @@ class Utils {
3256
3256
  ): Promise<boolean>;
3257
3257
  setClip(
3258
3258
  data: any,
3259
- info?:
3259
+ info:
3260
3260
  | {
3261
3261
  type: string;
3262
3262
  mimetype: string;
3263
3263
  }
3264
- | string
3264
+ | string = {
3265
+ type: "text",
3266
+ mimetype: "text/plain",
3267
+ }
3265
3268
  ): Promise<boolean> {
3266
3269
  if (typeof data === "object") {
3267
3270
  if (data instanceof Element) {
@@ -3998,6 +4001,10 @@ class Utils {
3998
4001
  * console.log($div); // div => HTMLDivELement
3999
4002
  * })
4000
4003
  */
4004
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4005
+ selector: K,
4006
+ parent?: Node | Element | Document | HTMLElement
4007
+ ): Promise<HTMLElementTagNameMap[K]>;
4001
4008
  waitNode<T extends Element>(
4002
4009
  selector: string,
4003
4010
  parent?: Node | Element | Document | HTMLElement
@@ -4014,6 +4021,10 @@ class Utils {
4014
4021
  * console.log($div); // div => HTMLDivELement[]
4015
4022
  * })
4016
4023
  */
4024
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4025
+ selectorList: K[],
4026
+ parent?: Node | Element | Document | HTMLElement
4027
+ ): Promise<HTMLElementTagNameMap[K][]>;
4017
4028
  waitNode<T extends Element[]>(
4018
4029
  selectorList: string[],
4019
4030
  parent?: Node | Element | Document | HTMLElement
@@ -4028,6 +4039,11 @@ class Utils {
4028
4039
  * console.log($div); // $div => HTMLDivELement | null
4029
4040
  * })
4030
4041
  */
4042
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4043
+ selector: K,
4044
+ parent: Node | Element | Document | HTMLElement,
4045
+ timeout: number
4046
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4031
4047
  waitNode<T extends Element>(
4032
4048
  selector: string,
4033
4049
  parent: Node | Element | Document | HTMLElement,
@@ -4043,6 +4059,11 @@ class Utils {
4043
4059
  * console.log($div); // $div => HTMLDivELement[] | null
4044
4060
  * })
4045
4061
  */
4062
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4063
+ selectorList: K[],
4064
+ parent: Node | Element | Document | HTMLElement,
4065
+ timeout: number
4066
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4046
4067
  waitNode<T extends Element[]>(
4047
4068
  selectorList: string[],
4048
4069
  parent: Node | Element | Document | HTMLElement,
@@ -4057,6 +4078,10 @@ class Utils {
4057
4078
  * console.log($div); // $div => HTMLDivELement | null
4058
4079
  * })
4059
4080
  */
4081
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4082
+ selector: K,
4083
+ timeout: number
4084
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4060
4085
  waitNode<T extends Element>(
4061
4086
  selector: string,
4062
4087
  timeout: number
@@ -4070,6 +4095,10 @@ class Utils {
4070
4095
  * console.log($div); // $div => HTMLDivELement[] | null
4071
4096
  * })
4072
4097
  */
4098
+ waitNode<K extends keyof HTMLElementTagNameMap>(
4099
+ selectorList: K[],
4100
+ timeout: number
4101
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4073
4102
  waitNode<T extends Element[]>(
4074
4103
  selectorList: string[],
4075
4104
  timeout: number
@@ -4181,6 +4210,10 @@ class Utils {
4181
4210
  * console.log($a); // $a => HTMLAnchorElement 这里是第一个
4182
4211
  * })
4183
4212
  */
4213
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4214
+ selectorList: K[],
4215
+ parent?: Node | Element | Document | HTMLElement
4216
+ ): Promise<HTMLElementTagNameMap[K]>;
4184
4217
  waitAnyNode<T extends Element>(
4185
4218
  selectorList: string[],
4186
4219
  parent?: Node | Element | Document | HTMLElement
@@ -4195,6 +4228,11 @@ class Utils {
4195
4228
  * console.log($div); // $div => HTMLDivELement | null
4196
4229
  * })
4197
4230
  */
4231
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4232
+ selectorList: K[],
4233
+ parent: Node | Element | Document | HTMLElement,
4234
+ timeout: number
4235
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4198
4236
  waitAnyNode<T extends Element>(
4199
4237
  selectorList: string[],
4200
4238
  parent: Node | Element | Document | HTMLElement,
@@ -4209,6 +4247,10 @@ class Utils {
4209
4247
  * console.log($div); // $div => HTMLDivELement | null
4210
4248
  * })
4211
4249
  */
4250
+ waitAnyNode<K extends keyof HTMLElementTagNameMap>(
4251
+ selectorList: K[],
4252
+ timeout: number
4253
+ ): Promise<HTMLElementTagNameMap[K] | null>;
4212
4254
  waitAnyNode<T extends Element>(
4213
4255
  selectorList: string[],
4214
4256
  timeout: number
@@ -4279,6 +4321,10 @@ class Utils {
4279
4321
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
4280
4322
  * })
4281
4323
  */
4324
+ waitNodeList<T extends keyof HTMLElementTagNameMap>(
4325
+ selector: T,
4326
+ parent?: Node | Element | Document | HTMLElement
4327
+ ): Promise<NodeListOf<HTMLElementTagNameMap[T]>>;
4282
4328
  waitNodeList<T extends NodeListOf<Element>>(
4283
4329
  selector: string,
4284
4330
  parent?: Node | Element | Document | HTMLElement
@@ -4295,6 +4341,10 @@ class Utils {
4295
4341
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[]
4296
4342
  * })
4297
4343
  */
4344
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4345
+ selectorList: K[],
4346
+ parent?: Node | Element | Document | HTMLElement
4347
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[]>;
4298
4348
  waitNodeList<T extends NodeListOf<Element>[]>(
4299
4349
  selectorList: string[],
4300
4350
  parent?: Node | Element | Document | HTMLElement
@@ -4314,6 +4364,11 @@ class Utils {
4314
4364
  parent: Node | Element | Document | HTMLElement,
4315
4365
  timeout: number
4316
4366
  ): Promise<T | null>;
4367
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4368
+ selector: K,
4369
+ parent: Node | Element | Document | HTMLElement,
4370
+ timeout: number
4371
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4317
4372
  /**
4318
4373
  * 等待元素数组出现
4319
4374
  * @param selectorList CSS选择器数组
@@ -4324,6 +4379,11 @@ class Utils {
4324
4379
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
4325
4380
  * })
4326
4381
  */
4382
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4383
+ selectorList: K[],
4384
+ parent: Node | Element | Document | HTMLElement,
4385
+ timeout: number
4386
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
4327
4387
  waitNodeList<T extends NodeListOf<Element>[]>(
4328
4388
  selectorList: string[],
4329
4389
  parent: Node | Element | Document | HTMLElement,
@@ -4338,6 +4398,10 @@ class Utils {
4338
4398
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4339
4399
  * })
4340
4400
  */
4401
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4402
+ selector: K[],
4403
+ timeout: number
4404
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4341
4405
  waitNodeList<T extends NodeListOf<Element>>(
4342
4406
  selector: string[],
4343
4407
  timeout: number
@@ -4351,6 +4415,10 @@ class Utils {
4351
4415
  * console.log($result); // $result => NodeListOf<HTMLDivElement>[] | null
4352
4416
  * })
4353
4417
  */
4418
+ waitNodeList<K extends keyof HTMLElementTagNameMap>(
4419
+ selectorList: K[],
4420
+ timeout: number
4421
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>[] | null>;
4354
4422
  waitNodeList<T extends NodeListOf<Element>>(
4355
4423
  selectorList: string[],
4356
4424
  timeout: number
@@ -4469,6 +4537,10 @@ class Utils {
4469
4537
  * console.log($result); // $result => NodeListOf<HTMLDivElement>
4470
4538
  * })
4471
4539
  */
4540
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4541
+ selectorList: K[],
4542
+ parent?: Node | Element | Document | HTMLElement
4543
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]>>;
4472
4544
  waitAnyNodeList<T extends Element>(
4473
4545
  selectorList: string[],
4474
4546
  parent?: Node | Element | Document | HTMLElement
@@ -4483,6 +4555,11 @@ class Utils {
4483
4555
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4484
4556
  * })
4485
4557
  */
4558
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4559
+ selectorList: K[],
4560
+ parent: Node | Element | Document | HTMLElement,
4561
+ timeout: number
4562
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4486
4563
  waitAnyNodeList<T extends Element>(
4487
4564
  selectorList: string[],
4488
4565
  parent: Node | Element | Document | HTMLElement,
@@ -4497,6 +4574,10 @@ class Utils {
4497
4574
  * console.log($result); // $result => NodeListOf<HTMLDivElement> | null
4498
4575
  * })
4499
4576
  */
4577
+ waitAnyNodeList<K extends keyof HTMLElementTagNameMap>(
4578
+ selectorList: K[],
4579
+ timeout: number
4580
+ ): Promise<NodeListOf<HTMLElementTagNameMap[K]> | null>;
4500
4581
  waitAnyNodeList<T extends Element>(
4501
4582
  selectorList: string[],
4502
4583
  timeout: number