@daysnap/utils 0.0.79 → 0.0.81
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/docs/interfaces/StorageManager.md +4 -4
- package/docs/interfaces/Trap.md +5 -5
- package/docs/modules.md +222 -112
- package/es/formartDateToZN.js +0 -1
- package/es/throttle.d.ts +11 -1
- package/es/throttle.js +25 -3
- package/lib/formartDateToZN.js +0 -1
- package/lib/throttle.d.ts +11 -1
- package/lib/throttle.js +28 -4
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
#### Defined in
|
|
37
37
|
|
|
38
|
-
[storage/factory.ts:3](https://github.com/daysnap/utils/blob/
|
|
38
|
+
[storage/factory.ts:3](https://github.com/daysnap/utils/blob/867c3c9/src/storage/factory.ts#L3)
|
|
39
39
|
|
|
40
40
|
___
|
|
41
41
|
|
|
@@ -49,7 +49,7 @@ ___
|
|
|
49
49
|
|
|
50
50
|
#### Defined in
|
|
51
51
|
|
|
52
|
-
[storage/factory.ts:4](https://github.com/daysnap/utils/blob/
|
|
52
|
+
[storage/factory.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/storage/factory.ts#L4)
|
|
53
53
|
|
|
54
54
|
___
|
|
55
55
|
|
|
@@ -69,7 +69,7 @@ ___
|
|
|
69
69
|
|
|
70
70
|
#### Defined in
|
|
71
71
|
|
|
72
|
-
[storage/factory.ts:2](https://github.com/daysnap/utils/blob/
|
|
72
|
+
[storage/factory.ts:2](https://github.com/daysnap/utils/blob/867c3c9/src/storage/factory.ts#L2)
|
|
73
73
|
|
|
74
74
|
___
|
|
75
75
|
|
|
@@ -89,4 +89,4 @@ ___
|
|
|
89
89
|
|
|
90
90
|
#### Defined in
|
|
91
91
|
|
|
92
|
-
[storage/factory.ts:5](https://github.com/daysnap/utils/blob/
|
|
92
|
+
[storage/factory.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/storage/factory.ts#L5)
|
package/docs/interfaces/Trap.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
#### Defined in
|
|
33
33
|
|
|
34
|
-
[trap.ts:12](https://github.com/daysnap/utils/blob/
|
|
34
|
+
[trap.ts:12](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L12)
|
|
35
35
|
|
|
36
36
|
___
|
|
37
37
|
|
|
@@ -56,7 +56,7 @@ ___
|
|
|
56
56
|
|
|
57
57
|
#### Defined in
|
|
58
58
|
|
|
59
|
-
[trap.ts:10](https://github.com/daysnap/utils/blob/
|
|
59
|
+
[trap.ts:10](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L10)
|
|
60
60
|
|
|
61
61
|
___
|
|
62
62
|
|
|
@@ -80,7 +80,7 @@ ___
|
|
|
80
80
|
|
|
81
81
|
#### Defined in
|
|
82
82
|
|
|
83
|
-
[trap.ts:11](https://github.com/daysnap/utils/blob/
|
|
83
|
+
[trap.ts:11](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L11)
|
|
84
84
|
|
|
85
85
|
___
|
|
86
86
|
|
|
@@ -90,7 +90,7 @@ ___
|
|
|
90
90
|
|
|
91
91
|
#### Defined in
|
|
92
92
|
|
|
93
|
-
[trap.ts:8](https://github.com/daysnap/utils/blob/
|
|
93
|
+
[trap.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L8)
|
|
94
94
|
|
|
95
95
|
___
|
|
96
96
|
|
|
@@ -115,4 +115,4 @@ ___
|
|
|
115
115
|
|
|
116
116
|
#### Defined in
|
|
117
117
|
|
|
118
|
-
[trap.ts:9](https://github.com/daysnap/utils/blob/
|
|
118
|
+
[trap.ts:9](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L9)
|
package/docs/modules.md
CHANGED
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
- [formatAmount](modules.md#formatamount)
|
|
47
47
|
- [formatDate](modules.md#formatdate)
|
|
48
48
|
- [formatDateStr](modules.md#formatdatestr)
|
|
49
|
+
- [formatDateToZN](modules.md#formatdatetozn)
|
|
49
50
|
- [formatMessage](modules.md#formatmessage)
|
|
50
51
|
- [formatPathParams](modules.md#formatpathparams)
|
|
51
52
|
- [getBlobByUrl](modules.md#getblobbyurl)
|
|
@@ -118,6 +119,8 @@
|
|
|
118
119
|
- [stringTrim](modules.md#stringtrim)
|
|
119
120
|
- [stringifyQuery](modules.md#stringifyquery)
|
|
120
121
|
- [throttle](modules.md#throttle)
|
|
122
|
+
- [throttleLeading](modules.md#throttleleading)
|
|
123
|
+
- [throttleTrailing](modules.md#throttletrailing)
|
|
121
124
|
- [toCDB](modules.md#tocdb)
|
|
122
125
|
- [toDBC](modules.md#todbc)
|
|
123
126
|
- [typeOf](modules.md#typeof)
|
|
@@ -130,7 +133,7 @@
|
|
|
130
133
|
|
|
131
134
|
#### Defined in
|
|
132
135
|
|
|
133
|
-
[trap.ts:15](https://github.com/daysnap/utils/blob/
|
|
136
|
+
[trap.ts:15](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L15)
|
|
134
137
|
|
|
135
138
|
## Functions
|
|
136
139
|
|
|
@@ -168,7 +171,7 @@ res = { '1': '男', '2': '女' }
|
|
|
168
171
|
|
|
169
172
|
#### Defined in
|
|
170
173
|
|
|
171
|
-
[ato.ts:12](https://github.com/daysnap/utils/blob/
|
|
174
|
+
[ato.ts:12](https://github.com/daysnap/utils/blob/867c3c9/src/ato.ts#L12)
|
|
172
175
|
|
|
173
176
|
▸ **ato**<`T`, `K`\>(`options`, `labelKey`, `valueKey`): `Record`<`T`[`K`], `any`\>
|
|
174
177
|
|
|
@@ -193,7 +196,7 @@ res = { '1': '男', '2': '女' }
|
|
|
193
196
|
|
|
194
197
|
#### Defined in
|
|
195
198
|
|
|
196
|
-
[ato.ts:16](https://github.com/daysnap/utils/blob/
|
|
199
|
+
[ato.ts:16](https://github.com/daysnap/utils/blob/867c3c9/src/ato.ts#L16)
|
|
197
200
|
|
|
198
201
|
___
|
|
199
202
|
|
|
@@ -216,7 +219,7 @@ base64 转 blob
|
|
|
216
219
|
|
|
217
220
|
#### Defined in
|
|
218
221
|
|
|
219
|
-
[base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/
|
|
222
|
+
[base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/base64ToBlob.ts#L6)
|
|
220
223
|
|
|
221
224
|
___
|
|
222
225
|
|
|
@@ -238,7 +241,7 @@ blob 转 base64
|
|
|
238
241
|
|
|
239
242
|
#### Defined in
|
|
240
243
|
|
|
241
|
-
[blobToBase64.ts:4](https://github.com/daysnap/utils/blob/
|
|
244
|
+
[blobToBase64.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/blobToBase64.ts#L4)
|
|
242
245
|
|
|
243
246
|
___
|
|
244
247
|
|
|
@@ -279,7 +282,7 @@ ___
|
|
|
279
282
|
|
|
280
283
|
#### Defined in
|
|
281
284
|
|
|
282
|
-
[cached.ts:5](https://github.com/daysnap/utils/blob/
|
|
285
|
+
[cached.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/cached.ts#L5)
|
|
283
286
|
|
|
284
287
|
___
|
|
285
288
|
|
|
@@ -302,7 +305,7 @@ camelCase('hello-world') => helloWorld
|
|
|
302
305
|
|
|
303
306
|
#### Defined in
|
|
304
307
|
|
|
305
|
-
[camelCase.ts:5](https://github.com/daysnap/utils/blob/
|
|
308
|
+
[camelCase.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/camelCase.ts#L5)
|
|
306
309
|
|
|
307
310
|
___
|
|
308
311
|
|
|
@@ -326,7 +329,7 @@ canvas 转 blob 文件
|
|
|
326
329
|
|
|
327
330
|
#### Defined in
|
|
328
331
|
|
|
329
|
-
[canvasToBlob.ts:4](https://github.com/daysnap/utils/blob/
|
|
332
|
+
[canvasToBlob.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/canvasToBlob.ts#L4)
|
|
330
333
|
|
|
331
334
|
___
|
|
332
335
|
|
|
@@ -349,7 +352,7 @@ capitalize('hello world') => Hello world
|
|
|
349
352
|
|
|
350
353
|
#### Defined in
|
|
351
354
|
|
|
352
|
-
[capitalize.ts:5](https://github.com/daysnap/utils/blob/
|
|
355
|
+
[capitalize.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/capitalize.ts#L5)
|
|
353
356
|
|
|
354
357
|
___
|
|
355
358
|
|
|
@@ -373,7 +376,7 @@ ___
|
|
|
373
376
|
|
|
374
377
|
#### Defined in
|
|
375
378
|
|
|
376
|
-
[clamp.ts:7](https://github.com/daysnap/utils/blob/
|
|
379
|
+
[clamp.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/clamp.ts#L7)
|
|
377
380
|
|
|
378
381
|
___
|
|
379
382
|
|
|
@@ -401,7 +404,7 @@ ___
|
|
|
401
404
|
|
|
402
405
|
#### Defined in
|
|
403
406
|
|
|
404
|
-
[clone.ts:8](https://github.com/daysnap/utils/blob/
|
|
407
|
+
[clone.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/clone.ts#L8)
|
|
405
408
|
|
|
406
409
|
___
|
|
407
410
|
|
|
@@ -429,7 +432,7 @@ ___
|
|
|
429
432
|
|
|
430
433
|
#### Defined in
|
|
431
434
|
|
|
432
|
-
[cloneSimple.ts:7](https://github.com/daysnap/utils/blob/
|
|
435
|
+
[cloneSimple.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/cloneSimple.ts#L7)
|
|
433
436
|
|
|
434
437
|
___
|
|
435
438
|
|
|
@@ -451,7 +454,7 @@ ___
|
|
|
451
454
|
|
|
452
455
|
#### Defined in
|
|
453
456
|
|
|
454
|
-
[createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/
|
|
457
|
+
[createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/createHexColorByHash.ts#L4)
|
|
455
458
|
|
|
456
459
|
___
|
|
457
460
|
|
|
@@ -477,7 +480,7 @@ ___
|
|
|
477
480
|
|
|
478
481
|
#### Defined in
|
|
479
482
|
|
|
480
|
-
[compareVersion.ts:9](https://github.com/daysnap/utils/blob/
|
|
483
|
+
[compareVersion.ts:9](https://github.com/daysnap/utils/blob/867c3c9/src/compareVersion.ts#L9)
|
|
481
484
|
|
|
482
485
|
___
|
|
483
486
|
|
|
@@ -499,7 +502,7 @@ ___
|
|
|
499
502
|
|
|
500
503
|
#### Defined in
|
|
501
504
|
|
|
502
|
-
[compressImage.ts:6](https://github.com/daysnap/utils/blob/
|
|
505
|
+
[compressImage.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/compressImage.ts#L6)
|
|
503
506
|
|
|
504
507
|
___
|
|
505
508
|
|
|
@@ -531,7 +534,7 @@ ___
|
|
|
531
534
|
|
|
532
535
|
#### Defined in
|
|
533
536
|
|
|
534
|
-
[trap.ts:49](https://github.com/daysnap/utils/blob/
|
|
537
|
+
[trap.ts:49](https://github.com/daysnap/utils/blob/867c3c9/src/trap.ts#L49)
|
|
535
538
|
|
|
536
539
|
___
|
|
537
540
|
|
|
@@ -594,7 +597,7 @@ fn() 执行的时候就会执行showLoading
|
|
|
594
597
|
|
|
595
598
|
#### Defined in
|
|
596
599
|
|
|
597
|
-
[createWithLoading.ts:9](https://github.com/daysnap/utils/blob/
|
|
600
|
+
[createWithLoading.ts:9](https://github.com/daysnap/utils/blob/867c3c9/src/createWithLoading.ts#L9)
|
|
598
601
|
|
|
599
602
|
___
|
|
600
603
|
|
|
@@ -637,7 +640,7 @@ ___
|
|
|
637
640
|
|
|
638
641
|
#### Defined in
|
|
639
642
|
|
|
640
|
-
[debounce.ts:5](https://github.com/daysnap/utils/blob/
|
|
643
|
+
[debounce.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/debounce.ts#L5)
|
|
641
644
|
|
|
642
645
|
___
|
|
643
646
|
|
|
@@ -661,7 +664,7 @@ ___
|
|
|
661
664
|
|
|
662
665
|
#### Defined in
|
|
663
666
|
|
|
664
|
-
[downloadFile.ts:4](https://github.com/daysnap/utils/blob/
|
|
667
|
+
[downloadFile.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/downloadFile.ts#L4)
|
|
665
668
|
|
|
666
669
|
___
|
|
667
670
|
|
|
@@ -690,7 +693,7 @@ ___
|
|
|
690
693
|
|
|
691
694
|
#### Defined in
|
|
692
695
|
|
|
693
|
-
[each.ts:4](https://github.com/daysnap/utils/blob/
|
|
696
|
+
[each.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/each.ts#L4)
|
|
694
697
|
|
|
695
698
|
▸ **each**<`T`\>(`data`, `callback`): `void`
|
|
696
699
|
|
|
@@ -713,7 +716,7 @@ ___
|
|
|
713
716
|
|
|
714
717
|
#### Defined in
|
|
715
718
|
|
|
716
|
-
[each.ts:8](https://github.com/daysnap/utils/blob/
|
|
719
|
+
[each.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/each.ts#L8)
|
|
717
720
|
|
|
718
721
|
___
|
|
719
722
|
|
|
@@ -731,7 +734,7 @@ ___
|
|
|
731
734
|
|
|
732
735
|
#### Defined in
|
|
733
736
|
|
|
734
|
-
[exitFullscreen.ts:6](https://github.com/daysnap/utils/blob/
|
|
737
|
+
[exitFullscreen.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/exitFullscreen.ts#L6)
|
|
735
738
|
|
|
736
739
|
___
|
|
737
740
|
|
|
@@ -760,7 +763,7 @@ ___
|
|
|
760
763
|
|
|
761
764
|
#### Defined in
|
|
762
765
|
|
|
763
|
-
[storage/factory.ts:8](https://github.com/daysnap/utils/blob/
|
|
766
|
+
[storage/factory.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/storage/factory.ts#L8)
|
|
764
767
|
|
|
765
768
|
___
|
|
766
769
|
|
|
@@ -782,7 +785,7 @@ ___
|
|
|
782
785
|
|
|
783
786
|
#### Defined in
|
|
784
787
|
|
|
785
|
-
[filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/
|
|
788
|
+
[filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/filterBankCardNo.ts#L4)
|
|
786
789
|
|
|
787
790
|
___
|
|
788
791
|
|
|
@@ -804,7 +807,7 @@ ___
|
|
|
804
807
|
|
|
805
808
|
#### Defined in
|
|
806
809
|
|
|
807
|
-
[filterCRLF.ts:4](https://github.com/daysnap/utils/blob/
|
|
810
|
+
[filterCRLF.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/filterCRLF.ts#L4)
|
|
808
811
|
|
|
809
812
|
___
|
|
810
813
|
|
|
@@ -826,7 +829,7 @@ ___
|
|
|
826
829
|
|
|
827
830
|
#### Defined in
|
|
828
831
|
|
|
829
|
-
[filterEmoji.ts:4](https://github.com/daysnap/utils/blob/
|
|
832
|
+
[filterEmoji.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/filterEmoji.ts#L4)
|
|
830
833
|
|
|
831
834
|
___
|
|
832
835
|
|
|
@@ -849,7 +852,7 @@ ___
|
|
|
849
852
|
|
|
850
853
|
#### Defined in
|
|
851
854
|
|
|
852
|
-
[filterEmptyValue.ts:12](https://github.com/daysnap/utils/blob/
|
|
855
|
+
[filterEmptyValue.ts:12](https://github.com/daysnap/utils/blob/867c3c9/src/filterEmptyValue.ts#L12)
|
|
853
856
|
|
|
854
857
|
___
|
|
855
858
|
|
|
@@ -872,7 +875,7 @@ ___
|
|
|
872
875
|
|
|
873
876
|
#### Defined in
|
|
874
877
|
|
|
875
|
-
[filterIdCard.ts:5](https://github.com/daysnap/utils/blob/
|
|
878
|
+
[filterIdCard.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/filterIdCard.ts#L5)
|
|
876
879
|
|
|
877
880
|
___
|
|
878
881
|
|
|
@@ -894,7 +897,7 @@ ___
|
|
|
894
897
|
|
|
895
898
|
#### Defined in
|
|
896
899
|
|
|
897
|
-
[filterName.ts:4](https://github.com/daysnap/utils/blob/
|
|
900
|
+
[filterName.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/filterName.ts#L4)
|
|
898
901
|
|
|
899
902
|
___
|
|
900
903
|
|
|
@@ -919,7 +922,7 @@ filterPhone('13177778888', ' ') => 131 **** 8888
|
|
|
919
922
|
|
|
920
923
|
#### Defined in
|
|
921
924
|
|
|
922
|
-
[filterPhone.ts:6](https://github.com/daysnap/utils/blob/
|
|
925
|
+
[filterPhone.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/filterPhone.ts#L6)
|
|
923
926
|
|
|
924
927
|
___
|
|
925
928
|
|
|
@@ -946,7 +949,7 @@ str = '131****8888'
|
|
|
946
949
|
|
|
947
950
|
#### Defined in
|
|
948
951
|
|
|
949
|
-
[filterString.ts:6](https://github.com/daysnap/utils/blob/
|
|
952
|
+
[filterString.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/filterString.ts#L6)
|
|
950
953
|
|
|
951
954
|
___
|
|
952
955
|
|
|
@@ -969,7 +972,7 @@ ___
|
|
|
969
972
|
|
|
970
973
|
#### Defined in
|
|
971
974
|
|
|
972
|
-
[formatAmount.ts:4](https://github.com/daysnap/utils/blob/
|
|
975
|
+
[formatAmount.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/formatAmount.ts#L4)
|
|
973
976
|
|
|
974
977
|
___
|
|
975
978
|
|
|
@@ -993,7 +996,7 @@ ___
|
|
|
993
996
|
|
|
994
997
|
#### Defined in
|
|
995
998
|
|
|
996
|
-
[formatDate.ts:8](https://github.com/daysnap/utils/blob/
|
|
999
|
+
[formatDate.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/formatDate.ts#L8)
|
|
997
1000
|
|
|
998
1001
|
___
|
|
999
1002
|
|
|
@@ -1016,7 +1019,27 @@ fix iOS 日期时间格式如果是 - 就会报错的问题
|
|
|
1016
1019
|
|
|
1017
1020
|
#### Defined in
|
|
1018
1021
|
|
|
1019
|
-
[formatDateStr.ts:5](https://github.com/daysnap/utils/blob/
|
|
1022
|
+
[formatDateStr.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/formatDateStr.ts#L5)
|
|
1023
|
+
|
|
1024
|
+
___
|
|
1025
|
+
|
|
1026
|
+
### formatDateToZN
|
|
1027
|
+
|
|
1028
|
+
▸ **formatDateToZN**(`v`): `string`
|
|
1029
|
+
|
|
1030
|
+
#### Parameters
|
|
1031
|
+
|
|
1032
|
+
| Name | Type |
|
|
1033
|
+
| :------ | :------ |
|
|
1034
|
+
| `v` | `string` \| `number` |
|
|
1035
|
+
|
|
1036
|
+
#### Returns
|
|
1037
|
+
|
|
1038
|
+
`string`
|
|
1039
|
+
|
|
1040
|
+
#### Defined in
|
|
1041
|
+
|
|
1042
|
+
[formartDateToZN.ts:3](https://github.com/daysnap/utils/blob/867c3c9/src/formartDateToZN.ts#L3)
|
|
1020
1043
|
|
|
1021
1044
|
___
|
|
1022
1045
|
|
|
@@ -1041,7 +1064,7 @@ formatMessage({ a: '123', b: { ba: '456' } }, ['b.ba']) => '456'
|
|
|
1041
1064
|
|
|
1042
1065
|
#### Defined in
|
|
1043
1066
|
|
|
1044
|
-
[formatMessage.ts:11](https://github.com/daysnap/utils/blob/
|
|
1067
|
+
[formatMessage.ts:11](https://github.com/daysnap/utils/blob/867c3c9/src/formatMessage.ts#L11)
|
|
1045
1068
|
|
|
1046
1069
|
___
|
|
1047
1070
|
|
|
@@ -1073,7 +1096,7 @@ rest = { xxx: 1 }
|
|
|
1073
1096
|
|
|
1074
1097
|
#### Defined in
|
|
1075
1098
|
|
|
1076
|
-
[formatPathParams.ts:8](https://github.com/daysnap/utils/blob/
|
|
1099
|
+
[formatPathParams.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/formatPathParams.ts#L8)
|
|
1077
1100
|
|
|
1078
1101
|
___
|
|
1079
1102
|
|
|
@@ -1095,7 +1118,7 @@ ___
|
|
|
1095
1118
|
|
|
1096
1119
|
#### Defined in
|
|
1097
1120
|
|
|
1098
|
-
[getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/
|
|
1121
|
+
[getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/getBlobByUrl.ts#L4)
|
|
1099
1122
|
|
|
1100
1123
|
___
|
|
1101
1124
|
|
|
@@ -1118,7 +1141,7 @@ ___
|
|
|
1118
1141
|
|
|
1119
1142
|
#### Defined in
|
|
1120
1143
|
|
|
1121
|
-
[storage/index.ts:9](https://github.com/daysnap/utils/blob/
|
|
1144
|
+
[storage/index.ts:9](https://github.com/daysnap/utils/blob/867c3c9/src/storage/index.ts#L9)
|
|
1122
1145
|
|
|
1123
1146
|
___
|
|
1124
1147
|
|
|
@@ -1140,7 +1163,7 @@ ___
|
|
|
1140
1163
|
|
|
1141
1164
|
#### Defined in
|
|
1142
1165
|
|
|
1143
|
-
[getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/
|
|
1166
|
+
[getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/getDayMillisecond.ts#L4)
|
|
1144
1167
|
|
|
1145
1168
|
___
|
|
1146
1169
|
|
|
@@ -1162,7 +1185,7 @@ ___
|
|
|
1162
1185
|
|
|
1163
1186
|
#### Defined in
|
|
1164
1187
|
|
|
1165
|
-
[getImageInfo.ts:4](https://github.com/daysnap/utils/blob/
|
|
1188
|
+
[getImageInfo.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/getImageInfo.ts#L4)
|
|
1166
1189
|
|
|
1167
1190
|
___
|
|
1168
1191
|
|
|
@@ -1185,7 +1208,7 @@ ___
|
|
|
1185
1208
|
|
|
1186
1209
|
#### Defined in
|
|
1187
1210
|
|
|
1188
|
-
[storage/index.ts:9](https://github.com/daysnap/utils/blob/
|
|
1211
|
+
[storage/index.ts:9](https://github.com/daysnap/utils/blob/867c3c9/src/storage/index.ts#L9)
|
|
1189
1212
|
|
|
1190
1213
|
___
|
|
1191
1214
|
|
|
@@ -1208,7 +1231,7 @@ ___
|
|
|
1208
1231
|
|
|
1209
1232
|
#### Defined in
|
|
1210
1233
|
|
|
1211
|
-
[getRandom.ts:7](https://github.com/daysnap/utils/blob/
|
|
1234
|
+
[getRandom.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/getRandom.ts#L7)
|
|
1212
1235
|
|
|
1213
1236
|
___
|
|
1214
1237
|
|
|
@@ -1224,7 +1247,7 @@ ___
|
|
|
1224
1247
|
|
|
1225
1248
|
#### Defined in
|
|
1226
1249
|
|
|
1227
|
-
[getRandomColor.ts:4](https://github.com/daysnap/utils/blob/
|
|
1250
|
+
[getRandomColor.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/getRandomColor.ts#L4)
|
|
1228
1251
|
|
|
1229
1252
|
___
|
|
1230
1253
|
|
|
@@ -1246,7 +1269,7 @@ ___
|
|
|
1246
1269
|
|
|
1247
1270
|
#### Defined in
|
|
1248
1271
|
|
|
1249
|
-
[getRandomNumber.ts:7](https://github.com/daysnap/utils/blob/
|
|
1272
|
+
[getRandomNumber.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/getRandomNumber.ts#L7)
|
|
1250
1273
|
|
|
1251
1274
|
___
|
|
1252
1275
|
|
|
@@ -1268,7 +1291,7 @@ ___
|
|
|
1268
1291
|
|
|
1269
1292
|
#### Defined in
|
|
1270
1293
|
|
|
1271
|
-
[getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/
|
|
1294
|
+
[getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/getVideoInfo.ts#L4)
|
|
1272
1295
|
|
|
1273
1296
|
___
|
|
1274
1297
|
|
|
@@ -1284,7 +1307,7 @@ ___
|
|
|
1284
1307
|
|
|
1285
1308
|
#### Defined in
|
|
1286
1309
|
|
|
1287
|
-
[inBrowser.ts:4](https://github.com/daysnap/utils/blob/
|
|
1310
|
+
[inBrowser.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/inBrowser.ts#L4)
|
|
1288
1311
|
|
|
1289
1312
|
___
|
|
1290
1313
|
|
|
@@ -1306,7 +1329,7 @@ ___
|
|
|
1306
1329
|
|
|
1307
1330
|
#### Defined in
|
|
1308
1331
|
|
|
1309
|
-
[insertLink.ts:4](https://github.com/daysnap/utils/blob/
|
|
1332
|
+
[insertLink.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/insertLink.ts#L4)
|
|
1310
1333
|
|
|
1311
1334
|
▸ **insertLink**(`href`, `callback`): `void`
|
|
1312
1335
|
|
|
@@ -1323,7 +1346,7 @@ ___
|
|
|
1323
1346
|
|
|
1324
1347
|
#### Defined in
|
|
1325
1348
|
|
|
1326
|
-
[insertLink.ts:5](https://github.com/daysnap/utils/blob/
|
|
1349
|
+
[insertLink.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/insertLink.ts#L5)
|
|
1327
1350
|
|
|
1328
1351
|
___
|
|
1329
1352
|
|
|
@@ -1345,7 +1368,7 @@ ___
|
|
|
1345
1368
|
|
|
1346
1369
|
#### Defined in
|
|
1347
1370
|
|
|
1348
|
-
[insertScript.ts:4](https://github.com/daysnap/utils/blob/
|
|
1371
|
+
[insertScript.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/insertScript.ts#L4)
|
|
1349
1372
|
|
|
1350
1373
|
▸ **insertScript**(`src`, `callback`): `void`
|
|
1351
1374
|
|
|
@@ -1362,7 +1385,7 @@ ___
|
|
|
1362
1385
|
|
|
1363
1386
|
#### Defined in
|
|
1364
1387
|
|
|
1365
|
-
[insertScript.ts:5](https://github.com/daysnap/utils/blob/
|
|
1388
|
+
[insertScript.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/insertScript.ts#L5)
|
|
1366
1389
|
|
|
1367
1390
|
___
|
|
1368
1391
|
|
|
@@ -1384,7 +1407,7 @@ ___
|
|
|
1384
1407
|
|
|
1385
1408
|
#### Defined in
|
|
1386
1409
|
|
|
1387
|
-
[insertStyle.ts:4](https://github.com/daysnap/utils/blob/
|
|
1410
|
+
[insertStyle.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/insertStyle.ts#L4)
|
|
1388
1411
|
|
|
1389
1412
|
___
|
|
1390
1413
|
|
|
@@ -1413,7 +1436,7 @@ isAmount('1.123') => false
|
|
|
1413
1436
|
|
|
1414
1437
|
#### Defined in
|
|
1415
1438
|
|
|
1416
|
-
[isAmount.ts:11](https://github.com/daysnap/utils/blob/
|
|
1439
|
+
[isAmount.ts:11](https://github.com/daysnap/utils/blob/867c3c9/src/isAmount.ts#L11)
|
|
1417
1440
|
|
|
1418
1441
|
___
|
|
1419
1442
|
|
|
@@ -1429,7 +1452,7 @@ ___
|
|
|
1429
1452
|
|
|
1430
1453
|
#### Defined in
|
|
1431
1454
|
|
|
1432
|
-
[isAndroid.ts:4](https://github.com/daysnap/utils/blob/
|
|
1455
|
+
[isAndroid.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isAndroid.ts#L4)
|
|
1433
1456
|
|
|
1434
1457
|
___
|
|
1435
1458
|
|
|
@@ -1453,7 +1476,7 @@ val is any[]
|
|
|
1453
1476
|
|
|
1454
1477
|
#### Defined in
|
|
1455
1478
|
|
|
1456
|
-
[isArray.ts:6](https://github.com/daysnap/utils/blob/
|
|
1479
|
+
[isArray.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/isArray.ts#L6)
|
|
1457
1480
|
|
|
1458
1481
|
___
|
|
1459
1482
|
|
|
@@ -1475,7 +1498,7 @@ val is boolean
|
|
|
1475
1498
|
|
|
1476
1499
|
#### Defined in
|
|
1477
1500
|
|
|
1478
|
-
[isBoolean.ts:5](https://github.com/daysnap/utils/blob/
|
|
1501
|
+
[isBoolean.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isBoolean.ts#L5)
|
|
1479
1502
|
|
|
1480
1503
|
___
|
|
1481
1504
|
|
|
@@ -1497,7 +1520,7 @@ ___
|
|
|
1497
1520
|
|
|
1498
1521
|
#### Defined in
|
|
1499
1522
|
|
|
1500
|
-
[isChinese.ts:4](https://github.com/daysnap/utils/blob/
|
|
1523
|
+
[isChinese.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isChinese.ts#L4)
|
|
1501
1524
|
|
|
1502
1525
|
___
|
|
1503
1526
|
|
|
@@ -1519,7 +1542,7 @@ val is Date
|
|
|
1519
1542
|
|
|
1520
1543
|
#### Defined in
|
|
1521
1544
|
|
|
1522
|
-
[isDate.ts:4](https://github.com/daysnap/utils/blob/
|
|
1545
|
+
[isDate.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isDate.ts#L4)
|
|
1523
1546
|
|
|
1524
1547
|
___
|
|
1525
1548
|
|
|
@@ -1541,7 +1564,7 @@ ___
|
|
|
1541
1564
|
|
|
1542
1565
|
#### Defined in
|
|
1543
1566
|
|
|
1544
|
-
[isEmail.ts:4](https://github.com/daysnap/utils/blob/
|
|
1567
|
+
[isEmail.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isEmail.ts#L4)
|
|
1545
1568
|
|
|
1546
1569
|
___
|
|
1547
1570
|
|
|
@@ -1563,7 +1586,7 @@ ___
|
|
|
1563
1586
|
|
|
1564
1587
|
#### Defined in
|
|
1565
1588
|
|
|
1566
|
-
[isEmpty.ts:6](https://github.com/daysnap/utils/blob/
|
|
1589
|
+
[isEmpty.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/isEmpty.ts#L6)
|
|
1567
1590
|
|
|
1568
1591
|
___
|
|
1569
1592
|
|
|
@@ -1585,7 +1608,7 @@ ___
|
|
|
1585
1608
|
|
|
1586
1609
|
#### Defined in
|
|
1587
1610
|
|
|
1588
|
-
[isEmptyArray.ts:6](https://github.com/daysnap/utils/blob/
|
|
1611
|
+
[isEmptyArray.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/isEmptyArray.ts#L6)
|
|
1589
1612
|
|
|
1590
1613
|
___
|
|
1591
1614
|
|
|
@@ -1607,7 +1630,7 @@ ___
|
|
|
1607
1630
|
|
|
1608
1631
|
#### Defined in
|
|
1609
1632
|
|
|
1610
|
-
[isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/
|
|
1633
|
+
[isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isEmptyObject.ts#L5)
|
|
1611
1634
|
|
|
1612
1635
|
___
|
|
1613
1636
|
|
|
@@ -1629,7 +1652,7 @@ val is Error
|
|
|
1629
1652
|
|
|
1630
1653
|
#### Defined in
|
|
1631
1654
|
|
|
1632
|
-
[isError.ts:4](https://github.com/daysnap/utils/blob/
|
|
1655
|
+
[isError.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isError.ts#L4)
|
|
1633
1656
|
|
|
1634
1657
|
___
|
|
1635
1658
|
|
|
@@ -1651,7 +1674,7 @@ val is Function
|
|
|
1651
1674
|
|
|
1652
1675
|
#### Defined in
|
|
1653
1676
|
|
|
1654
|
-
[isFunction.ts:4](https://github.com/daysnap/utils/blob/
|
|
1677
|
+
[isFunction.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isFunction.ts#L4)
|
|
1655
1678
|
|
|
1656
1679
|
___
|
|
1657
1680
|
|
|
@@ -1669,7 +1692,7 @@ ___
|
|
|
1669
1692
|
|
|
1670
1693
|
#### Defined in
|
|
1671
1694
|
|
|
1672
|
-
[isIE.ts:6](https://github.com/daysnap/utils/blob/
|
|
1695
|
+
[isIE.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/isIE.ts#L6)
|
|
1673
1696
|
|
|
1674
1697
|
___
|
|
1675
1698
|
|
|
@@ -1685,7 +1708,7 @@ ___
|
|
|
1685
1708
|
|
|
1686
1709
|
#### Defined in
|
|
1687
1710
|
|
|
1688
|
-
[isIOS.ts:4](https://github.com/daysnap/utils/blob/
|
|
1711
|
+
[isIOS.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isIOS.ts#L4)
|
|
1689
1712
|
|
|
1690
1713
|
___
|
|
1691
1714
|
|
|
@@ -1707,7 +1730,7 @@ ___
|
|
|
1707
1730
|
|
|
1708
1731
|
#### Defined in
|
|
1709
1732
|
|
|
1710
|
-
[isIdCard.ts:4](https://github.com/daysnap/utils/blob/
|
|
1733
|
+
[isIdCard.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isIdCard.ts#L4)
|
|
1711
1734
|
|
|
1712
1735
|
___
|
|
1713
1736
|
|
|
@@ -1729,7 +1752,7 @@ ___
|
|
|
1729
1752
|
|
|
1730
1753
|
#### Defined in
|
|
1731
1754
|
|
|
1732
|
-
[isJSONString.ts:7](https://github.com/daysnap/utils/blob/
|
|
1755
|
+
[isJSONString.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/isJSONString.ts#L7)
|
|
1733
1756
|
|
|
1734
1757
|
___
|
|
1735
1758
|
|
|
@@ -1751,7 +1774,7 @@ ___
|
|
|
1751
1774
|
|
|
1752
1775
|
#### Defined in
|
|
1753
1776
|
|
|
1754
|
-
[isLan.ts:5](https://github.com/daysnap/utils/blob/
|
|
1777
|
+
[isLan.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isLan.ts#L5)
|
|
1755
1778
|
|
|
1756
1779
|
___
|
|
1757
1780
|
|
|
@@ -1773,7 +1796,7 @@ ___
|
|
|
1773
1796
|
|
|
1774
1797
|
#### Defined in
|
|
1775
1798
|
|
|
1776
|
-
[isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/
|
|
1799
|
+
[isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isLicenseCode.ts#L5)
|
|
1777
1800
|
|
|
1778
1801
|
___
|
|
1779
1802
|
|
|
@@ -1789,7 +1812,7 @@ ___
|
|
|
1789
1812
|
|
|
1790
1813
|
#### Defined in
|
|
1791
1814
|
|
|
1792
|
-
[isMobile.ts:4](https://github.com/daysnap/utils/blob/
|
|
1815
|
+
[isMobile.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isMobile.ts#L4)
|
|
1793
1816
|
|
|
1794
1817
|
___
|
|
1795
1818
|
|
|
@@ -1812,7 +1835,7 @@ ___
|
|
|
1812
1835
|
|
|
1813
1836
|
#### Defined in
|
|
1814
1837
|
|
|
1815
|
-
[isNativeFunction.ts:7](https://github.com/daysnap/utils/blob/
|
|
1838
|
+
[isNativeFunction.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/isNativeFunction.ts#L7)
|
|
1816
1839
|
|
|
1817
1840
|
___
|
|
1818
1841
|
|
|
@@ -1834,7 +1857,7 @@ val is null
|
|
|
1834
1857
|
|
|
1835
1858
|
#### Defined in
|
|
1836
1859
|
|
|
1837
|
-
[isNull.ts:4](https://github.com/daysnap/utils/blob/
|
|
1860
|
+
[isNull.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isNull.ts#L4)
|
|
1838
1861
|
|
|
1839
1862
|
___
|
|
1840
1863
|
|
|
@@ -1856,7 +1879,7 @@ val is number
|
|
|
1856
1879
|
|
|
1857
1880
|
#### Defined in
|
|
1858
1881
|
|
|
1859
|
-
[isNumber.ts:5](https://github.com/daysnap/utils/blob/
|
|
1882
|
+
[isNumber.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isNumber.ts#L5)
|
|
1860
1883
|
|
|
1861
1884
|
___
|
|
1862
1885
|
|
|
@@ -1878,7 +1901,7 @@ val is Record<string, any\>
|
|
|
1878
1901
|
|
|
1879
1902
|
#### Defined in
|
|
1880
1903
|
|
|
1881
|
-
[isObject.ts:4](https://github.com/daysnap/utils/blob/
|
|
1904
|
+
[isObject.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isObject.ts#L4)
|
|
1882
1905
|
|
|
1883
1906
|
___
|
|
1884
1907
|
|
|
@@ -1900,7 +1923,7 @@ ___
|
|
|
1900
1923
|
|
|
1901
1924
|
#### Defined in
|
|
1902
1925
|
|
|
1903
|
-
[isPhone.ts:4](https://github.com/daysnap/utils/blob/
|
|
1926
|
+
[isPhone.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isPhone.ts#L4)
|
|
1904
1927
|
|
|
1905
1928
|
___
|
|
1906
1929
|
|
|
@@ -1928,7 +1951,7 @@ val is Promise<T\>
|
|
|
1928
1951
|
|
|
1929
1952
|
#### Defined in
|
|
1930
1953
|
|
|
1931
|
-
[isPromise.ts:4](https://github.com/daysnap/utils/blob/
|
|
1954
|
+
[isPromise.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isPromise.ts#L4)
|
|
1932
1955
|
|
|
1933
1956
|
___
|
|
1934
1957
|
|
|
@@ -1950,7 +1973,7 @@ val is RegExp
|
|
|
1950
1973
|
|
|
1951
1974
|
#### Defined in
|
|
1952
1975
|
|
|
1953
|
-
[isRegExp.ts:4](https://github.com/daysnap/utils/blob/
|
|
1976
|
+
[isRegExp.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isRegExp.ts#L4)
|
|
1954
1977
|
|
|
1955
1978
|
___
|
|
1956
1979
|
|
|
@@ -1972,7 +1995,7 @@ val is string
|
|
|
1972
1995
|
|
|
1973
1996
|
#### Defined in
|
|
1974
1997
|
|
|
1975
|
-
[isString.ts:4](https://github.com/daysnap/utils/blob/
|
|
1998
|
+
[isString.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isString.ts#L4)
|
|
1976
1999
|
|
|
1977
2000
|
___
|
|
1978
2001
|
|
|
@@ -1994,7 +2017,7 @@ ___
|
|
|
1994
2017
|
|
|
1995
2018
|
#### Defined in
|
|
1996
2019
|
|
|
1997
|
-
[isURL.ts:4](https://github.com/daysnap/utils/blob/
|
|
2020
|
+
[isURL.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isURL.ts#L4)
|
|
1998
2021
|
|
|
1999
2022
|
___
|
|
2000
2023
|
|
|
@@ -2016,7 +2039,7 @@ val is undefined
|
|
|
2016
2039
|
|
|
2017
2040
|
#### Defined in
|
|
2018
2041
|
|
|
2019
|
-
[isUndefined.ts:4](https://github.com/daysnap/utils/blob/
|
|
2042
|
+
[isUndefined.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isUndefined.ts#L4)
|
|
2020
2043
|
|
|
2021
2044
|
___
|
|
2022
2045
|
|
|
@@ -2032,7 +2055,7 @@ ___
|
|
|
2032
2055
|
|
|
2033
2056
|
#### Defined in
|
|
2034
2057
|
|
|
2035
|
-
[isWeChat.ts:4](https://github.com/daysnap/utils/blob/
|
|
2058
|
+
[isWeChat.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/isWeChat.ts#L4)
|
|
2036
2059
|
|
|
2037
2060
|
___
|
|
2038
2061
|
|
|
@@ -2049,7 +2072,7 @@ https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html
|
|
|
2049
2072
|
|
|
2050
2073
|
#### Defined in
|
|
2051
2074
|
|
|
2052
|
-
[isWeChatMiniProgram.ts:5](https://github.com/daysnap/utils/blob/
|
|
2075
|
+
[isWeChatMiniProgram.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isWeChatMiniProgram.ts#L5)
|
|
2053
2076
|
|
|
2054
2077
|
___
|
|
2055
2078
|
|
|
@@ -2069,7 +2092,7 @@ ___
|
|
|
2069
2092
|
|
|
2070
2093
|
#### Defined in
|
|
2071
2094
|
|
|
2072
|
-
[isWeChat.ts:12](https://github.com/daysnap/utils/blob/
|
|
2095
|
+
[isWeChat.ts:12](https://github.com/daysnap/utils/blob/867c3c9/src/isWeChat.ts#L12)
|
|
2073
2096
|
|
|
2074
2097
|
___
|
|
2075
2098
|
|
|
@@ -2091,7 +2114,7 @@ val is Window
|
|
|
2091
2114
|
|
|
2092
2115
|
#### Defined in
|
|
2093
2116
|
|
|
2094
|
-
[isWindow.ts:5](https://github.com/daysnap/utils/blob/
|
|
2117
|
+
[isWindow.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/isWindow.ts#L5)
|
|
2095
2118
|
|
|
2096
2119
|
___
|
|
2097
2120
|
|
|
@@ -2114,7 +2137,7 @@ kebabCase('helloWorld') => hello-world
|
|
|
2114
2137
|
|
|
2115
2138
|
#### Defined in
|
|
2116
2139
|
|
|
2117
|
-
[kebabCase.ts:5](https://github.com/daysnap/utils/blob/
|
|
2140
|
+
[kebabCase.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/kebabCase.ts#L5)
|
|
2118
2141
|
|
|
2119
2142
|
___
|
|
2120
2143
|
|
|
@@ -2143,7 +2166,7 @@ list 生成器,快速生成数据
|
|
|
2143
2166
|
|
|
2144
2167
|
#### Defined in
|
|
2145
2168
|
|
|
2146
|
-
[listGenerator.ts:5](https://github.com/daysnap/utils/blob/
|
|
2169
|
+
[listGenerator.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/listGenerator.ts#L5)
|
|
2147
2170
|
|
|
2148
2171
|
___
|
|
2149
2172
|
|
|
@@ -2168,7 +2191,7 @@ ___
|
|
|
2168
2191
|
|
|
2169
2192
|
#### Defined in
|
|
2170
2193
|
|
|
2171
|
-
[mousewheel.ts:22](https://github.com/daysnap/utils/blob/
|
|
2194
|
+
[mousewheel.ts:22](https://github.com/daysnap/utils/blob/867c3c9/src/mousewheel.ts#L22)
|
|
2172
2195
|
|
|
2173
2196
|
___
|
|
2174
2197
|
|
|
@@ -2190,7 +2213,7 @@ ___
|
|
|
2190
2213
|
|
|
2191
2214
|
#### Defined in
|
|
2192
2215
|
|
|
2193
|
-
[normalizePath.ts:4](https://github.com/daysnap/utils/blob/
|
|
2216
|
+
[normalizePath.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/normalizePath.ts#L4)
|
|
2194
2217
|
|
|
2195
2218
|
___
|
|
2196
2219
|
|
|
@@ -2220,7 +2243,7 @@ ___
|
|
|
2220
2243
|
|
|
2221
2244
|
#### Defined in
|
|
2222
2245
|
|
|
2223
|
-
[omit.ts:4](https://github.com/daysnap/utils/blob/
|
|
2246
|
+
[omit.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/omit.ts#L4)
|
|
2224
2247
|
|
|
2225
2248
|
___
|
|
2226
2249
|
|
|
@@ -2244,7 +2267,7 @@ ___
|
|
|
2244
2267
|
|
|
2245
2268
|
#### Defined in
|
|
2246
2269
|
|
|
2247
|
-
[padding.ts:7](https://github.com/daysnap/utils/blob/
|
|
2270
|
+
[padding.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/padding.ts#L7)
|
|
2248
2271
|
|
|
2249
2272
|
___
|
|
2250
2273
|
|
|
@@ -2266,7 +2289,7 @@ ___
|
|
|
2266
2289
|
|
|
2267
2290
|
#### Defined in
|
|
2268
2291
|
|
|
2269
|
-
[parseDate.ts:4](https://github.com/daysnap/utils/blob/
|
|
2292
|
+
[parseDate.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/parseDate.ts#L4)
|
|
2270
2293
|
|
|
2271
2294
|
___
|
|
2272
2295
|
|
|
@@ -2289,7 +2312,7 @@ ___
|
|
|
2289
2312
|
|
|
2290
2313
|
#### Defined in
|
|
2291
2314
|
|
|
2292
|
-
[parseError.ts:8](https://github.com/daysnap/utils/blob/
|
|
2315
|
+
[parseError.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/parseError.ts#L8)
|
|
2293
2316
|
|
|
2294
2317
|
___
|
|
2295
2318
|
|
|
@@ -2319,7 +2342,7 @@ parseObject('a.b.c', 1) => { a: { b: { c: 1 } } }
|
|
|
2319
2342
|
|
|
2320
2343
|
#### Defined in
|
|
2321
2344
|
|
|
2322
|
-
[parseObject.ts:5](https://github.com/daysnap/utils/blob/
|
|
2345
|
+
[parseObject.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/parseObject.ts#L5)
|
|
2323
2346
|
|
|
2324
2347
|
___
|
|
2325
2348
|
|
|
@@ -2348,7 +2371,7 @@ ___
|
|
|
2348
2371
|
|
|
2349
2372
|
#### Defined in
|
|
2350
2373
|
|
|
2351
|
-
[parsePath.ts:6](https://github.com/daysnap/utils/blob/
|
|
2374
|
+
[parsePath.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/parsePath.ts#L6)
|
|
2352
2375
|
|
|
2353
2376
|
___
|
|
2354
2377
|
|
|
@@ -2371,7 +2394,7 @@ ___
|
|
|
2371
2394
|
|
|
2372
2395
|
#### Defined in
|
|
2373
2396
|
|
|
2374
|
-
[parseQuery.ts:8](https://github.com/daysnap/utils/blob/
|
|
2397
|
+
[parseQuery.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/parseQuery.ts#L8)
|
|
2375
2398
|
|
|
2376
2399
|
___
|
|
2377
2400
|
|
|
@@ -2394,7 +2417,7 @@ pascalCase('hello-world') => HelloWorld
|
|
|
2394
2417
|
|
|
2395
2418
|
#### Defined in
|
|
2396
2419
|
|
|
2397
|
-
[pascalCase.ts:8](https://github.com/daysnap/utils/blob/
|
|
2420
|
+
[pascalCase.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/pascalCase.ts#L8)
|
|
2398
2421
|
|
|
2399
2422
|
___
|
|
2400
2423
|
|
|
@@ -2424,7 +2447,7 @@ ___
|
|
|
2424
2447
|
|
|
2425
2448
|
#### Defined in
|
|
2426
2449
|
|
|
2427
|
-
[pick.ts:4](https://github.com/daysnap/utils/blob/
|
|
2450
|
+
[pick.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/pick.ts#L4)
|
|
2428
2451
|
|
|
2429
2452
|
___
|
|
2430
2453
|
|
|
@@ -2447,7 +2470,7 @@ ___
|
|
|
2447
2470
|
|
|
2448
2471
|
#### Defined in
|
|
2449
2472
|
|
|
2450
|
-
[replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/
|
|
2473
|
+
[replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/replaceCrlf.ts#L4)
|
|
2451
2474
|
|
|
2452
2475
|
___
|
|
2453
2476
|
|
|
@@ -2471,7 +2494,7 @@ ___
|
|
|
2471
2494
|
|
|
2472
2495
|
#### Defined in
|
|
2473
2496
|
|
|
2474
|
-
[requestFullScreen.ts:6](https://github.com/daysnap/utils/blob/
|
|
2497
|
+
[requestFullScreen.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/requestFullScreen.ts#L6)
|
|
2475
2498
|
|
|
2476
2499
|
___
|
|
2477
2500
|
|
|
@@ -2497,7 +2520,7 @@ reserve(0, '--') => 0
|
|
|
2497
2520
|
|
|
2498
2521
|
#### Defined in
|
|
2499
2522
|
|
|
2500
|
-
[reserve.ts:8](https://github.com/daysnap/utils/blob/
|
|
2523
|
+
[reserve.ts:8](https://github.com/daysnap/utils/blob/867c3c9/src/reserve.ts#L8)
|
|
2501
2524
|
|
|
2502
2525
|
___
|
|
2503
2526
|
|
|
@@ -2521,7 +2544,7 @@ ___
|
|
|
2521
2544
|
|
|
2522
2545
|
#### Defined in
|
|
2523
2546
|
|
|
2524
|
-
[rgbToHex.ts:4](https://github.com/daysnap/utils/blob/
|
|
2547
|
+
[rgbToHex.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/rgbToHex.ts#L4)
|
|
2525
2548
|
|
|
2526
2549
|
___
|
|
2527
2550
|
|
|
@@ -2544,7 +2567,7 @@ ___
|
|
|
2544
2567
|
|
|
2545
2568
|
#### Defined in
|
|
2546
2569
|
|
|
2547
|
-
[round.ts:6](https://github.com/daysnap/utils/blob/
|
|
2570
|
+
[round.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/round.ts#L6)
|
|
2548
2571
|
|
|
2549
2572
|
___
|
|
2550
2573
|
|
|
@@ -2560,7 +2583,7 @@ ___
|
|
|
2560
2583
|
|
|
2561
2584
|
#### Defined in
|
|
2562
2585
|
|
|
2563
|
-
[scrollToTop.ts:4](https://github.com/daysnap/utils/blob/
|
|
2586
|
+
[scrollToTop.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/scrollToTop.ts#L4)
|
|
2564
2587
|
|
|
2565
2588
|
___
|
|
2566
2589
|
|
|
@@ -2583,7 +2606,7 @@ ___
|
|
|
2583
2606
|
|
|
2584
2607
|
#### Defined in
|
|
2585
2608
|
|
|
2586
|
-
[sleep.ts:6](https://github.com/daysnap/utils/blob/
|
|
2609
|
+
[sleep.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/sleep.ts#L6)
|
|
2587
2610
|
|
|
2588
2611
|
___
|
|
2589
2612
|
|
|
@@ -2612,7 +2635,7 @@ ___
|
|
|
2612
2635
|
|
|
2613
2636
|
#### Defined in
|
|
2614
2637
|
|
|
2615
|
-
[splitArray.ts:4](https://github.com/daysnap/utils/blob/
|
|
2638
|
+
[splitArray.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/splitArray.ts#L4)
|
|
2616
2639
|
|
|
2617
2640
|
___
|
|
2618
2641
|
|
|
@@ -2635,7 +2658,7 @@ ___
|
|
|
2635
2658
|
|
|
2636
2659
|
#### Defined in
|
|
2637
2660
|
|
|
2638
|
-
[stringTrim.ts:6](https://github.com/daysnap/utils/blob/
|
|
2661
|
+
[stringTrim.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/stringTrim.ts#L6)
|
|
2639
2662
|
|
|
2640
2663
|
___
|
|
2641
2664
|
|
|
@@ -2657,13 +2680,13 @@ ___
|
|
|
2657
2680
|
|
|
2658
2681
|
#### Defined in
|
|
2659
2682
|
|
|
2660
|
-
[stringifyQuery.ts:7](https://github.com/daysnap/utils/blob/
|
|
2683
|
+
[stringifyQuery.ts:7](https://github.com/daysnap/utils/blob/867c3c9/src/stringifyQuery.ts#L7)
|
|
2661
2684
|
|
|
2662
2685
|
___
|
|
2663
2686
|
|
|
2664
2687
|
### throttle
|
|
2665
2688
|
|
|
2666
|
-
▸ **throttle**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`
|
|
2689
|
+
▸ **throttle**<`T`\>(`fn`, `ms`, `mode?`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`
|
|
2667
2690
|
|
|
2668
2691
|
节流函数
|
|
2669
2692
|
减少事件执行次数,有规律的执行
|
|
@@ -2676,6 +2699,93 @@ ___
|
|
|
2676
2699
|
|
|
2677
2700
|
#### Parameters
|
|
2678
2701
|
|
|
2702
|
+
| Name | Type | Default value |
|
|
2703
|
+
| :------ | :------ | :------ |
|
|
2704
|
+
| `fn` | `T` | `undefined` |
|
|
2705
|
+
| `ms` | `number` | `undefined` |
|
|
2706
|
+
| `mode` | ``"leading"`` \| ``"trailing"`` | `'trailing'` |
|
|
2707
|
+
|
|
2708
|
+
#### Returns
|
|
2709
|
+
|
|
2710
|
+
`fn`
|
|
2711
|
+
|
|
2712
|
+
▸ (`this`, `...args`): `void`
|
|
2713
|
+
|
|
2714
|
+
##### Parameters
|
|
2715
|
+
|
|
2716
|
+
| Name | Type |
|
|
2717
|
+
| :------ | :------ |
|
|
2718
|
+
| `this` | `unknown` |
|
|
2719
|
+
| `...args` | `Parameters`<`T`\> |
|
|
2720
|
+
|
|
2721
|
+
##### Returns
|
|
2722
|
+
|
|
2723
|
+
`void`
|
|
2724
|
+
|
|
2725
|
+
#### Defined in
|
|
2726
|
+
|
|
2727
|
+
[throttle.ts:48](https://github.com/daysnap/utils/blob/867c3c9/src/throttle.ts#L48)
|
|
2728
|
+
|
|
2729
|
+
___
|
|
2730
|
+
|
|
2731
|
+
### throttleLeading
|
|
2732
|
+
|
|
2733
|
+
▸ **throttleLeading**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`
|
|
2734
|
+
|
|
2735
|
+
节流函数,时间戳模式
|
|
2736
|
+
减少事件执行次数,有规律的执行,事件触发后立即执行
|
|
2737
|
+
|
|
2738
|
+
#### Type parameters
|
|
2739
|
+
|
|
2740
|
+
| Name | Type |
|
|
2741
|
+
| :------ | :------ |
|
|
2742
|
+
| `T` | extends (...`args`: `any`[]) => `any` |
|
|
2743
|
+
|
|
2744
|
+
#### Parameters
|
|
2745
|
+
|
|
2746
|
+
| Name | Type |
|
|
2747
|
+
| :------ | :------ |
|
|
2748
|
+
| `fn` | `T` |
|
|
2749
|
+
| `ms` | `number` |
|
|
2750
|
+
|
|
2751
|
+
#### Returns
|
|
2752
|
+
|
|
2753
|
+
`fn`
|
|
2754
|
+
|
|
2755
|
+
▸ (`this`, `...args`): `void`
|
|
2756
|
+
|
|
2757
|
+
##### Parameters
|
|
2758
|
+
|
|
2759
|
+
| Name | Type |
|
|
2760
|
+
| :------ | :------ |
|
|
2761
|
+
| `this` | `unknown` |
|
|
2762
|
+
| `...args` | `Parameters`<`T`\> |
|
|
2763
|
+
|
|
2764
|
+
##### Returns
|
|
2765
|
+
|
|
2766
|
+
`void`
|
|
2767
|
+
|
|
2768
|
+
#### Defined in
|
|
2769
|
+
|
|
2770
|
+
[throttle.ts:5](https://github.com/daysnap/utils/blob/867c3c9/src/throttle.ts#L5)
|
|
2771
|
+
|
|
2772
|
+
___
|
|
2773
|
+
|
|
2774
|
+
### throttleTrailing
|
|
2775
|
+
|
|
2776
|
+
▸ **throttleTrailing**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`
|
|
2777
|
+
|
|
2778
|
+
节流函数,定时器模式
|
|
2779
|
+
减少事件执行次数,有规律的执行,事件触发后延迟执行
|
|
2780
|
+
|
|
2781
|
+
#### Type parameters
|
|
2782
|
+
|
|
2783
|
+
| Name | Type |
|
|
2784
|
+
| :------ | :------ |
|
|
2785
|
+
| `T` | extends (...`args`: `any`[]) => `any` |
|
|
2786
|
+
|
|
2787
|
+
#### Parameters
|
|
2788
|
+
|
|
2679
2789
|
| Name | Type |
|
|
2680
2790
|
| :------ | :------ |
|
|
2681
2791
|
| `fn` | `T` |
|
|
@@ -2700,7 +2810,7 @@ ___
|
|
|
2700
2810
|
|
|
2701
2811
|
#### Defined in
|
|
2702
2812
|
|
|
2703
|
-
[throttle.ts:
|
|
2813
|
+
[throttle.ts:25](https://github.com/daysnap/utils/blob/867c3c9/src/throttle.ts#L25)
|
|
2704
2814
|
|
|
2705
2815
|
___
|
|
2706
2816
|
|
|
@@ -2722,7 +2832,7 @@ ___
|
|
|
2722
2832
|
|
|
2723
2833
|
#### Defined in
|
|
2724
2834
|
|
|
2725
|
-
[toCDB.ts:4](https://github.com/daysnap/utils/blob/
|
|
2835
|
+
[toCDB.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/toCDB.ts#L4)
|
|
2726
2836
|
|
|
2727
2837
|
___
|
|
2728
2838
|
|
|
@@ -2744,7 +2854,7 @@ ___
|
|
|
2744
2854
|
|
|
2745
2855
|
#### Defined in
|
|
2746
2856
|
|
|
2747
|
-
[toDBC.ts:4](https://github.com/daysnap/utils/blob/
|
|
2857
|
+
[toDBC.ts:4](https://github.com/daysnap/utils/blob/867c3c9/src/toDBC.ts#L4)
|
|
2748
2858
|
|
|
2749
2859
|
___
|
|
2750
2860
|
|
|
@@ -2768,4 +2878,4 @@ ___
|
|
|
2768
2878
|
|
|
2769
2879
|
#### Defined in
|
|
2770
2880
|
|
|
2771
|
-
[typeOf.ts:6](https://github.com/daysnap/utils/blob/
|
|
2881
|
+
[typeOf.ts:6](https://github.com/daysnap/utils/blob/867c3c9/src/typeOf.ts#L6)
|
package/es/formartDateToZN.js
CHANGED
|
@@ -9,7 +9,6 @@ export function formatDateToZN(v) {
|
|
|
9
9
|
const hours = Math.floor(minutes / 60);
|
|
10
10
|
const days = Math.floor(hours / 24);
|
|
11
11
|
const weeks = Math.floor(days / 7);
|
|
12
|
-
console.log(diff, seconds, minutes, hours, days, weeks);
|
|
13
12
|
// 判断时间间隔,并返回相应的表示方式
|
|
14
13
|
if (weeks >= 4) {
|
|
15
14
|
return formatDate(timestamp, 'yyyy-MM-dd hh:mm');
|
package/es/throttle.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节流函数,时间戳模式
|
|
3
|
+
* 减少事件执行次数,有规律的执行,事件触发后立即执行
|
|
4
|
+
*/
|
|
5
|
+
export declare function throttleLeading<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
6
|
+
/**
|
|
7
|
+
* 节流函数,定时器模式
|
|
8
|
+
* 减少事件执行次数,有规律的执行,事件触发后延迟执行
|
|
9
|
+
*/
|
|
10
|
+
export declare function throttleTrailing<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
1
11
|
/**
|
|
2
12
|
* 节流函数
|
|
3
13
|
* 减少事件执行次数,有规律的执行
|
|
4
14
|
*/
|
|
5
|
-
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
15
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number, mode?: 'leading' | 'trailing'): (this: unknown, ...args: Parameters<T>) => void;
|
package/es/throttle.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* 节流函数,时间戳模式
|
|
3
|
+
* 减少事件执行次数,有规律的执行,事件触发后立即执行
|
|
4
4
|
*/
|
|
5
|
-
export function
|
|
5
|
+
export function throttleLeading(fn, ms) {
|
|
6
|
+
let pre = 0;
|
|
7
|
+
// eslint-disable-next-line func-names
|
|
8
|
+
return function (...args) {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
if (now - pre >= ms) {
|
|
11
|
+
fn.apply(this, args);
|
|
12
|
+
pre = now;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 节流函数,定时器模式
|
|
18
|
+
* 减少事件执行次数,有规律的执行,事件触发后延迟执行
|
|
19
|
+
*/
|
|
20
|
+
export function throttleTrailing(fn, ms) {
|
|
6
21
|
let timer = null;
|
|
7
22
|
// eslint-disable-next-line func-names
|
|
8
23
|
return function (...args) {
|
|
@@ -15,3 +30,10 @@ export function throttle(fn, ms) {
|
|
|
15
30
|
}, ms);
|
|
16
31
|
};
|
|
17
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* 节流函数
|
|
35
|
+
* 减少事件执行次数,有规律的执行
|
|
36
|
+
*/
|
|
37
|
+
export function throttle(fn, ms, mode = 'trailing') {
|
|
38
|
+
return mode === 'leading' ? throttleLeading(fn, ms) : throttleTrailing(fn, ms);
|
|
39
|
+
}
|
package/lib/formartDateToZN.js
CHANGED
|
@@ -12,7 +12,6 @@ function formatDateToZN(v) {
|
|
|
12
12
|
const hours = Math.floor(minutes / 60);
|
|
13
13
|
const days = Math.floor(hours / 24);
|
|
14
14
|
const weeks = Math.floor(days / 7);
|
|
15
|
-
console.log(diff, seconds, minutes, hours, days, weeks);
|
|
16
15
|
// 判断时间间隔,并返回相应的表示方式
|
|
17
16
|
if (weeks >= 4) {
|
|
18
17
|
return (0, index_1.formatDate)(timestamp, 'yyyy-MM-dd hh:mm');
|
package/lib/throttle.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节流函数,时间戳模式
|
|
3
|
+
* 减少事件执行次数,有规律的执行,事件触发后立即执行
|
|
4
|
+
*/
|
|
5
|
+
export declare function throttleLeading<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
6
|
+
/**
|
|
7
|
+
* 节流函数,定时器模式
|
|
8
|
+
* 减少事件执行次数,有规律的执行,事件触发后延迟执行
|
|
9
|
+
*/
|
|
10
|
+
export declare function throttleTrailing<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
1
11
|
/**
|
|
2
12
|
* 节流函数
|
|
3
13
|
* 减少事件执行次数,有规律的执行
|
|
4
14
|
*/
|
|
5
|
-
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
15
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number, mode?: 'leading' | 'trailing'): (this: unknown, ...args: Parameters<T>) => void;
|
package/lib/throttle.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttle = void 0;
|
|
3
|
+
exports.throttle = exports.throttleTrailing = exports.throttleLeading = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* 节流函数,时间戳模式
|
|
6
|
+
* 减少事件执行次数,有规律的执行,事件触发后立即执行
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function throttleLeading(fn, ms) {
|
|
9
|
+
let pre = 0;
|
|
10
|
+
// eslint-disable-next-line func-names
|
|
11
|
+
return function (...args) {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
if (now - pre >= ms) {
|
|
14
|
+
fn.apply(this, args);
|
|
15
|
+
pre = now;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.throttleLeading = throttleLeading;
|
|
20
|
+
/**
|
|
21
|
+
* 节流函数,定时器模式
|
|
22
|
+
* 减少事件执行次数,有规律的执行,事件触发后延迟执行
|
|
23
|
+
*/
|
|
24
|
+
function throttleTrailing(fn, ms) {
|
|
9
25
|
let timer = null;
|
|
10
26
|
// eslint-disable-next-line func-names
|
|
11
27
|
return function (...args) {
|
|
@@ -18,4 +34,12 @@ function throttle(fn, ms) {
|
|
|
18
34
|
}, ms);
|
|
19
35
|
};
|
|
20
36
|
}
|
|
37
|
+
exports.throttleTrailing = throttleTrailing;
|
|
38
|
+
/**
|
|
39
|
+
* 节流函数
|
|
40
|
+
* 减少事件执行次数,有规律的执行
|
|
41
|
+
*/
|
|
42
|
+
function throttle(fn, ms, mode = 'trailing') {
|
|
43
|
+
return mode === 'leading' ? throttleLeading(fn, ms) : throttleTrailing(fn, ms);
|
|
44
|
+
}
|
|
21
45
|
exports.throttle = throttle;
|