@daysnap/utils 0.0.47 → 0.0.49
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/README.md +37 -0
- package/docs/modules.md +281 -81
- package/es/camelCase.d.ts +5 -0
- package/es/camelCase.js +7 -0
- package/es/capitalize.d.ts +5 -0
- package/es/capitalize.js +7 -0
- package/es/formatPathParams.d.ts +13 -0
- package/es/formatPathParams.js +19 -0
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -0
- package/es/kebabCase.d.ts +5 -0
- package/es/kebabCase.js +8 -0
- package/es/pascalCase.d.ts +5 -0
- package/es/pascalCase.js +9 -0
- package/lib/camelCase.d.ts +5 -0
- package/lib/camelCase.js +11 -0
- package/lib/capitalize.d.ts +5 -0
- package/lib/capitalize.js +11 -0
- package/lib/formatPathParams.d.ts +13 -0
- package/lib/formatPathParams.js +23 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +5 -0
- package/lib/kebabCase.d.ts +5 -0
- package/lib/kebabCase.js +12 -0
- package/lib/pascalCase.d.ts +5 -0
- package/lib/pascalCase.js +13 -0
- package/package.json +1 -1
package/docs/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@daysnap/utils / [Exports](modules.md)
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img alt="logo" src="https://avatars.githubusercontent.com/u/96568061?s=200&v=4" width="120" height="120" style="margin-bottom: 10px;">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">@daysnap/utils</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">日常工作中常用的工具函数</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.org/package/@daysnap/utils">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@daysnap/utils.svg" alt="npm version" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://npmcharts.com/compare/@daysnap/utils">
|
|
16
|
+
<img src="https://img.shields.io/npm/dm/@daysnap/utils.svg">
|
|
17
|
+
</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
- 安装
|
|
23
|
+
```shell
|
|
24
|
+
npm install @daysnap/utils
|
|
25
|
+
|
|
26
|
+
# or
|
|
27
|
+
yarn add @daysnap/utils
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- 引入
|
|
31
|
+
```js
|
|
32
|
+
import { debounce } from '@daysnap/utils'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 详情 API 文档
|
|
36
|
+
|
|
37
|
+
[点我查看](./docs/modules.md)
|
package/docs/modules.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
- [base64ToBlob](modules.md#base64toblob)
|
|
10
10
|
- [blobToBase64](modules.md#blobtobase64)
|
|
11
|
+
- [camelCase](modules.md#camelcase)
|
|
11
12
|
- [canvasToBlob](modules.md#canvastoblob)
|
|
13
|
+
- [capitalize](modules.md#capitalize)
|
|
12
14
|
- [clone](modules.md#clone)
|
|
13
15
|
- [cloneSimple](modules.md#clonesimple)
|
|
14
16
|
- [colorGenByHash](modules.md#colorgenbyhash)
|
|
@@ -25,6 +27,7 @@
|
|
|
25
27
|
- [filterPhone](modules.md#filterphone)
|
|
26
28
|
- [formatAmount](modules.md#formatamount)
|
|
27
29
|
- [formatDate](modules.md#formatdate)
|
|
30
|
+
- [formatMessage](modules.md#formatmessage)
|
|
28
31
|
- [getBlobByUrl](modules.md#getblobbyurl)
|
|
29
32
|
- [getCache](modules.md#getcache)
|
|
30
33
|
- [getDayMillisecond](modules.md#getdaymillisecond)
|
|
@@ -33,6 +36,9 @@
|
|
|
33
36
|
- [getRandomColor](modules.md#getrandomcolor)
|
|
34
37
|
- [getVideoInfo](modules.md#getvideoinfo)
|
|
35
38
|
- [inBrowser](modules.md#inbrowser)
|
|
39
|
+
- [insertLink](modules.md#insertlink)
|
|
40
|
+
- [insertScript](modules.md#insertscript)
|
|
41
|
+
- [insertStyle](modules.md#insertstyle)
|
|
36
42
|
- [isAndroid](modules.md#isandroid)
|
|
37
43
|
- [isArray](modules.md#isarray)
|
|
38
44
|
- [isBoolean](modules.md#isboolean)
|
|
@@ -58,7 +64,7 @@
|
|
|
58
64
|
- [isUndefined](modules.md#isundefined)
|
|
59
65
|
- [isWeixin](modules.md#isweixin)
|
|
60
66
|
- [isWindow](modules.md#iswindow)
|
|
61
|
-
- [
|
|
67
|
+
- [kebabCase](modules.md#kebabcase)
|
|
62
68
|
- [omit](modules.md#omit)
|
|
63
69
|
- [padding](modules.md#padding)
|
|
64
70
|
- [parseDate](modules.md#parsedate)
|
|
@@ -66,6 +72,7 @@
|
|
|
66
72
|
- [parseObject](modules.md#parseobject)
|
|
67
73
|
- [parsePath](modules.md#parsepath)
|
|
68
74
|
- [parseQuery](modules.md#parsequery)
|
|
75
|
+
- [pascalCase](modules.md#pascalcase)
|
|
69
76
|
- [pick](modules.md#pick)
|
|
70
77
|
- [replaceCrlf](modules.md#replacecrlf)
|
|
71
78
|
- [reserve](modules.md#reserve)
|
|
@@ -97,7 +104,7 @@ base64 转 blob
|
|
|
97
104
|
|
|
98
105
|
#### Defined in
|
|
99
106
|
|
|
100
|
-
[base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/
|
|
107
|
+
[base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/base64ToBlob.ts#L6)
|
|
101
108
|
|
|
102
109
|
___
|
|
103
110
|
|
|
@@ -119,7 +126,30 @@ blob 转 base64
|
|
|
119
126
|
|
|
120
127
|
#### Defined in
|
|
121
128
|
|
|
122
|
-
[blobToBase64.ts:4](https://github.com/daysnap/utils/blob/
|
|
129
|
+
[blobToBase64.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/blobToBase64.ts#L4)
|
|
130
|
+
|
|
131
|
+
___
|
|
132
|
+
|
|
133
|
+
### camelCase
|
|
134
|
+
|
|
135
|
+
▸ **camelCase**(`str`): `string`
|
|
136
|
+
|
|
137
|
+
驼峰
|
|
138
|
+
camelCase('hello-world') => helloWorld
|
|
139
|
+
|
|
140
|
+
#### Parameters
|
|
141
|
+
|
|
142
|
+
| Name | Type |
|
|
143
|
+
| :------ | :------ |
|
|
144
|
+
| `str` | `string` |
|
|
145
|
+
|
|
146
|
+
#### Returns
|
|
147
|
+
|
|
148
|
+
`string`
|
|
149
|
+
|
|
150
|
+
#### Defined in
|
|
151
|
+
|
|
152
|
+
camelCase.ts:5
|
|
123
153
|
|
|
124
154
|
___
|
|
125
155
|
|
|
@@ -143,7 +173,30 @@ canvas 转 blob 文件
|
|
|
143
173
|
|
|
144
174
|
#### Defined in
|
|
145
175
|
|
|
146
|
-
[canvasToBlob.ts:4](https://github.com/daysnap/utils/blob/
|
|
176
|
+
[canvasToBlob.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/canvasToBlob.ts#L4)
|
|
177
|
+
|
|
178
|
+
___
|
|
179
|
+
|
|
180
|
+
### capitalize
|
|
181
|
+
|
|
182
|
+
▸ **capitalize**(`str`): `string`
|
|
183
|
+
|
|
184
|
+
首字母大写
|
|
185
|
+
capitalize('hello world') => Hello world
|
|
186
|
+
|
|
187
|
+
#### Parameters
|
|
188
|
+
|
|
189
|
+
| Name | Type |
|
|
190
|
+
| :------ | :------ |
|
|
191
|
+
| `str` | `string` |
|
|
192
|
+
|
|
193
|
+
#### Returns
|
|
194
|
+
|
|
195
|
+
`string`
|
|
196
|
+
|
|
197
|
+
#### Defined in
|
|
198
|
+
|
|
199
|
+
capitalize.ts:5
|
|
147
200
|
|
|
148
201
|
___
|
|
149
202
|
|
|
@@ -171,7 +224,7 @@ ___
|
|
|
171
224
|
|
|
172
225
|
#### Defined in
|
|
173
226
|
|
|
174
|
-
[clone.ts:8](https://github.com/daysnap/utils/blob/
|
|
227
|
+
[clone.ts:8](https://github.com/daysnap/utils/blob/edb8efd/src/clone.ts#L8)
|
|
175
228
|
|
|
176
229
|
___
|
|
177
230
|
|
|
@@ -199,7 +252,7 @@ ___
|
|
|
199
252
|
|
|
200
253
|
#### Defined in
|
|
201
254
|
|
|
202
|
-
[cloneSimple.ts:7](https://github.com/daysnap/utils/blob/
|
|
255
|
+
[cloneSimple.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/cloneSimple.ts#L7)
|
|
203
256
|
|
|
204
257
|
___
|
|
205
258
|
|
|
@@ -221,7 +274,7 @@ ___
|
|
|
221
274
|
|
|
222
275
|
#### Defined in
|
|
223
276
|
|
|
224
|
-
[createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/
|
|
277
|
+
[createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/createHexColorByHash.ts#L4)
|
|
225
278
|
|
|
226
279
|
___
|
|
227
280
|
|
|
@@ -247,7 +300,7 @@ ___
|
|
|
247
300
|
|
|
248
301
|
#### Defined in
|
|
249
302
|
|
|
250
|
-
[compareVersion.ts:9](https://github.com/daysnap/utils/blob/
|
|
303
|
+
[compareVersion.ts:9](https://github.com/daysnap/utils/blob/edb8efd/src/compareVersion.ts#L9)
|
|
251
304
|
|
|
252
305
|
___
|
|
253
306
|
|
|
@@ -269,7 +322,7 @@ ___
|
|
|
269
322
|
|
|
270
323
|
#### Defined in
|
|
271
324
|
|
|
272
|
-
[compressImage.ts:6](https://github.com/daysnap/utils/blob/
|
|
325
|
+
[compressImage.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/compressImage.ts#L6)
|
|
273
326
|
|
|
274
327
|
___
|
|
275
328
|
|
|
@@ -312,7 +365,7 @@ ___
|
|
|
312
365
|
|
|
313
366
|
#### Defined in
|
|
314
367
|
|
|
315
|
-
[debounce.ts:5](https://github.com/daysnap/utils/blob/
|
|
368
|
+
[debounce.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/debounce.ts#L5)
|
|
316
369
|
|
|
317
370
|
___
|
|
318
371
|
|
|
@@ -336,7 +389,7 @@ ___
|
|
|
336
389
|
|
|
337
390
|
#### Defined in
|
|
338
391
|
|
|
339
|
-
[downloadFile.ts:4](https://github.com/daysnap/utils/blob/
|
|
392
|
+
[downloadFile.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/downloadFile.ts#L4)
|
|
340
393
|
|
|
341
394
|
___
|
|
342
395
|
|
|
@@ -365,7 +418,7 @@ ___
|
|
|
365
418
|
|
|
366
419
|
#### Defined in
|
|
367
420
|
|
|
368
|
-
[each.ts:4](https://github.com/daysnap/utils/blob/
|
|
421
|
+
[each.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/each.ts#L4)
|
|
369
422
|
|
|
370
423
|
▸ **each**<`T`\>(`data`, `callback`): `void`
|
|
371
424
|
|
|
@@ -388,7 +441,7 @@ ___
|
|
|
388
441
|
|
|
389
442
|
#### Defined in
|
|
390
443
|
|
|
391
|
-
[each.ts:8](https://github.com/daysnap/utils/blob/
|
|
444
|
+
[each.ts:8](https://github.com/daysnap/utils/blob/edb8efd/src/each.ts#L8)
|
|
392
445
|
|
|
393
446
|
___
|
|
394
447
|
|
|
@@ -410,7 +463,7 @@ ___
|
|
|
410
463
|
|
|
411
464
|
#### Defined in
|
|
412
465
|
|
|
413
|
-
[filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/
|
|
466
|
+
[filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/filterBankCardNo.ts#L4)
|
|
414
467
|
|
|
415
468
|
___
|
|
416
469
|
|
|
@@ -432,7 +485,7 @@ ___
|
|
|
432
485
|
|
|
433
486
|
#### Defined in
|
|
434
487
|
|
|
435
|
-
[filterCRLF.ts:4](https://github.com/daysnap/utils/blob/
|
|
488
|
+
[filterCRLF.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/filterCRLF.ts#L4)
|
|
436
489
|
|
|
437
490
|
___
|
|
438
491
|
|
|
@@ -454,7 +507,7 @@ ___
|
|
|
454
507
|
|
|
455
508
|
#### Defined in
|
|
456
509
|
|
|
457
|
-
[filterEmoji.ts:4](https://github.com/daysnap/utils/blob/
|
|
510
|
+
[filterEmoji.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/filterEmoji.ts#L4)
|
|
458
511
|
|
|
459
512
|
___
|
|
460
513
|
|
|
@@ -476,7 +529,7 @@ ___
|
|
|
476
529
|
|
|
477
530
|
#### Defined in
|
|
478
531
|
|
|
479
|
-
[filterIdCard.ts:4](https://github.com/daysnap/utils/blob/
|
|
532
|
+
[filterIdCard.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/filterIdCard.ts#L4)
|
|
480
533
|
|
|
481
534
|
___
|
|
482
535
|
|
|
@@ -498,7 +551,7 @@ ___
|
|
|
498
551
|
|
|
499
552
|
#### Defined in
|
|
500
553
|
|
|
501
|
-
[filterName.ts:4](https://github.com/daysnap/utils/blob/
|
|
554
|
+
[filterName.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/filterName.ts#L4)
|
|
502
555
|
|
|
503
556
|
___
|
|
504
557
|
|
|
@@ -523,7 +576,7 @@ filterPhone('13177778888', ' ') => 131 **** 8888
|
|
|
523
576
|
|
|
524
577
|
#### Defined in
|
|
525
578
|
|
|
526
|
-
[filterPhone.ts:6](https://github.com/daysnap/utils/blob/
|
|
579
|
+
[filterPhone.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/filterPhone.ts#L6)
|
|
527
580
|
|
|
528
581
|
___
|
|
529
582
|
|
|
@@ -546,7 +599,7 @@ ___
|
|
|
546
599
|
|
|
547
600
|
#### Defined in
|
|
548
601
|
|
|
549
|
-
[formatAmount.ts:4](https://github.com/daysnap/utils/blob/
|
|
602
|
+
[formatAmount.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/formatAmount.ts#L4)
|
|
550
603
|
|
|
551
604
|
___
|
|
552
605
|
|
|
@@ -569,7 +622,32 @@ ___
|
|
|
569
622
|
|
|
570
623
|
#### Defined in
|
|
571
624
|
|
|
572
|
-
[formatDate.ts:6](https://github.com/daysnap/utils/blob/
|
|
625
|
+
[formatDate.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/formatDate.ts#L6)
|
|
626
|
+
|
|
627
|
+
___
|
|
628
|
+
|
|
629
|
+
### formatMessage
|
|
630
|
+
|
|
631
|
+
▸ **formatMessage**(`message`, `keys?`): `string`
|
|
632
|
+
|
|
633
|
+
格式化消息
|
|
634
|
+
formatMessage({ a: '123', b: { ba: '456' } }, ['a']) => '123'
|
|
635
|
+
formatMessage({ a: '123', b: { ba: '456' } }, ['b.ba']) => '456'
|
|
636
|
+
|
|
637
|
+
#### Parameters
|
|
638
|
+
|
|
639
|
+
| Name | Type |
|
|
640
|
+
| :------ | :------ |
|
|
641
|
+
| `message` | `unknown` |
|
|
642
|
+
| `keys` | `string`[] |
|
|
643
|
+
|
|
644
|
+
#### Returns
|
|
645
|
+
|
|
646
|
+
`string`
|
|
647
|
+
|
|
648
|
+
#### Defined in
|
|
649
|
+
|
|
650
|
+
[formatMessage.ts:11](https://github.com/daysnap/utils/blob/edb8efd/src/formatMessage.ts#L11)
|
|
573
651
|
|
|
574
652
|
___
|
|
575
653
|
|
|
@@ -591,7 +669,7 @@ ___
|
|
|
591
669
|
|
|
592
670
|
#### Defined in
|
|
593
671
|
|
|
594
|
-
[getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/
|
|
672
|
+
[getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/getBlobByUrl.ts#L4)
|
|
595
673
|
|
|
596
674
|
___
|
|
597
675
|
|
|
@@ -614,7 +692,7 @@ ___
|
|
|
614
692
|
|
|
615
693
|
#### Defined in
|
|
616
694
|
|
|
617
|
-
[storage/index.ts:7](https://github.com/daysnap/utils/blob/
|
|
695
|
+
[storage/index.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/storage/index.ts#L7)
|
|
618
696
|
|
|
619
697
|
___
|
|
620
698
|
|
|
@@ -636,7 +714,7 @@ ___
|
|
|
636
714
|
|
|
637
715
|
#### Defined in
|
|
638
716
|
|
|
639
|
-
[getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/
|
|
717
|
+
[getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/getDayMillisecond.ts#L4)
|
|
640
718
|
|
|
641
719
|
___
|
|
642
720
|
|
|
@@ -658,7 +736,7 @@ ___
|
|
|
658
736
|
|
|
659
737
|
#### Defined in
|
|
660
738
|
|
|
661
|
-
[getImageInfo.ts:4](https://github.com/daysnap/utils/blob/
|
|
739
|
+
[getImageInfo.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/getImageInfo.ts#L4)
|
|
662
740
|
|
|
663
741
|
___
|
|
664
742
|
|
|
@@ -681,7 +759,7 @@ ___
|
|
|
681
759
|
|
|
682
760
|
#### Defined in
|
|
683
761
|
|
|
684
|
-
[storage/index.ts:7](https://github.com/daysnap/utils/blob/
|
|
762
|
+
[storage/index.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/storage/index.ts#L7)
|
|
685
763
|
|
|
686
764
|
___
|
|
687
765
|
|
|
@@ -697,7 +775,7 @@ ___
|
|
|
697
775
|
|
|
698
776
|
#### Defined in
|
|
699
777
|
|
|
700
|
-
[getRandomColor.ts:4](https://github.com/daysnap/utils/blob/
|
|
778
|
+
[getRandomColor.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/getRandomColor.ts#L4)
|
|
701
779
|
|
|
702
780
|
___
|
|
703
781
|
|
|
@@ -719,7 +797,7 @@ ___
|
|
|
719
797
|
|
|
720
798
|
#### Defined in
|
|
721
799
|
|
|
722
|
-
[getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/
|
|
800
|
+
[getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/getVideoInfo.ts#L4)
|
|
723
801
|
|
|
724
802
|
___
|
|
725
803
|
|
|
@@ -735,7 +813,107 @@ ___
|
|
|
735
813
|
|
|
736
814
|
#### Defined in
|
|
737
815
|
|
|
738
|
-
[inBrowser.ts:4](https://github.com/daysnap/utils/blob/
|
|
816
|
+
[inBrowser.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/inBrowser.ts#L4)
|
|
817
|
+
|
|
818
|
+
___
|
|
819
|
+
|
|
820
|
+
### insertLink
|
|
821
|
+
|
|
822
|
+
▸ **insertLink**(`href`): `Promise`<`HTMLLinkElement`\>
|
|
823
|
+
|
|
824
|
+
插入 link
|
|
825
|
+
|
|
826
|
+
#### Parameters
|
|
827
|
+
|
|
828
|
+
| Name | Type |
|
|
829
|
+
| :------ | :------ |
|
|
830
|
+
| `href` | `string` |
|
|
831
|
+
|
|
832
|
+
#### Returns
|
|
833
|
+
|
|
834
|
+
`Promise`<`HTMLLinkElement`\>
|
|
835
|
+
|
|
836
|
+
#### Defined in
|
|
837
|
+
|
|
838
|
+
[insertLink.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/insertLink.ts#L4)
|
|
839
|
+
|
|
840
|
+
▸ **insertLink**(`href`, `callback`): `void`
|
|
841
|
+
|
|
842
|
+
#### Parameters
|
|
843
|
+
|
|
844
|
+
| Name | Type |
|
|
845
|
+
| :------ | :------ |
|
|
846
|
+
| `href` | `string` |
|
|
847
|
+
| `callback` | (`err`: `unknown`, `el`: `HTMLLinkElement`) => `void` |
|
|
848
|
+
|
|
849
|
+
#### Returns
|
|
850
|
+
|
|
851
|
+
`void`
|
|
852
|
+
|
|
853
|
+
#### Defined in
|
|
854
|
+
|
|
855
|
+
[insertLink.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/insertLink.ts#L5)
|
|
856
|
+
|
|
857
|
+
___
|
|
858
|
+
|
|
859
|
+
### insertScript
|
|
860
|
+
|
|
861
|
+
▸ **insertScript**(`src`): `Promise`<`HTMLScriptElement`\>
|
|
862
|
+
|
|
863
|
+
插入外部 script 标签
|
|
864
|
+
|
|
865
|
+
#### Parameters
|
|
866
|
+
|
|
867
|
+
| Name | Type |
|
|
868
|
+
| :------ | :------ |
|
|
869
|
+
| `src` | `string` |
|
|
870
|
+
|
|
871
|
+
#### Returns
|
|
872
|
+
|
|
873
|
+
`Promise`<`HTMLScriptElement`\>
|
|
874
|
+
|
|
875
|
+
#### Defined in
|
|
876
|
+
|
|
877
|
+
[insertScript.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/insertScript.ts#L4)
|
|
878
|
+
|
|
879
|
+
▸ **insertScript**(`src`, `callback`): `void`
|
|
880
|
+
|
|
881
|
+
#### Parameters
|
|
882
|
+
|
|
883
|
+
| Name | Type |
|
|
884
|
+
| :------ | :------ |
|
|
885
|
+
| `src` | `string` |
|
|
886
|
+
| `callback` | (`err`: `unknown`, `el`: `HTMLScriptElement`) => `void` |
|
|
887
|
+
|
|
888
|
+
#### Returns
|
|
889
|
+
|
|
890
|
+
`void`
|
|
891
|
+
|
|
892
|
+
#### Defined in
|
|
893
|
+
|
|
894
|
+
[insertScript.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/insertScript.ts#L5)
|
|
895
|
+
|
|
896
|
+
___
|
|
897
|
+
|
|
898
|
+
### insertStyle
|
|
899
|
+
|
|
900
|
+
▸ **insertStyle**(`content`): `HTMLStyleElement`
|
|
901
|
+
|
|
902
|
+
插入样式
|
|
903
|
+
|
|
904
|
+
#### Parameters
|
|
905
|
+
|
|
906
|
+
| Name | Type |
|
|
907
|
+
| :------ | :------ |
|
|
908
|
+
| `content` | `string` |
|
|
909
|
+
|
|
910
|
+
#### Returns
|
|
911
|
+
|
|
912
|
+
`HTMLStyleElement`
|
|
913
|
+
|
|
914
|
+
#### Defined in
|
|
915
|
+
|
|
916
|
+
[insertStyle.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/insertStyle.ts#L4)
|
|
739
917
|
|
|
740
918
|
___
|
|
741
919
|
|
|
@@ -751,7 +929,7 @@ ___
|
|
|
751
929
|
|
|
752
930
|
#### Defined in
|
|
753
931
|
|
|
754
|
-
[isAndroid.ts:4](https://github.com/daysnap/utils/blob/
|
|
932
|
+
[isAndroid.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isAndroid.ts#L4)
|
|
755
933
|
|
|
756
934
|
___
|
|
757
935
|
|
|
@@ -775,7 +953,7 @@ val is any[]
|
|
|
775
953
|
|
|
776
954
|
#### Defined in
|
|
777
955
|
|
|
778
|
-
[isArray.ts:6](https://github.com/daysnap/utils/blob/
|
|
956
|
+
[isArray.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/isArray.ts#L6)
|
|
779
957
|
|
|
780
958
|
___
|
|
781
959
|
|
|
@@ -797,7 +975,7 @@ val is boolean
|
|
|
797
975
|
|
|
798
976
|
#### Defined in
|
|
799
977
|
|
|
800
|
-
[isBoolean.ts:5](https://github.com/daysnap/utils/blob/
|
|
978
|
+
[isBoolean.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isBoolean.ts#L5)
|
|
801
979
|
|
|
802
980
|
___
|
|
803
981
|
|
|
@@ -819,7 +997,7 @@ ___
|
|
|
819
997
|
|
|
820
998
|
#### Defined in
|
|
821
999
|
|
|
822
|
-
[isEmail.ts:4](https://github.com/daysnap/utils/blob/
|
|
1000
|
+
[isEmail.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isEmail.ts#L4)
|
|
823
1001
|
|
|
824
1002
|
___
|
|
825
1003
|
|
|
@@ -841,7 +1019,7 @@ ___
|
|
|
841
1019
|
|
|
842
1020
|
#### Defined in
|
|
843
1021
|
|
|
844
|
-
[isEmpty.ts:6](https://github.com/daysnap/utils/blob/
|
|
1022
|
+
[isEmpty.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/isEmpty.ts#L6)
|
|
845
1023
|
|
|
846
1024
|
___
|
|
847
1025
|
|
|
@@ -863,7 +1041,7 @@ ___
|
|
|
863
1041
|
|
|
864
1042
|
#### Defined in
|
|
865
1043
|
|
|
866
|
-
[isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/
|
|
1044
|
+
[isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isEmptyObject.ts#L5)
|
|
867
1045
|
|
|
868
1046
|
___
|
|
869
1047
|
|
|
@@ -885,7 +1063,7 @@ val is Error
|
|
|
885
1063
|
|
|
886
1064
|
#### Defined in
|
|
887
1065
|
|
|
888
|
-
[isError.ts:4](https://github.com/daysnap/utils/blob/
|
|
1066
|
+
[isError.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isError.ts#L4)
|
|
889
1067
|
|
|
890
1068
|
___
|
|
891
1069
|
|
|
@@ -907,7 +1085,7 @@ val is Function
|
|
|
907
1085
|
|
|
908
1086
|
#### Defined in
|
|
909
1087
|
|
|
910
|
-
[isFunction.ts:4](https://github.com/daysnap/utils/blob/
|
|
1088
|
+
[isFunction.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isFunction.ts#L4)
|
|
911
1089
|
|
|
912
1090
|
___
|
|
913
1091
|
|
|
@@ -923,7 +1101,7 @@ ___
|
|
|
923
1101
|
|
|
924
1102
|
#### Defined in
|
|
925
1103
|
|
|
926
|
-
[isIOS.ts:4](https://github.com/daysnap/utils/blob/
|
|
1104
|
+
[isIOS.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isIOS.ts#L4)
|
|
927
1105
|
|
|
928
1106
|
___
|
|
929
1107
|
|
|
@@ -945,7 +1123,7 @@ ___
|
|
|
945
1123
|
|
|
946
1124
|
#### Defined in
|
|
947
1125
|
|
|
948
|
-
[isIdCard.ts:4](https://github.com/daysnap/utils/blob/
|
|
1126
|
+
[isIdCard.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isIdCard.ts#L4)
|
|
949
1127
|
|
|
950
1128
|
___
|
|
951
1129
|
|
|
@@ -967,7 +1145,7 @@ ___
|
|
|
967
1145
|
|
|
968
1146
|
#### Defined in
|
|
969
1147
|
|
|
970
|
-
[isJSONString.ts:7](https://github.com/daysnap/utils/blob/
|
|
1148
|
+
[isJSONString.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/isJSONString.ts#L7)
|
|
971
1149
|
|
|
972
1150
|
___
|
|
973
1151
|
|
|
@@ -989,7 +1167,7 @@ ___
|
|
|
989
1167
|
|
|
990
1168
|
#### Defined in
|
|
991
1169
|
|
|
992
|
-
[isLan.ts:5](https://github.com/daysnap/utils/blob/
|
|
1170
|
+
[isLan.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isLan.ts#L5)
|
|
993
1171
|
|
|
994
1172
|
___
|
|
995
1173
|
|
|
@@ -1011,7 +1189,7 @@ ___
|
|
|
1011
1189
|
|
|
1012
1190
|
#### Defined in
|
|
1013
1191
|
|
|
1014
|
-
[isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/
|
|
1192
|
+
[isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isLicenseCode.ts#L5)
|
|
1015
1193
|
|
|
1016
1194
|
___
|
|
1017
1195
|
|
|
@@ -1027,7 +1205,7 @@ ___
|
|
|
1027
1205
|
|
|
1028
1206
|
#### Defined in
|
|
1029
1207
|
|
|
1030
|
-
[isMobile.ts:4](https://github.com/daysnap/utils/blob/
|
|
1208
|
+
[isMobile.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isMobile.ts#L4)
|
|
1031
1209
|
|
|
1032
1210
|
___
|
|
1033
1211
|
|
|
@@ -1049,7 +1227,7 @@ val is null
|
|
|
1049
1227
|
|
|
1050
1228
|
#### Defined in
|
|
1051
1229
|
|
|
1052
|
-
[isNull.ts:4](https://github.com/daysnap/utils/blob/
|
|
1230
|
+
[isNull.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isNull.ts#L4)
|
|
1053
1231
|
|
|
1054
1232
|
___
|
|
1055
1233
|
|
|
@@ -1071,7 +1249,7 @@ val is number
|
|
|
1071
1249
|
|
|
1072
1250
|
#### Defined in
|
|
1073
1251
|
|
|
1074
|
-
[isNumber.ts:5](https://github.com/daysnap/utils/blob/
|
|
1252
|
+
[isNumber.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isNumber.ts#L5)
|
|
1075
1253
|
|
|
1076
1254
|
___
|
|
1077
1255
|
|
|
@@ -1093,7 +1271,7 @@ val is Record<string, any\>
|
|
|
1093
1271
|
|
|
1094
1272
|
#### Defined in
|
|
1095
1273
|
|
|
1096
|
-
[isObject.ts:4](https://github.com/daysnap/utils/blob/
|
|
1274
|
+
[isObject.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isObject.ts#L4)
|
|
1097
1275
|
|
|
1098
1276
|
___
|
|
1099
1277
|
|
|
@@ -1115,7 +1293,7 @@ ___
|
|
|
1115
1293
|
|
|
1116
1294
|
#### Defined in
|
|
1117
1295
|
|
|
1118
|
-
[isPhone.ts:4](https://github.com/daysnap/utils/blob/
|
|
1296
|
+
[isPhone.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isPhone.ts#L4)
|
|
1119
1297
|
|
|
1120
1298
|
___
|
|
1121
1299
|
|
|
@@ -1143,7 +1321,7 @@ val is Promise<T\>
|
|
|
1143
1321
|
|
|
1144
1322
|
#### Defined in
|
|
1145
1323
|
|
|
1146
|
-
[isPromise.ts:4](https://github.com/daysnap/utils/blob/
|
|
1324
|
+
[isPromise.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isPromise.ts#L4)
|
|
1147
1325
|
|
|
1148
1326
|
___
|
|
1149
1327
|
|
|
@@ -1165,7 +1343,7 @@ val is RegExp
|
|
|
1165
1343
|
|
|
1166
1344
|
#### Defined in
|
|
1167
1345
|
|
|
1168
|
-
[isRegExp.ts:4](https://github.com/daysnap/utils/blob/
|
|
1346
|
+
[isRegExp.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isRegExp.ts#L4)
|
|
1169
1347
|
|
|
1170
1348
|
___
|
|
1171
1349
|
|
|
@@ -1187,7 +1365,7 @@ val is string
|
|
|
1187
1365
|
|
|
1188
1366
|
#### Defined in
|
|
1189
1367
|
|
|
1190
|
-
[isString.ts:4](https://github.com/daysnap/utils/blob/
|
|
1368
|
+
[isString.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isString.ts#L4)
|
|
1191
1369
|
|
|
1192
1370
|
___
|
|
1193
1371
|
|
|
@@ -1209,7 +1387,7 @@ ___
|
|
|
1209
1387
|
|
|
1210
1388
|
#### Defined in
|
|
1211
1389
|
|
|
1212
|
-
[isURL.ts:4](https://github.com/daysnap/utils/blob/
|
|
1390
|
+
[isURL.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isURL.ts#L4)
|
|
1213
1391
|
|
|
1214
1392
|
___
|
|
1215
1393
|
|
|
@@ -1231,7 +1409,7 @@ val is undefined
|
|
|
1231
1409
|
|
|
1232
1410
|
#### Defined in
|
|
1233
1411
|
|
|
1234
|
-
[isUndefined.ts:4](https://github.com/daysnap/utils/blob/
|
|
1412
|
+
[isUndefined.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isUndefined.ts#L4)
|
|
1235
1413
|
|
|
1236
1414
|
___
|
|
1237
1415
|
|
|
@@ -1247,7 +1425,7 @@ ___
|
|
|
1247
1425
|
|
|
1248
1426
|
#### Defined in
|
|
1249
1427
|
|
|
1250
|
-
[isWeixin.ts:4](https://github.com/daysnap/utils/blob/
|
|
1428
|
+
[isWeixin.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/isWeixin.ts#L4)
|
|
1251
1429
|
|
|
1252
1430
|
___
|
|
1253
1431
|
|
|
@@ -1269,31 +1447,30 @@ val is Window
|
|
|
1269
1447
|
|
|
1270
1448
|
#### Defined in
|
|
1271
1449
|
|
|
1272
|
-
[isWindow.ts:5](https://github.com/daysnap/utils/blob/
|
|
1450
|
+
[isWindow.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/isWindow.ts#L5)
|
|
1273
1451
|
|
|
1274
1452
|
___
|
|
1275
1453
|
|
|
1276
|
-
###
|
|
1454
|
+
### kebabCase
|
|
1277
1455
|
|
|
1278
|
-
▸ **
|
|
1456
|
+
▸ **kebabCase**(`key`): `string`
|
|
1279
1457
|
|
|
1280
|
-
|
|
1458
|
+
说明
|
|
1459
|
+
kebabCase('helloWorld') => hello-world
|
|
1281
1460
|
|
|
1282
1461
|
#### Parameters
|
|
1283
1462
|
|
|
1284
|
-
| Name | Type |
|
|
1285
|
-
| :------ | :------ |
|
|
1286
|
-
| `
|
|
1287
|
-
| `type` | ``"style"`` \| ``"js"`` \| ``"css"`` | 类型 |
|
|
1288
|
-
| `callback?` | () => `void` | 回调函数 |
|
|
1463
|
+
| Name | Type |
|
|
1464
|
+
| :------ | :------ |
|
|
1465
|
+
| `key` | `string` |
|
|
1289
1466
|
|
|
1290
1467
|
#### Returns
|
|
1291
1468
|
|
|
1292
|
-
`
|
|
1469
|
+
`string`
|
|
1293
1470
|
|
|
1294
1471
|
#### Defined in
|
|
1295
1472
|
|
|
1296
|
-
|
|
1473
|
+
kebabCase.ts:5
|
|
1297
1474
|
|
|
1298
1475
|
___
|
|
1299
1476
|
|
|
@@ -1323,7 +1500,7 @@ ___
|
|
|
1323
1500
|
|
|
1324
1501
|
#### Defined in
|
|
1325
1502
|
|
|
1326
|
-
[omit.ts:4](https://github.com/daysnap/utils/blob/
|
|
1503
|
+
[omit.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/omit.ts#L4)
|
|
1327
1504
|
|
|
1328
1505
|
___
|
|
1329
1506
|
|
|
@@ -1347,7 +1524,7 @@ ___
|
|
|
1347
1524
|
|
|
1348
1525
|
#### Defined in
|
|
1349
1526
|
|
|
1350
|
-
[padding.ts:7](https://github.com/daysnap/utils/blob/
|
|
1527
|
+
[padding.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/padding.ts#L7)
|
|
1351
1528
|
|
|
1352
1529
|
___
|
|
1353
1530
|
|
|
@@ -1369,7 +1546,7 @@ ___
|
|
|
1369
1546
|
|
|
1370
1547
|
#### Defined in
|
|
1371
1548
|
|
|
1372
|
-
[parseDate.ts:4](https://github.com/daysnap/utils/blob/
|
|
1549
|
+
[parseDate.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/parseDate.ts#L4)
|
|
1373
1550
|
|
|
1374
1551
|
___
|
|
1375
1552
|
|
|
@@ -1392,7 +1569,7 @@ ___
|
|
|
1392
1569
|
|
|
1393
1570
|
#### Defined in
|
|
1394
1571
|
|
|
1395
|
-
[parseError.ts:8](https://github.com/daysnap/utils/blob/
|
|
1572
|
+
[parseError.ts:8](https://github.com/daysnap/utils/blob/edb8efd/src/parseError.ts#L8)
|
|
1396
1573
|
|
|
1397
1574
|
___
|
|
1398
1575
|
|
|
@@ -1422,7 +1599,7 @@ parseObject('a.b.c', 1) => { a: { b: { c: 1 } } }
|
|
|
1422
1599
|
|
|
1423
1600
|
#### Defined in
|
|
1424
1601
|
|
|
1425
|
-
[parseObject.ts:5](https://github.com/daysnap/utils/blob/
|
|
1602
|
+
[parseObject.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/parseObject.ts#L5)
|
|
1426
1603
|
|
|
1427
1604
|
___
|
|
1428
1605
|
|
|
@@ -1451,7 +1628,7 @@ ___
|
|
|
1451
1628
|
|
|
1452
1629
|
#### Defined in
|
|
1453
1630
|
|
|
1454
|
-
[parsePath.ts:
|
|
1631
|
+
[parsePath.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/parsePath.ts#L6)
|
|
1455
1632
|
|
|
1456
1633
|
___
|
|
1457
1634
|
|
|
@@ -1474,7 +1651,30 @@ ___
|
|
|
1474
1651
|
|
|
1475
1652
|
#### Defined in
|
|
1476
1653
|
|
|
1477
|
-
[parseQuery.ts:8](https://github.com/daysnap/utils/blob/
|
|
1654
|
+
[parseQuery.ts:8](https://github.com/daysnap/utils/blob/edb8efd/src/parseQuery.ts#L8)
|
|
1655
|
+
|
|
1656
|
+
___
|
|
1657
|
+
|
|
1658
|
+
### pascalCase
|
|
1659
|
+
|
|
1660
|
+
▸ **pascalCase**(`str`): `string`
|
|
1661
|
+
|
|
1662
|
+
首字母大写的驼峰
|
|
1663
|
+
pascalCase('hello-world') => HelloWorld
|
|
1664
|
+
|
|
1665
|
+
#### Parameters
|
|
1666
|
+
|
|
1667
|
+
| Name | Type |
|
|
1668
|
+
| :------ | :------ |
|
|
1669
|
+
| `str` | `string` |
|
|
1670
|
+
|
|
1671
|
+
#### Returns
|
|
1672
|
+
|
|
1673
|
+
`string`
|
|
1674
|
+
|
|
1675
|
+
#### Defined in
|
|
1676
|
+
|
|
1677
|
+
pascalCase.ts:8
|
|
1478
1678
|
|
|
1479
1679
|
___
|
|
1480
1680
|
|
|
@@ -1504,7 +1704,7 @@ ___
|
|
|
1504
1704
|
|
|
1505
1705
|
#### Defined in
|
|
1506
1706
|
|
|
1507
|
-
[pick.ts:4](https://github.com/daysnap/utils/blob/
|
|
1707
|
+
[pick.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/pick.ts#L4)
|
|
1508
1708
|
|
|
1509
1709
|
___
|
|
1510
1710
|
|
|
@@ -1527,7 +1727,7 @@ ___
|
|
|
1527
1727
|
|
|
1528
1728
|
#### Defined in
|
|
1529
1729
|
|
|
1530
|
-
[replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/
|
|
1730
|
+
[replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/edb8efd/src/replaceCrlf.ts#L4)
|
|
1531
1731
|
|
|
1532
1732
|
___
|
|
1533
1733
|
|
|
@@ -1553,7 +1753,7 @@ reserve(0, '--') => 0
|
|
|
1553
1753
|
|
|
1554
1754
|
#### Defined in
|
|
1555
1755
|
|
|
1556
|
-
[reserve.ts:8](https://github.com/daysnap/utils/blob/
|
|
1756
|
+
[reserve.ts:8](https://github.com/daysnap/utils/blob/edb8efd/src/reserve.ts#L8)
|
|
1557
1757
|
|
|
1558
1758
|
___
|
|
1559
1759
|
|
|
@@ -1576,7 +1776,7 @@ ___
|
|
|
1576
1776
|
|
|
1577
1777
|
#### Defined in
|
|
1578
1778
|
|
|
1579
|
-
[round.ts:6](https://github.com/daysnap/utils/blob/
|
|
1779
|
+
[round.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/round.ts#L6)
|
|
1580
1780
|
|
|
1581
1781
|
___
|
|
1582
1782
|
|
|
@@ -1599,7 +1799,7 @@ ___
|
|
|
1599
1799
|
|
|
1600
1800
|
#### Defined in
|
|
1601
1801
|
|
|
1602
|
-
[sleep.ts:6](https://github.com/daysnap/utils/blob/
|
|
1802
|
+
[sleep.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/sleep.ts#L6)
|
|
1603
1803
|
|
|
1604
1804
|
___
|
|
1605
1805
|
|
|
@@ -1622,7 +1822,7 @@ ___
|
|
|
1622
1822
|
|
|
1623
1823
|
#### Defined in
|
|
1624
1824
|
|
|
1625
|
-
[stringTrim.ts:6](https://github.com/daysnap/utils/blob/
|
|
1825
|
+
[stringTrim.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/stringTrim.ts#L6)
|
|
1626
1826
|
|
|
1627
1827
|
___
|
|
1628
1828
|
|
|
@@ -1644,7 +1844,7 @@ ___
|
|
|
1644
1844
|
|
|
1645
1845
|
#### Defined in
|
|
1646
1846
|
|
|
1647
|
-
[stringifyQuery.ts:7](https://github.com/daysnap/utils/blob/
|
|
1847
|
+
[stringifyQuery.ts:7](https://github.com/daysnap/utils/blob/edb8efd/src/stringifyQuery.ts#L7)
|
|
1648
1848
|
|
|
1649
1849
|
___
|
|
1650
1850
|
|
|
@@ -1659,7 +1859,7 @@ ___
|
|
|
1659
1859
|
|
|
1660
1860
|
| Name | Type |
|
|
1661
1861
|
| :------ | :------ |
|
|
1662
|
-
| `T` | extends (...`args`: []) => `any` |
|
|
1862
|
+
| `T` | extends (...`args`: `any`[]) => `any` |
|
|
1663
1863
|
|
|
1664
1864
|
#### Parameters
|
|
1665
1865
|
|
|
@@ -1687,7 +1887,7 @@ ___
|
|
|
1687
1887
|
|
|
1688
1888
|
#### Defined in
|
|
1689
1889
|
|
|
1690
|
-
[throttle.ts:5](https://github.com/daysnap/utils/blob/
|
|
1890
|
+
[throttle.ts:5](https://github.com/daysnap/utils/blob/edb8efd/src/throttle.ts#L5)
|
|
1691
1891
|
|
|
1692
1892
|
___
|
|
1693
1893
|
|
|
@@ -1711,4 +1911,4 @@ ___
|
|
|
1711
1911
|
|
|
1712
1912
|
#### Defined in
|
|
1713
1913
|
|
|
1714
|
-
[typeOf.ts:6](https://github.com/daysnap/utils/blob/
|
|
1914
|
+
[typeOf.ts:6](https://github.com/daysnap/utils/blob/edb8efd/src/typeOf.ts#L6)
|
package/es/camelCase.js
ADDED
package/es/capitalize.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化字符串参数,一般用来处理 api path params
|
|
3
|
+
* const url = 'api/v1/user/{id}'
|
|
4
|
+
* const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
|
|
5
|
+
* path = 'api/v1/user/123'
|
|
6
|
+
* rest = { xxx: 1 }
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatPathParams(path: string, params?: Record<string, any>): {
|
|
9
|
+
path: string;
|
|
10
|
+
rest: {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化字符串参数,一般用来处理 api path params
|
|
3
|
+
* const url = 'api/v1/user/{id}'
|
|
4
|
+
* const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
|
|
5
|
+
* path = 'api/v1/user/123'
|
|
6
|
+
* rest = { xxx: 1 }
|
|
7
|
+
*/
|
|
8
|
+
export function formatPathParams(path, params = {}) {
|
|
9
|
+
const rest = Object.assign({}, params);
|
|
10
|
+
if (path.includes('{')) {
|
|
11
|
+
Object.keys(rest).forEach((key) => {
|
|
12
|
+
if (path.includes(`{${key}}`)) {
|
|
13
|
+
path = path.replace(`{${key}}`, rest[key]);
|
|
14
|
+
delete rest[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return { path, rest };
|
|
19
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './base64ToBlob';
|
|
2
2
|
export * from './blobToBase64';
|
|
3
|
+
export * from './camelCase';
|
|
3
4
|
export * from './canvasToBlob';
|
|
5
|
+
export * from './capitalize';
|
|
4
6
|
export * from './clone';
|
|
5
7
|
export * from './cloneSimple';
|
|
6
8
|
export * from './compareVersion';
|
|
@@ -18,6 +20,7 @@ export * from './filterPhone';
|
|
|
18
20
|
export * from './formatAmount';
|
|
19
21
|
export * from './formatDate';
|
|
20
22
|
export * from './formatMessage';
|
|
23
|
+
export * from './formatPathParams';
|
|
21
24
|
export * from './getBlobByUrl';
|
|
22
25
|
export * from './getDayMillisecond';
|
|
23
26
|
export * from './getImageInfo';
|
|
@@ -52,6 +55,7 @@ export * from './isURL';
|
|
|
52
55
|
export * from './isUndefined';
|
|
53
56
|
export * from './isWeixin';
|
|
54
57
|
export * from './isWindow';
|
|
58
|
+
export * from './kebabCase';
|
|
55
59
|
export * from './omit';
|
|
56
60
|
export * from './padding';
|
|
57
61
|
export * from './parseDate';
|
|
@@ -59,6 +63,7 @@ export * from './parseError';
|
|
|
59
63
|
export * from './parseObject';
|
|
60
64
|
export * from './parsePath';
|
|
61
65
|
export * from './parseQuery';
|
|
66
|
+
export * from './pascalCase';
|
|
62
67
|
export * from './pick';
|
|
63
68
|
export * from './replaceCrlf';
|
|
64
69
|
export * from './reserve';
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* 本文件自动生成 './scripts/entry.js' */
|
|
2
2
|
export * from './base64ToBlob';
|
|
3
3
|
export * from './blobToBase64';
|
|
4
|
+
export * from './camelCase';
|
|
4
5
|
export * from './canvasToBlob';
|
|
6
|
+
export * from './capitalize';
|
|
5
7
|
export * from './clone';
|
|
6
8
|
export * from './cloneSimple';
|
|
7
9
|
export * from './compareVersion';
|
|
@@ -19,6 +21,7 @@ export * from './filterPhone';
|
|
|
19
21
|
export * from './formatAmount';
|
|
20
22
|
export * from './formatDate';
|
|
21
23
|
export * from './formatMessage';
|
|
24
|
+
export * from './formatPathParams';
|
|
22
25
|
export * from './getBlobByUrl';
|
|
23
26
|
export * from './getDayMillisecond';
|
|
24
27
|
export * from './getImageInfo';
|
|
@@ -53,6 +56,7 @@ export * from './isURL';
|
|
|
53
56
|
export * from './isUndefined';
|
|
54
57
|
export * from './isWeixin';
|
|
55
58
|
export * from './isWindow';
|
|
59
|
+
export * from './kebabCase';
|
|
56
60
|
export * from './omit';
|
|
57
61
|
export * from './padding';
|
|
58
62
|
export * from './parseDate';
|
|
@@ -60,6 +64,7 @@ export * from './parseError';
|
|
|
60
64
|
export * from './parseObject';
|
|
61
65
|
export * from './parsePath';
|
|
62
66
|
export * from './parseQuery';
|
|
67
|
+
export * from './pascalCase';
|
|
63
68
|
export * from './pick';
|
|
64
69
|
export * from './replaceCrlf';
|
|
65
70
|
export * from './reserve';
|
package/es/kebabCase.js
ADDED
package/es/pascalCase.js
ADDED
package/lib/camelCase.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.camelCase = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 驼峰
|
|
6
|
+
* camelCase('hello-world') => helloWorld
|
|
7
|
+
*/
|
|
8
|
+
function camelCase(str) {
|
|
9
|
+
return str.replace(/-(\w)/g, (_, c) => (c ? c.toUpperCase() : ''));
|
|
10
|
+
}
|
|
11
|
+
exports.camelCase = camelCase;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.capitalize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 首字母大写
|
|
6
|
+
* capitalize('hello world') => Hello world
|
|
7
|
+
*/
|
|
8
|
+
function capitalize(str) {
|
|
9
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
10
|
+
}
|
|
11
|
+
exports.capitalize = capitalize;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化字符串参数,一般用来处理 api path params
|
|
3
|
+
* const url = 'api/v1/user/{id}'
|
|
4
|
+
* const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
|
|
5
|
+
* path = 'api/v1/user/123'
|
|
6
|
+
* rest = { xxx: 1 }
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatPathParams(path: string, params?: Record<string, any>): {
|
|
9
|
+
path: string;
|
|
10
|
+
rest: {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPathParams = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 格式化字符串参数,一般用来处理 api path params
|
|
6
|
+
* const url = 'api/v1/user/{id}'
|
|
7
|
+
* const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
|
|
8
|
+
* path = 'api/v1/user/123'
|
|
9
|
+
* rest = { xxx: 1 }
|
|
10
|
+
*/
|
|
11
|
+
function formatPathParams(path, params = {}) {
|
|
12
|
+
const rest = Object.assign({}, params);
|
|
13
|
+
if (path.includes('{')) {
|
|
14
|
+
Object.keys(rest).forEach((key) => {
|
|
15
|
+
if (path.includes(`{${key}}`)) {
|
|
16
|
+
path = path.replace(`{${key}}`, rest[key]);
|
|
17
|
+
delete rest[key];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return { path, rest };
|
|
22
|
+
}
|
|
23
|
+
exports.formatPathParams = formatPathParams;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './base64ToBlob';
|
|
2
2
|
export * from './blobToBase64';
|
|
3
|
+
export * from './camelCase';
|
|
3
4
|
export * from './canvasToBlob';
|
|
5
|
+
export * from './capitalize';
|
|
4
6
|
export * from './clone';
|
|
5
7
|
export * from './cloneSimple';
|
|
6
8
|
export * from './compareVersion';
|
|
@@ -18,6 +20,7 @@ export * from './filterPhone';
|
|
|
18
20
|
export * from './formatAmount';
|
|
19
21
|
export * from './formatDate';
|
|
20
22
|
export * from './formatMessage';
|
|
23
|
+
export * from './formatPathParams';
|
|
21
24
|
export * from './getBlobByUrl';
|
|
22
25
|
export * from './getDayMillisecond';
|
|
23
26
|
export * from './getImageInfo';
|
|
@@ -52,6 +55,7 @@ export * from './isURL';
|
|
|
52
55
|
export * from './isUndefined';
|
|
53
56
|
export * from './isWeixin';
|
|
54
57
|
export * from './isWindow';
|
|
58
|
+
export * from './kebabCase';
|
|
55
59
|
export * from './omit';
|
|
56
60
|
export * from './padding';
|
|
57
61
|
export * from './parseDate';
|
|
@@ -59,6 +63,7 @@ export * from './parseError';
|
|
|
59
63
|
export * from './parseObject';
|
|
60
64
|
export * from './parsePath';
|
|
61
65
|
export * from './parseQuery';
|
|
66
|
+
export * from './pascalCase';
|
|
62
67
|
export * from './pick';
|
|
63
68
|
export * from './replaceCrlf';
|
|
64
69
|
export * from './reserve';
|
package/lib/index.js
CHANGED
|
@@ -17,7 +17,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
__exportStar(require("./base64ToBlob"), exports);
|
|
19
19
|
__exportStar(require("./blobToBase64"), exports);
|
|
20
|
+
__exportStar(require("./camelCase"), exports);
|
|
20
21
|
__exportStar(require("./canvasToBlob"), exports);
|
|
22
|
+
__exportStar(require("./capitalize"), exports);
|
|
21
23
|
__exportStar(require("./clone"), exports);
|
|
22
24
|
__exportStar(require("./cloneSimple"), exports);
|
|
23
25
|
__exportStar(require("./compareVersion"), exports);
|
|
@@ -35,6 +37,7 @@ __exportStar(require("./filterPhone"), exports);
|
|
|
35
37
|
__exportStar(require("./formatAmount"), exports);
|
|
36
38
|
__exportStar(require("./formatDate"), exports);
|
|
37
39
|
__exportStar(require("./formatMessage"), exports);
|
|
40
|
+
__exportStar(require("./formatPathParams"), exports);
|
|
38
41
|
__exportStar(require("./getBlobByUrl"), exports);
|
|
39
42
|
__exportStar(require("./getDayMillisecond"), exports);
|
|
40
43
|
__exportStar(require("./getImageInfo"), exports);
|
|
@@ -69,6 +72,7 @@ __exportStar(require("./isURL"), exports);
|
|
|
69
72
|
__exportStar(require("./isUndefined"), exports);
|
|
70
73
|
__exportStar(require("./isWeixin"), exports);
|
|
71
74
|
__exportStar(require("./isWindow"), exports);
|
|
75
|
+
__exportStar(require("./kebabCase"), exports);
|
|
72
76
|
__exportStar(require("./omit"), exports);
|
|
73
77
|
__exportStar(require("./padding"), exports);
|
|
74
78
|
__exportStar(require("./parseDate"), exports);
|
|
@@ -76,6 +80,7 @@ __exportStar(require("./parseError"), exports);
|
|
|
76
80
|
__exportStar(require("./parseObject"), exports);
|
|
77
81
|
__exportStar(require("./parsePath"), exports);
|
|
78
82
|
__exportStar(require("./parseQuery"), exports);
|
|
83
|
+
__exportStar(require("./pascalCase"), exports);
|
|
79
84
|
__exportStar(require("./pick"), exports);
|
|
80
85
|
__exportStar(require("./replaceCrlf"), exports);
|
|
81
86
|
__exportStar(require("./reserve"), exports);
|
package/lib/kebabCase.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kebabCase = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 说明
|
|
6
|
+
* kebabCase('helloWorld') => hello-world
|
|
7
|
+
*/
|
|
8
|
+
function kebabCase(key) {
|
|
9
|
+
const result = key.replace(/([A-Z])/g, ' $1').trim();
|
|
10
|
+
return result.split(' ').join('-').toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
exports.kebabCase = kebabCase;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pascalCase = void 0;
|
|
4
|
+
const camelCase_1 = require("./camelCase");
|
|
5
|
+
const capitalize_1 = require("./capitalize");
|
|
6
|
+
/**
|
|
7
|
+
* 首字母大写的驼峰
|
|
8
|
+
* pascalCase('hello-world') => HelloWorld
|
|
9
|
+
*/
|
|
10
|
+
function pascalCase(str) {
|
|
11
|
+
return (0, capitalize_1.capitalize)((0, camelCase_1.camelCase)(str));
|
|
12
|
+
}
|
|
13
|
+
exports.pascalCase = pascalCase;
|