@daysnap/utils 0.0.35 → 0.0.36

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/modules.md CHANGED
@@ -15,6 +15,7 @@
15
15
  - [downloadFile](modules.md#downloadfile)
16
16
  - [each](modules.md#each)
17
17
  - [filterBankCardNo](modules.md#filterbankcardno)
18
+ - [filterCRLF](modules.md#filtercrlf)
18
19
  - [filterEmoji](modules.md#filteremoji)
19
20
  - [filterIdCard](modules.md#filteridcard)
20
21
  - [filterName](modules.md#filtername)
@@ -26,9 +27,11 @@
26
27
  - [getDayMillisecond](modules.md#getdaymillisecond)
27
28
  - [getImageInfo](modules.md#getimageinfo)
28
29
  - [getLocal](modules.md#getlocal)
30
+ - [getRandomColor](modules.md#getrandomcolor)
29
31
  - [getVideoInfo](modules.md#getvideoinfo)
30
32
  - [inBrowser](modules.md#inbrowser)
31
33
  - [isAndroid](modules.md#isandroid)
34
+ - [isArray](modules.md#isarray)
32
35
  - [isBoolean](modules.md#isboolean)
33
36
  - [isEmail](modules.md#isemail)
34
37
  - [isEmpty](modules.md#isempty)
@@ -49,7 +52,9 @@
49
52
  - [isRegExp](modules.md#isregexp)
50
53
  - [isString](modules.md#isstring)
51
54
  - [isUndefined](modules.md#isundefined)
55
+ - [isWeixin](modules.md#isweixin)
52
56
  - [isWindow](modules.md#iswindow)
57
+ - [loadResource](modules.md#loadresource)
53
58
  - [omit](modules.md#omit)
54
59
  - [parseDate](modules.md#parsedate)
55
60
  - [parseError](modules.md#parseerror)
@@ -60,7 +65,9 @@
60
65
  - [reserve](modules.md#reserve)
61
66
  - [round](modules.md#round)
62
67
  - [sleep](modules.md#sleep)
68
+ - [stringTrim](modules.md#stringtrim)
63
69
  - [stringifyQuery](modules.md#stringifyquery)
70
+ - [typeOf](modules.md#typeof)
64
71
 
65
72
  ## Functions
66
73
 
@@ -83,7 +90,7 @@ base64 转 blob
83
90
 
84
91
  #### Defined in
85
92
 
86
- [base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/base64ToBlob.ts#L6)
93
+ [base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/base64ToBlob.ts#L6)
87
94
 
88
95
  ___
89
96
 
@@ -105,7 +112,7 @@ blob 转 base64
105
112
 
106
113
  #### Defined in
107
114
 
108
- [blobToBase64.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/blobToBase64.ts#L4)
115
+ [blobToBase64.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/blobToBase64.ts#L4)
109
116
 
110
117
  ___
111
118
 
@@ -133,7 +140,7 @@ ___
133
140
 
134
141
  #### Defined in
135
142
 
136
- [clone.ts:7](https://github.com/daysnap/utils/blob/b7c7b79/src/clone.ts#L7)
143
+ [clone.ts:7](https://github.com/daysnap/utils/blob/ce2c582/src/clone.ts#L7)
137
144
 
138
145
  ___
139
146
 
@@ -155,7 +162,7 @@ ___
155
162
 
156
163
  #### Defined in
157
164
 
158
- [createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/createHexColorByHash.ts#L4)
165
+ [createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/createHexColorByHash.ts#L4)
159
166
 
160
167
  ___
161
168
 
@@ -181,7 +188,7 @@ ___
181
188
 
182
189
  #### Defined in
183
190
 
184
- [compareVersion.ts:9](https://github.com/daysnap/utils/blob/b7c7b79/src/compareVersion.ts#L9)
191
+ [compareVersion.ts:9](https://github.com/daysnap/utils/blob/ce2c582/src/compareVersion.ts#L9)
185
192
 
186
193
  ___
187
194
 
@@ -203,7 +210,7 @@ ___
203
210
 
204
211
  #### Defined in
205
212
 
206
- [compressImage.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/compressImage.ts#L6)
213
+ [compressImage.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/compressImage.ts#L6)
207
214
 
208
215
  ___
209
216
 
@@ -227,7 +234,7 @@ ___
227
234
 
228
235
  #### Defined in
229
236
 
230
- [downloadFile.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/downloadFile.ts#L4)
237
+ [downloadFile.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/downloadFile.ts#L4)
231
238
 
232
239
  ___
233
240
 
@@ -256,7 +263,7 @@ ___
256
263
 
257
264
  #### Defined in
258
265
 
259
- [each.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/each.ts#L4)
266
+ [each.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/each.ts#L4)
260
267
 
261
268
  ▸ **each**<`T`\>(`data`, `callback`): `void`
262
269
 
@@ -279,7 +286,7 @@ ___
279
286
 
280
287
  #### Defined in
281
288
 
282
- [each.ts:8](https://github.com/daysnap/utils/blob/b7c7b79/src/each.ts#L8)
289
+ [each.ts:8](https://github.com/daysnap/utils/blob/ce2c582/src/each.ts#L8)
283
290
 
284
291
  ___
285
292
 
@@ -301,7 +308,29 @@ ___
301
308
 
302
309
  #### Defined in
303
310
 
304
- [filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/filterBankCardNo.ts#L4)
311
+ [filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/filterBankCardNo.ts#L4)
312
+
313
+ ___
314
+
315
+ ### filterCRLF
316
+
317
+ ▸ **filterCRLF**(`v`): `string`
318
+
319
+ 替换字符串里面的回车换行符
320
+
321
+ #### Parameters
322
+
323
+ | Name | Type |
324
+ | :------ | :------ |
325
+ | `v` | `string` |
326
+
327
+ #### Returns
328
+
329
+ `string`
330
+
331
+ #### Defined in
332
+
333
+ [filterCRLF.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/filterCRLF.ts#L4)
305
334
 
306
335
  ___
307
336
 
@@ -323,7 +352,7 @@ ___
323
352
 
324
353
  #### Defined in
325
354
 
326
- [filterEmoji.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/filterEmoji.ts#L4)
355
+ [filterEmoji.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/filterEmoji.ts#L4)
327
356
 
328
357
  ___
329
358
 
@@ -345,7 +374,7 @@ ___
345
374
 
346
375
  #### Defined in
347
376
 
348
- [filterIdCard.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/filterIdCard.ts#L4)
377
+ [filterIdCard.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/filterIdCard.ts#L4)
349
378
 
350
379
  ___
351
380
 
@@ -367,7 +396,7 @@ ___
367
396
 
368
397
  #### Defined in
369
398
 
370
- [filterName.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/filterName.ts#L4)
399
+ [filterName.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/filterName.ts#L4)
371
400
 
372
401
  ___
373
402
 
@@ -392,7 +421,7 @@ filterPhone('13177778888', ' ') => 131 **** 8888
392
421
 
393
422
  #### Defined in
394
423
 
395
- [filterPhone.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/filterPhone.ts#L6)
424
+ [filterPhone.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/filterPhone.ts#L6)
396
425
 
397
426
  ___
398
427
 
@@ -415,7 +444,7 @@ ___
415
444
 
416
445
  #### Defined in
417
446
 
418
- [formatAmount.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/formatAmount.ts#L4)
447
+ [formatAmount.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/formatAmount.ts#L4)
419
448
 
420
449
  ___
421
450
 
@@ -438,7 +467,7 @@ ___
438
467
 
439
468
  #### Defined in
440
469
 
441
- [formatDate.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/formatDate.ts#L6)
470
+ [formatDate.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/formatDate.ts#L6)
442
471
 
443
472
  ___
444
473
 
@@ -460,7 +489,7 @@ ___
460
489
 
461
490
  #### Defined in
462
491
 
463
- [getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/getBlobByUrl.ts#L4)
492
+ [getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/getBlobByUrl.ts#L4)
464
493
 
465
494
  ___
466
495
 
@@ -483,7 +512,7 @@ ___
483
512
 
484
513
  #### Defined in
485
514
 
486
- [storage/index.ts:7](https://github.com/daysnap/utils/blob/b7c7b79/src/storage/index.ts#L7)
515
+ [storage/index.ts:7](https://github.com/daysnap/utils/blob/ce2c582/src/storage/index.ts#L7)
487
516
 
488
517
  ___
489
518
 
@@ -505,7 +534,7 @@ ___
505
534
 
506
535
  #### Defined in
507
536
 
508
- [getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/getDayMillisecond.ts#L4)
537
+ [getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/getDayMillisecond.ts#L4)
509
538
 
510
539
  ___
511
540
 
@@ -527,7 +556,7 @@ ___
527
556
 
528
557
  #### Defined in
529
558
 
530
- [getImageInfo.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/getImageInfo.ts#L4)
559
+ [getImageInfo.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/getImageInfo.ts#L4)
531
560
 
532
561
  ___
533
562
 
@@ -550,7 +579,23 @@ ___
550
579
 
551
580
  #### Defined in
552
581
 
553
- [storage/index.ts:7](https://github.com/daysnap/utils/blob/b7c7b79/src/storage/index.ts#L7)
582
+ [storage/index.ts:7](https://github.com/daysnap/utils/blob/ce2c582/src/storage/index.ts#L7)
583
+
584
+ ___
585
+
586
+ ### getRandomColor
587
+
588
+ ▸ **getRandomColor**(): `string`
589
+
590
+ 随机颜色
591
+
592
+ #### Returns
593
+
594
+ `string`
595
+
596
+ #### Defined in
597
+
598
+ [getRandomColor.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/getRandomColor.ts#L4)
554
599
 
555
600
  ___
556
601
 
@@ -572,7 +617,7 @@ ___
572
617
 
573
618
  #### Defined in
574
619
 
575
- [getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/getVideoInfo.ts#L4)
620
+ [getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/getVideoInfo.ts#L4)
576
621
 
577
622
  ___
578
623
 
@@ -588,7 +633,7 @@ ___
588
633
 
589
634
  #### Defined in
590
635
 
591
- [inBrowser.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/inBrowser.ts#L4)
636
+ [inBrowser.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/inBrowser.ts#L4)
592
637
 
593
638
  ___
594
639
 
@@ -604,7 +649,31 @@ ___
604
649
 
605
650
  #### Defined in
606
651
 
607
- [isAndroid.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isAndroid.ts#L4)
652
+ [isAndroid.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isAndroid.ts#L4)
653
+
654
+ ___
655
+
656
+ ### isArray
657
+
658
+ ▸ **isArray**(`val`): val is any[]
659
+
660
+ 判断是否是数组
661
+
662
+ #### Parameters
663
+
664
+ | Name | Type | Description |
665
+ | :------ | :------ | :------ |
666
+ | `val` | `unknown` | 待判断值 |
667
+
668
+ #### Returns
669
+
670
+ val is any[]
671
+
672
+ 是否
673
+
674
+ #### Defined in
675
+
676
+ [isArray.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/isArray.ts#L6)
608
677
 
609
678
  ___
610
679
 
@@ -626,7 +695,7 @@ val is boolean
626
695
 
627
696
  #### Defined in
628
697
 
629
- isBoolean.ts:5
698
+ [isBoolean.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isBoolean.ts#L5)
630
699
 
631
700
  ___
632
701
 
@@ -648,7 +717,7 @@ ___
648
717
 
649
718
  #### Defined in
650
719
 
651
- [isEmail.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isEmail.ts#L4)
720
+ [isEmail.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isEmail.ts#L4)
652
721
 
653
722
  ___
654
723
 
@@ -670,7 +739,7 @@ ___
670
739
 
671
740
  #### Defined in
672
741
 
673
- [isEmpty.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/isEmpty.ts#L6)
742
+ [isEmpty.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/isEmpty.ts#L6)
674
743
 
675
744
  ___
676
745
 
@@ -692,7 +761,7 @@ ___
692
761
 
693
762
  #### Defined in
694
763
 
695
- [isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/b7c7b79/src/isEmptyObject.ts#L5)
764
+ [isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isEmptyObject.ts#L5)
696
765
 
697
766
  ___
698
767
 
@@ -714,7 +783,7 @@ val is Error
714
783
 
715
784
  #### Defined in
716
785
 
717
- [isError.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isError.ts#L4)
786
+ [isError.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isError.ts#L4)
718
787
 
719
788
  ___
720
789
 
@@ -736,7 +805,7 @@ val is Function
736
805
 
737
806
  #### Defined in
738
807
 
739
- [isFunction.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isFunction.ts#L4)
808
+ [isFunction.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isFunction.ts#L4)
740
809
 
741
810
  ___
742
811
 
@@ -752,7 +821,7 @@ ___
752
821
 
753
822
  #### Defined in
754
823
 
755
- [isIOS.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isIOS.ts#L4)
824
+ [isIOS.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isIOS.ts#L4)
756
825
 
757
826
  ___
758
827
 
@@ -774,7 +843,7 @@ ___
774
843
 
775
844
  #### Defined in
776
845
 
777
- [isIdCard.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isIdCard.ts#L4)
846
+ [isIdCard.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isIdCard.ts#L4)
778
847
 
779
848
  ___
780
849
 
@@ -796,7 +865,7 @@ ___
796
865
 
797
866
  #### Defined in
798
867
 
799
- [isJSONString.ts:7](https://github.com/daysnap/utils/blob/b7c7b79/src/isJSONString.ts#L7)
868
+ [isJSONString.ts:7](https://github.com/daysnap/utils/blob/ce2c582/src/isJSONString.ts#L7)
800
869
 
801
870
  ___
802
871
 
@@ -818,7 +887,7 @@ ___
818
887
 
819
888
  #### Defined in
820
889
 
821
- [isLan.ts:5](https://github.com/daysnap/utils/blob/b7c7b79/src/isLan.ts#L5)
890
+ [isLan.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isLan.ts#L5)
822
891
 
823
892
  ___
824
893
 
@@ -840,7 +909,7 @@ ___
840
909
 
841
910
  #### Defined in
842
911
 
843
- [isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/b7c7b79/src/isLicenseCode.ts#L5)
912
+ [isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isLicenseCode.ts#L5)
844
913
 
845
914
  ___
846
915
 
@@ -856,7 +925,7 @@ ___
856
925
 
857
926
  #### Defined in
858
927
 
859
- [isMobile.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isMobile.ts#L4)
928
+ [isMobile.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isMobile.ts#L4)
860
929
 
861
930
  ___
862
931
 
@@ -878,7 +947,7 @@ val is null
878
947
 
879
948
  #### Defined in
880
949
 
881
- [isNull.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isNull.ts#L4)
950
+ [isNull.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isNull.ts#L4)
882
951
 
883
952
  ___
884
953
 
@@ -900,7 +969,7 @@ val is number
900
969
 
901
970
  #### Defined in
902
971
 
903
- [isNumber.ts:5](https://github.com/daysnap/utils/blob/b7c7b79/src/isNumber.ts#L5)
972
+ [isNumber.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isNumber.ts#L5)
904
973
 
905
974
  ___
906
975
 
@@ -922,7 +991,7 @@ val is Record<string, any\>
922
991
 
923
992
  #### Defined in
924
993
 
925
- [isObject.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isObject.ts#L4)
994
+ [isObject.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isObject.ts#L4)
926
995
 
927
996
  ___
928
997
 
@@ -944,7 +1013,7 @@ ___
944
1013
 
945
1014
  #### Defined in
946
1015
 
947
- [isPhone.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isPhone.ts#L4)
1016
+ [isPhone.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isPhone.ts#L4)
948
1017
 
949
1018
  ___
950
1019
 
@@ -972,7 +1041,7 @@ val is Promise<T\>
972
1041
 
973
1042
  #### Defined in
974
1043
 
975
- [isPromise.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isPromise.ts#L4)
1044
+ [isPromise.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isPromise.ts#L4)
976
1045
 
977
1046
  ___
978
1047
 
@@ -994,7 +1063,7 @@ val is RegExp
994
1063
 
995
1064
  #### Defined in
996
1065
 
997
- [isRegExp.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isRegExp.ts#L4)
1066
+ [isRegExp.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isRegExp.ts#L4)
998
1067
 
999
1068
  ___
1000
1069
 
@@ -1016,7 +1085,7 @@ val is string
1016
1085
 
1017
1086
  #### Defined in
1018
1087
 
1019
- [isString.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isString.ts#L4)
1088
+ [isString.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isString.ts#L4)
1020
1089
 
1021
1090
  ___
1022
1091
 
@@ -1038,7 +1107,23 @@ val is undefined
1038
1107
 
1039
1108
  #### Defined in
1040
1109
 
1041
- [isUndefined.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/isUndefined.ts#L4)
1110
+ [isUndefined.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isUndefined.ts#L4)
1111
+
1112
+ ___
1113
+
1114
+ ### isWeixin
1115
+
1116
+ ▸ **isWeixin**(): `boolean`
1117
+
1118
+ 是否是微信环境
1119
+
1120
+ #### Returns
1121
+
1122
+ `boolean`
1123
+
1124
+ #### Defined in
1125
+
1126
+ [isWeixin.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/isWeixin.ts#L4)
1042
1127
 
1043
1128
  ___
1044
1129
 
@@ -1060,7 +1145,31 @@ val is Window
1060
1145
 
1061
1146
  #### Defined in
1062
1147
 
1063
- [isWindow.ts:5](https://github.com/daysnap/utils/blob/b7c7b79/src/isWindow.ts#L5)
1148
+ [isWindow.ts:5](https://github.com/daysnap/utils/blob/ce2c582/src/isWindow.ts#L5)
1149
+
1150
+ ___
1151
+
1152
+ ### loadResource
1153
+
1154
+ ▸ **loadResource**(`res`, `type`, `callback?`): `void`
1155
+
1156
+ 加载外部js、css、写入style样式
1157
+
1158
+ #### Parameters
1159
+
1160
+ | Name | Type | Description |
1161
+ | :------ | :------ | :------ |
1162
+ | `res` | `string` | 资源url或内容 |
1163
+ | `type` | ``"style"`` \| ``"js"`` \| ``"css"`` | 类型 |
1164
+ | `callback?` | `any` | 回调函数 |
1165
+
1166
+ #### Returns
1167
+
1168
+ `void`
1169
+
1170
+ #### Defined in
1171
+
1172
+ [loadResource.ts:9](https://github.com/daysnap/utils/blob/ce2c582/src/loadResource.ts#L9)
1064
1173
 
1065
1174
  ___
1066
1175
 
@@ -1090,7 +1199,7 @@ ___
1090
1199
 
1091
1200
  #### Defined in
1092
1201
 
1093
- [omit.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/omit.ts#L4)
1202
+ [omit.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/omit.ts#L4)
1094
1203
 
1095
1204
  ___
1096
1205
 
@@ -1112,7 +1221,7 @@ ___
1112
1221
 
1113
1222
  #### Defined in
1114
1223
 
1115
- [parseDate.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/parseDate.ts#L4)
1224
+ [parseDate.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/parseDate.ts#L4)
1116
1225
 
1117
1226
  ___
1118
1227
 
@@ -1135,7 +1244,7 @@ ___
1135
1244
 
1136
1245
  #### Defined in
1137
1246
 
1138
- [parseError.ts:8](https://github.com/daysnap/utils/blob/b7c7b79/src/parseError.ts#L8)
1247
+ [parseError.ts:8](https://github.com/daysnap/utils/blob/ce2c582/src/parseError.ts#L8)
1139
1248
 
1140
1249
  ___
1141
1250
 
@@ -1164,7 +1273,7 @@ ___
1164
1273
 
1165
1274
  #### Defined in
1166
1275
 
1167
- [parsePath.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/parsePath.ts#L4)
1276
+ [parsePath.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/parsePath.ts#L4)
1168
1277
 
1169
1278
  ___
1170
1279
 
@@ -1187,7 +1296,7 @@ ___
1187
1296
 
1188
1297
  #### Defined in
1189
1298
 
1190
- [parseQuery.ts:8](https://github.com/daysnap/utils/blob/b7c7b79/src/parseQuery.ts#L8)
1299
+ [parseQuery.ts:8](https://github.com/daysnap/utils/blob/ce2c582/src/parseQuery.ts#L8)
1191
1300
 
1192
1301
  ___
1193
1302
 
@@ -1217,7 +1326,7 @@ ___
1217
1326
 
1218
1327
  #### Defined in
1219
1328
 
1220
- [pick.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/pick.ts#L4)
1329
+ [pick.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/pick.ts#L4)
1221
1330
 
1222
1331
  ___
1223
1332
 
@@ -1240,7 +1349,7 @@ ___
1240
1349
 
1241
1350
  #### Defined in
1242
1351
 
1243
- [replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/replaceCrlf.ts#L4)
1352
+ [replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/replaceCrlf.ts#L4)
1244
1353
 
1245
1354
  ___
1246
1355
 
@@ -1266,7 +1375,7 @@ reserve(0, '--') => 0
1266
1375
 
1267
1376
  #### Defined in
1268
1377
 
1269
- [reserve.ts:8](https://github.com/daysnap/utils/blob/b7c7b79/src/reserve.ts#L8)
1378
+ [reserve.ts:8](https://github.com/daysnap/utils/blob/ce2c582/src/reserve.ts#L8)
1270
1379
 
1271
1380
  ___
1272
1381
 
@@ -1289,7 +1398,7 @@ ___
1289
1398
 
1290
1399
  #### Defined in
1291
1400
 
1292
- [round.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/round.ts#L6)
1401
+ [round.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/round.ts#L6)
1293
1402
 
1294
1403
  ___
1295
1404
 
@@ -1312,7 +1421,30 @@ ___
1312
1421
 
1313
1422
  #### Defined in
1314
1423
 
1315
- [sleep.ts:4](https://github.com/daysnap/utils/blob/b7c7b79/src/sleep.ts#L4)
1424
+ [sleep.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/sleep.ts#L4)
1425
+
1426
+ ___
1427
+
1428
+ ### stringTrim
1429
+
1430
+ ▸ **stringTrim**(`str`, `type?`): `string`
1431
+
1432
+ 去除字符串空格
1433
+
1434
+ #### Parameters
1435
+
1436
+ | Name | Type |
1437
+ | :------ | :------ |
1438
+ | `str` | `string` |
1439
+ | `type?` | ``1`` \| ``2`` \| ``3`` \| ``4`` |
1440
+
1441
+ #### Returns
1442
+
1443
+ `string`
1444
+
1445
+ #### Defined in
1446
+
1447
+ [stringTrim.ts:4](https://github.com/daysnap/utils/blob/ce2c582/src/stringTrim.ts#L4)
1316
1448
 
1317
1449
  ___
1318
1450
 
@@ -1334,4 +1466,34 @@ ___
1334
1466
 
1335
1467
  #### Defined in
1336
1468
 
1337
- [stringifyQuery.ts:6](https://github.com/daysnap/utils/blob/b7c7b79/src/stringifyQuery.ts#L6)
1469
+ [stringifyQuery.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/stringifyQuery.ts#L6)
1470
+
1471
+ ___
1472
+
1473
+ ### typeOf
1474
+
1475
+ ▸ **typeOf**<`T`\>(`val`): val is T
1476
+
1477
+ 判断类型
1478
+
1479
+ #### Type parameters
1480
+
1481
+ | Name |
1482
+ | :------ |
1483
+ | `T` |
1484
+
1485
+ #### Parameters
1486
+
1487
+ | Name | Type | Description |
1488
+ | :------ | :------ | :------ |
1489
+ | `val` | `T` | 待判断数据 |
1490
+
1491
+ #### Returns
1492
+
1493
+ val is T
1494
+
1495
+ 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
1496
+
1497
+ #### Defined in
1498
+
1499
+ [typeOf.ts:6](https://github.com/daysnap/utils/blob/ce2c582/src/typeOf.ts#L6)
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 替换字符串里面的回车换行符
3
+ */
4
+ export declare function filterCRLF(v: string): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 替换字符串里面的回车换行符
3
+ */
4
+ export function filterCRLF(v) {
5
+ return v.replace(/\r|\n/gi, '<br/>');
6
+ }
@@ -17,5 +17,6 @@ export function getBlobByUrl(url) {
17
17
  reject(new Error("".concat(statusText, "[").concat(status, "]")));
18
18
  }
19
19
  };
20
+ xhr.send();
20
21
  });
21
22
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 随机颜色
3
+ */
4
+ export declare function getRandomColor(): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 随机颜色
3
+ */
4
+ export function getRandomColor() {
5
+ return "#".concat(Math.floor(Math.random() * 0xffffff).toString(16));
6
+ }
package/es/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './createHexColorByHash';
7
7
  export * from './downloadFile';
8
8
  export * from './each';
9
9
  export * from './filterBankCardNo';
10
+ export * from './filterCRLF';
10
11
  export * from './filterEmoji';
11
12
  export * from './filterIdCard';
12
13
  export * from './filterName';
@@ -16,9 +17,11 @@ export * from './formatDate';
16
17
  export * from './getBlobByUrl';
17
18
  export * from './getDayMillisecond';
18
19
  export * from './getImageInfo';
20
+ export * from './getRandomColor';
19
21
  export * from './getVideoInfo';
20
22
  export * from './inBrowser';
21
23
  export * from './isAndroid';
24
+ export * from './isArray';
22
25
  export * from './isBoolean';
23
26
  export * from './isEmail';
24
27
  export * from './isEmpty';
@@ -39,7 +42,9 @@ export * from './isPromise';
39
42
  export * from './isRegExp';
40
43
  export * from './isString';
41
44
  export * from './isUndefined';
45
+ export * from './isWeixin';
42
46
  export * from './isWindow';
47
+ export * from './loadResource';
43
48
  export * from './omit';
44
49
  export * from './parseDate';
45
50
  export * from './parseError';
@@ -51,4 +56,6 @@ export * from './reserve';
51
56
  export * from './round';
52
57
  export * from './sleep';
53
58
  export * from './storage';
59
+ export * from './stringTrim';
54
60
  export * from './stringifyQuery';
61
+ export * from './typeOf';
package/es/index.js CHANGED
@@ -8,6 +8,7 @@ export * from './createHexColorByHash';
8
8
  export * from './downloadFile';
9
9
  export * from './each';
10
10
  export * from './filterBankCardNo';
11
+ export * from './filterCRLF';
11
12
  export * from './filterEmoji';
12
13
  export * from './filterIdCard';
13
14
  export * from './filterName';
@@ -17,9 +18,11 @@ export * from './formatDate';
17
18
  export * from './getBlobByUrl';
18
19
  export * from './getDayMillisecond';
19
20
  export * from './getImageInfo';
21
+ export * from './getRandomColor';
20
22
  export * from './getVideoInfo';
21
23
  export * from './inBrowser';
22
24
  export * from './isAndroid';
25
+ export * from './isArray';
23
26
  export * from './isBoolean';
24
27
  export * from './isEmail';
25
28
  export * from './isEmpty';
@@ -40,7 +43,9 @@ export * from './isPromise';
40
43
  export * from './isRegExp';
41
44
  export * from './isString';
42
45
  export * from './isUndefined';
46
+ export * from './isWeixin';
43
47
  export * from './isWindow';
48
+ export * from './loadResource';
44
49
  export * from './omit';
45
50
  export * from './parseDate';
46
51
  export * from './parseError';
@@ -52,4 +57,6 @@ export * from './reserve';
52
57
  export * from './round';
53
58
  export * from './sleep';
54
59
  export * from './storage';
55
- export * from './stringifyQuery';
60
+ export * from './stringTrim';
61
+ export * from './stringifyQuery';
62
+ export * from './typeOf';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断是否是数组
3
+ * @param val 待判断值
4
+ * @returns 是否
5
+ */
6
+ export declare function isArray(val: unknown): val is any[];
package/es/isArray.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是数组
3
+ * @param val 待判断值
4
+ * @returns 是否
5
+ */
6
+ export function isArray(val) {
7
+ return Array.isArray(val);
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 是否是微信环境
3
+ */
4
+ export declare function isWeixin(): boolean;
package/es/isWeixin.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 是否是微信环境
3
+ */
4
+ export function isWeixin() {
5
+ return /MicroMessenger/gi.test(navigator.userAgent);
6
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 加载外部js、css、写入style样式
3
+ * @param res 资源url或内容
4
+ * @param type 类型
5
+ * @param callback 回调函数
6
+ */
7
+ export declare function loadResource(res: string, type: 'js' | 'css' | 'style', callback?: any): void;
@@ -0,0 +1,31 @@
1
+ import { isFunction } from './isFunction';
2
+ /**
3
+ * 加载外部js、css、写入style样式
4
+ * @param res 资源url或内容
5
+ * @param type 类型
6
+ * @param callback 回调函数
7
+ */
8
+ export function loadResource(res, type, callback) {
9
+ var ref;
10
+ if (type === 'js') {
11
+ // 外部js
12
+ ref = document.createElement('js');
13
+ ref.setAttribute('type', 'text/javascript');
14
+ ref.setAttribute('src', res);
15
+ } else if (type === 'css') {
16
+ // 外部css
17
+ ref = document.createElement('link');
18
+ ref.setAttribute('rel', 'stylesheet');
19
+ ref.setAttribute('type', 'text/css');
20
+ ref.setAttribute('href', res);
21
+ } else if (type === 'style') {
22
+ ref = document.createElement('style');
23
+ ref.innerHTML = res;
24
+ }
25
+ if (ref) {
26
+ document.querySelector('head').appendChild(ref);
27
+ ref.onload = function () {
28
+ if (isFunction(callback)) callback();
29
+ };
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ *去除字符串空格
3
+ */
4
+ export declare function stringTrim(str: string, type?: 1 | 2 | 3 | 4): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ *去除字符串空格
3
+ */
4
+ export function stringTrim(str, type) {
5
+ var _type;
6
+ // 1-所有空格,2-前后空格,3-前空格,4-后空格
7
+ // eslint-disable-next-line no-param-reassign
8
+ type = (_type = type) !== null && _type !== void 0 ? _type : 1;
9
+ switch (type) {
10
+ case 1:
11
+ return str.replace(/\s+/g, '');
12
+ case 2:
13
+ return str.replace(/(^\s*)|(\s*$)/g, '');
14
+ case 3:
15
+ return str.replace(/(^\s*)/g, '');
16
+ case 4:
17
+ return str.replace(/(\s*$)/g, '');
18
+ default:
19
+ return str;
20
+ }
21
+ }
package/es/typeOf.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断类型
3
+ * @param val 待判断数据
4
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
5
+ */
6
+ export declare function typeOf<T>(val: T): val is T;
package/es/typeOf.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断类型
3
+ * @param val 待判断数据
4
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
5
+ */
6
+ export function typeOf(val) {
7
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 替换字符串里面的回车换行符
3
+ */
4
+ export declare function filterCRLF(v: string): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterCRLF = filterCRLF;
7
+ /**
8
+ * 替换字符串里面的回车换行符
9
+ */
10
+ function filterCRLF(v) {
11
+ return v.replace(/\r|\n/gi, '<br/>');
12
+ }
@@ -23,5 +23,6 @@ function getBlobByUrl(url) {
23
23
  reject(new Error("".concat(statusText, "[").concat(status, "]")));
24
24
  }
25
25
  };
26
+ xhr.send();
26
27
  });
27
28
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 随机颜色
3
+ */
4
+ export declare function getRandomColor(): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRandomColor = getRandomColor;
7
+ /**
8
+ * 随机颜色
9
+ */
10
+ function getRandomColor() {
11
+ return "#".concat(Math.floor(Math.random() * 0xffffff).toString(16));
12
+ }
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './createHexColorByHash';
7
7
  export * from './downloadFile';
8
8
  export * from './each';
9
9
  export * from './filterBankCardNo';
10
+ export * from './filterCRLF';
10
11
  export * from './filterEmoji';
11
12
  export * from './filterIdCard';
12
13
  export * from './filterName';
@@ -16,9 +17,11 @@ export * from './formatDate';
16
17
  export * from './getBlobByUrl';
17
18
  export * from './getDayMillisecond';
18
19
  export * from './getImageInfo';
20
+ export * from './getRandomColor';
19
21
  export * from './getVideoInfo';
20
22
  export * from './inBrowser';
21
23
  export * from './isAndroid';
24
+ export * from './isArray';
22
25
  export * from './isBoolean';
23
26
  export * from './isEmail';
24
27
  export * from './isEmpty';
@@ -39,7 +42,9 @@ export * from './isPromise';
39
42
  export * from './isRegExp';
40
43
  export * from './isString';
41
44
  export * from './isUndefined';
45
+ export * from './isWeixin';
42
46
  export * from './isWindow';
47
+ export * from './loadResource';
43
48
  export * from './omit';
44
49
  export * from './parseDate';
45
50
  export * from './parseError';
@@ -51,4 +56,6 @@ export * from './reserve';
51
56
  export * from './round';
52
57
  export * from './sleep';
53
58
  export * from './storage';
59
+ export * from './stringTrim';
54
60
  export * from './stringifyQuery';
61
+ export * from './typeOf';
package/lib/index.js CHANGED
@@ -102,6 +102,17 @@ Object.keys(_filterBankCardNo).forEach(function (key) {
102
102
  }
103
103
  });
104
104
  });
105
+ var _filterCRLF = require("./filterCRLF");
106
+ Object.keys(_filterCRLF).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+ if (key in exports && exports[key] === _filterCRLF[key]) return;
109
+ Object.defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function get() {
112
+ return _filterCRLF[key];
113
+ }
114
+ });
115
+ });
105
116
  var _filterEmoji = require("./filterEmoji");
106
117
  Object.keys(_filterEmoji).forEach(function (key) {
107
118
  if (key === "default" || key === "__esModule") return;
@@ -201,6 +212,17 @@ Object.keys(_getImageInfo).forEach(function (key) {
201
212
  }
202
213
  });
203
214
  });
215
+ var _getRandomColor = require("./getRandomColor");
216
+ Object.keys(_getRandomColor).forEach(function (key) {
217
+ if (key === "default" || key === "__esModule") return;
218
+ if (key in exports && exports[key] === _getRandomColor[key]) return;
219
+ Object.defineProperty(exports, key, {
220
+ enumerable: true,
221
+ get: function get() {
222
+ return _getRandomColor[key];
223
+ }
224
+ });
225
+ });
204
226
  var _getVideoInfo = require("./getVideoInfo");
205
227
  Object.keys(_getVideoInfo).forEach(function (key) {
206
228
  if (key === "default" || key === "__esModule") return;
@@ -234,6 +256,17 @@ Object.keys(_isAndroid).forEach(function (key) {
234
256
  }
235
257
  });
236
258
  });
259
+ var _isArray = require("./isArray");
260
+ Object.keys(_isArray).forEach(function (key) {
261
+ if (key === "default" || key === "__esModule") return;
262
+ if (key in exports && exports[key] === _isArray[key]) return;
263
+ Object.defineProperty(exports, key, {
264
+ enumerable: true,
265
+ get: function get() {
266
+ return _isArray[key];
267
+ }
268
+ });
269
+ });
237
270
  var _isBoolean = require("./isBoolean");
238
271
  Object.keys(_isBoolean).forEach(function (key) {
239
272
  if (key === "default" || key === "__esModule") return;
@@ -454,6 +487,17 @@ Object.keys(_isUndefined).forEach(function (key) {
454
487
  }
455
488
  });
456
489
  });
490
+ var _isWeixin = require("./isWeixin");
491
+ Object.keys(_isWeixin).forEach(function (key) {
492
+ if (key === "default" || key === "__esModule") return;
493
+ if (key in exports && exports[key] === _isWeixin[key]) return;
494
+ Object.defineProperty(exports, key, {
495
+ enumerable: true,
496
+ get: function get() {
497
+ return _isWeixin[key];
498
+ }
499
+ });
500
+ });
457
501
  var _isWindow = require("./isWindow");
458
502
  Object.keys(_isWindow).forEach(function (key) {
459
503
  if (key === "default" || key === "__esModule") return;
@@ -465,6 +509,17 @@ Object.keys(_isWindow).forEach(function (key) {
465
509
  }
466
510
  });
467
511
  });
512
+ var _loadResource = require("./loadResource");
513
+ Object.keys(_loadResource).forEach(function (key) {
514
+ if (key === "default" || key === "__esModule") return;
515
+ if (key in exports && exports[key] === _loadResource[key]) return;
516
+ Object.defineProperty(exports, key, {
517
+ enumerable: true,
518
+ get: function get() {
519
+ return _loadResource[key];
520
+ }
521
+ });
522
+ });
468
523
  var _omit = require("./omit");
469
524
  Object.keys(_omit).forEach(function (key) {
470
525
  if (key === "default" || key === "__esModule") return;
@@ -586,6 +641,17 @@ Object.keys(_storage).forEach(function (key) {
586
641
  }
587
642
  });
588
643
  });
644
+ var _stringTrim = require("./stringTrim");
645
+ Object.keys(_stringTrim).forEach(function (key) {
646
+ if (key === "default" || key === "__esModule") return;
647
+ if (key in exports && exports[key] === _stringTrim[key]) return;
648
+ Object.defineProperty(exports, key, {
649
+ enumerable: true,
650
+ get: function get() {
651
+ return _stringTrim[key];
652
+ }
653
+ });
654
+ });
589
655
  var _stringifyQuery = require("./stringifyQuery");
590
656
  Object.keys(_stringifyQuery).forEach(function (key) {
591
657
  if (key === "default" || key === "__esModule") return;
@@ -596,4 +662,15 @@ Object.keys(_stringifyQuery).forEach(function (key) {
596
662
  return _stringifyQuery[key];
597
663
  }
598
664
  });
665
+ });
666
+ var _typeOf = require("./typeOf");
667
+ Object.keys(_typeOf).forEach(function (key) {
668
+ if (key === "default" || key === "__esModule") return;
669
+ if (key in exports && exports[key] === _typeOf[key]) return;
670
+ Object.defineProperty(exports, key, {
671
+ enumerable: true,
672
+ get: function get() {
673
+ return _typeOf[key];
674
+ }
675
+ });
599
676
  });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断是否是数组
3
+ * @param val 待判断值
4
+ * @returns 是否
5
+ */
6
+ export declare function isArray(val: unknown): val is any[];
package/lib/isArray.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isArray = isArray;
7
+ /**
8
+ * 判断是否是数组
9
+ * @param val 待判断值
10
+ * @returns 是否
11
+ */
12
+ function isArray(val) {
13
+ return Array.isArray(val);
14
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 是否是微信环境
3
+ */
4
+ export declare function isWeixin(): boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWeixin = isWeixin;
7
+ /**
8
+ * 是否是微信环境
9
+ */
10
+ function isWeixin() {
11
+ return /MicroMessenger/gi.test(navigator.userAgent);
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 加载外部js、css、写入style样式
3
+ * @param res 资源url或内容
4
+ * @param type 类型
5
+ * @param callback 回调函数
6
+ */
7
+ export declare function loadResource(res: string, type: 'js' | 'css' | 'style', callback?: any): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadResource = loadResource;
7
+ var _isFunction = require("./isFunction");
8
+ /**
9
+ * 加载外部js、css、写入style样式
10
+ * @param res 资源url或内容
11
+ * @param type 类型
12
+ * @param callback 回调函数
13
+ */
14
+ function loadResource(res, type, callback) {
15
+ var ref;
16
+ if (type === 'js') {
17
+ // 外部js
18
+ ref = document.createElement('js');
19
+ ref.setAttribute('type', 'text/javascript');
20
+ ref.setAttribute('src', res);
21
+ } else if (type === 'css') {
22
+ // 外部css
23
+ ref = document.createElement('link');
24
+ ref.setAttribute('rel', 'stylesheet');
25
+ ref.setAttribute('type', 'text/css');
26
+ ref.setAttribute('href', res);
27
+ } else if (type === 'style') {
28
+ ref = document.createElement('style');
29
+ ref.innerHTML = res;
30
+ }
31
+ if (ref) {
32
+ document.querySelector('head').appendChild(ref);
33
+ ref.onload = function () {
34
+ if ((0, _isFunction.isFunction)(callback)) callback();
35
+ };
36
+ }
37
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ *去除字符串空格
3
+ */
4
+ export declare function stringTrim(str: string, type?: 1 | 2 | 3 | 4): string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stringTrim = stringTrim;
7
+ /**
8
+ *去除字符串空格
9
+ */
10
+ function stringTrim(str, type) {
11
+ var _type;
12
+ // 1-所有空格,2-前后空格,3-前空格,4-后空格
13
+ // eslint-disable-next-line no-param-reassign
14
+ type = (_type = type) !== null && _type !== void 0 ? _type : 1;
15
+ switch (type) {
16
+ case 1:
17
+ return str.replace(/\s+/g, '');
18
+ case 2:
19
+ return str.replace(/(^\s*)|(\s*$)/g, '');
20
+ case 3:
21
+ return str.replace(/(^\s*)/g, '');
22
+ case 4:
23
+ return str.replace(/(\s*$)/g, '');
24
+ default:
25
+ return str;
26
+ }
27
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断类型
3
+ * @param val 待判断数据
4
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
5
+ */
6
+ export declare function typeOf<T>(val: T): val is T;
package/lib/typeOf.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.typeOf = typeOf;
7
+ /**
8
+ * 判断类型
9
+ * @param val 待判断数据
10
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
11
+ */
12
+ function typeOf(val) {
13
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "通用的工具库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",