@daysnap/utils 0.0.29 → 0.0.31

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.
Files changed (49) hide show
  1. package/README.md +4 -0
  2. package/docs/.nojekyll +1 -0
  3. package/docs/README.md +18 -0
  4. package/docs/modules.md +1209 -0
  5. package/es/compareVersion.d.ts +6 -4
  6. package/es/compareVersion.js +14 -12
  7. package/es/inBrowser.d.ts +4 -0
  8. package/es/inBrowser.js +6 -0
  9. package/es/index.d.ts +9 -0
  10. package/es/index.js +10 -1
  11. package/es/isEmptyObject.d.ts +5 -0
  12. package/es/isEmptyObject.js +7 -0
  13. package/es/isError.d.ts +4 -0
  14. package/es/isError.js +6 -0
  15. package/es/isJSONString.d.ts +5 -0
  16. package/es/isJSONString.js +13 -0
  17. package/es/isLicenseCode.d.ts +5 -0
  18. package/es/isLicenseCode.js +7 -0
  19. package/es/isWindow.d.ts +5 -0
  20. package/es/isWindow.js +7 -0
  21. package/es/parseQuery.d.ts +6 -0
  22. package/es/parseQuery.js +33 -0
  23. package/es/sleep.d.ts +4 -0
  24. package/es/sleep.js +9 -0
  25. package/es/stringifyQuery.d.ts +4 -0
  26. package/es/stringifyQuery.js +13 -0
  27. package/lib/compareVersion.d.ts +6 -4
  28. package/lib/compareVersion.js +14 -12
  29. package/lib/inBrowser.d.ts +4 -0
  30. package/lib/inBrowser.js +12 -0
  31. package/lib/index.d.ts +9 -0
  32. package/lib/index.js +99 -0
  33. package/lib/isEmptyObject.d.ts +5 -0
  34. package/lib/isEmptyObject.js +13 -0
  35. package/lib/isError.d.ts +4 -0
  36. package/lib/isError.js +12 -0
  37. package/lib/isJSONString.d.ts +5 -0
  38. package/lib/isJSONString.js +19 -0
  39. package/lib/isLicenseCode.d.ts +5 -0
  40. package/lib/isLicenseCode.js +13 -0
  41. package/lib/isWindow.d.ts +5 -0
  42. package/lib/isWindow.js +13 -0
  43. package/lib/parseQuery.d.ts +6 -0
  44. package/lib/parseQuery.js +40 -0
  45. package/lib/sleep.d.ts +4 -0
  46. package/lib/sleep.js +15 -0
  47. package/lib/stringifyQuery.d.ts +4 -0
  48. package/lib/stringifyQuery.js +19 -0
  49. package/package.json +9 -4
@@ -0,0 +1,1209 @@
1
+ [@daysnap/utils](README.md) / Exports
2
+
3
+ # @daysnap/utils
4
+
5
+ ## Table of contents
6
+
7
+ ### Functions
8
+
9
+ - [base64ToBlob](modules.md#base64toblob)
10
+ - [blobToBase64](modules.md#blobtobase64)
11
+ - [colorGenByHash](modules.md#colorgenbyhash)
12
+ - [compareVersion](modules.md#compareversion)
13
+ - [compressImage](modules.md#compressimage)
14
+ - [downloadFile](modules.md#downloadfile)
15
+ - [each](modules.md#each)
16
+ - [filterBankCardNo](modules.md#filterbankcardno)
17
+ - [filterEmoji](modules.md#filteremoji)
18
+ - [filterIdCard](modules.md#filteridcard)
19
+ - [filterName](modules.md#filtername)
20
+ - [filterPhone](modules.md#filterphone)
21
+ - [formatAmount](modules.md#formatamount)
22
+ - [formatDate](modules.md#formatdate)
23
+ - [getBlobByUrl](modules.md#getblobbyurl)
24
+ - [getCache](modules.md#getcache)
25
+ - [getDayMillisecond](modules.md#getdaymillisecond)
26
+ - [getImageInfo](modules.md#getimageinfo)
27
+ - [getLocal](modules.md#getlocal)
28
+ - [getVideoInfo](modules.md#getvideoinfo)
29
+ - [inBrowser](modules.md#inbrowser)
30
+ - [isAndroid](modules.md#isandroid)
31
+ - [isEmail](modules.md#isemail)
32
+ - [isEmpty](modules.md#isempty)
33
+ - [isEmptyObject](modules.md#isemptyobject)
34
+ - [isError](modules.md#iserror)
35
+ - [isFunction](modules.md#isfunction)
36
+ - [isIOS](modules.md#isios)
37
+ - [isIdCard](modules.md#isidcard)
38
+ - [isJSONString](modules.md#isjsonstring)
39
+ - [isLicenseCode](modules.md#islicensecode)
40
+ - [isMobile](modules.md#ismobile)
41
+ - [isNull](modules.md#isnull)
42
+ - [isObject](modules.md#isobject)
43
+ - [isPhone](modules.md#isphone)
44
+ - [isPromise](modules.md#ispromise)
45
+ - [isRegExp](modules.md#isregexp)
46
+ - [isString](modules.md#isstring)
47
+ - [isUndefined](modules.md#isundefined)
48
+ - [isWindow](modules.md#iswindow)
49
+ - [omit](modules.md#omit)
50
+ - [parseDate](modules.md#parsedate)
51
+ - [parseError](modules.md#parseerror)
52
+ - [parsePath](modules.md#parsepath)
53
+ - [parseQuery](modules.md#parsequery)
54
+ - [pick](modules.md#pick)
55
+ - [replaceCrlf](modules.md#replacecrlf)
56
+ - [reserve](modules.md#reserve)
57
+ - [sleep](modules.md#sleep)
58
+ - [stringifyQuery](modules.md#stringifyquery)
59
+
60
+ ## Functions
61
+
62
+ ### base64ToBlob
63
+
64
+ ▸ **base64ToBlob**(`base64`, `contentType?`): `Blob`
65
+
66
+ base64 转 blob
67
+
68
+ #### Parameters
69
+
70
+ | Name | Type |
71
+ | :------ | :------ |
72
+ | `base64` | `string` |
73
+ | `contentType?` | `string` |
74
+
75
+ #### Returns
76
+
77
+ `Blob`
78
+
79
+ #### Defined in
80
+
81
+ [base64ToBlob.ts:4](https://github.com/daysnap/utils/blob/d990909/src/base64ToBlob.ts#L4)
82
+
83
+ ___
84
+
85
+ ### blobToBase64
86
+
87
+ ▸ **blobToBase64**(`blob`): `Promise`<`string` \| `ArrayBuffer`\>
88
+
89
+ blob 转 base64
90
+
91
+ #### Parameters
92
+
93
+ | Name | Type |
94
+ | :------ | :------ |
95
+ | `blob` | `Blob` |
96
+
97
+ #### Returns
98
+
99
+ `Promise`<`string` \| `ArrayBuffer`\>
100
+
101
+ #### Defined in
102
+
103
+ [blobToBase64.ts:4](https://github.com/daysnap/utils/blob/d990909/src/blobToBase64.ts#L4)
104
+
105
+ ___
106
+
107
+ ### colorGenByHash
108
+
109
+ ▸ **colorGenByHash**(`str`): `string`
110
+
111
+ 根据字符串hash值生成颜色值
112
+
113
+ #### Parameters
114
+
115
+ | Name | Type |
116
+ | :------ | :------ |
117
+ | `str` | `string` |
118
+
119
+ #### Returns
120
+
121
+ `string`
122
+
123
+ #### Defined in
124
+
125
+ [createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/d990909/src/createHexColorByHash.ts#L4)
126
+
127
+ ___
128
+
129
+ ### compareVersion
130
+
131
+ ▸ **compareVersion**(`nv`, `v`): ``-1`` \| ``0`` \| ``1``
132
+
133
+ 比对版本
134
+ -1 => nv < v
135
+ 0 => nv === v
136
+ 1 => nv > v
137
+
138
+ #### Parameters
139
+
140
+ | Name | Type | Description |
141
+ | :------ | :------ | :------ |
142
+ | `nv` | `string` | 新版本 |
143
+ | `v` | `string` | 版本 |
144
+
145
+ #### Returns
146
+
147
+ ``-1`` \| ``0`` \| ``1``
148
+
149
+ #### Defined in
150
+
151
+ [compareVersion.ts:9](https://github.com/daysnap/utils/blob/d990909/src/compareVersion.ts#L9)
152
+
153
+ ___
154
+
155
+ ### compressImage
156
+
157
+ ▸ **compressImage**(`image`): `HTMLCanvasElement`
158
+
159
+ 压缩图片
160
+
161
+ #### Parameters
162
+
163
+ | Name | Type |
164
+ | :------ | :------ |
165
+ | `image` | `CanvasImageSource` |
166
+
167
+ #### Returns
168
+
169
+ `HTMLCanvasElement`
170
+
171
+ #### Defined in
172
+
173
+ [compressImage.ts:6](https://github.com/daysnap/utils/blob/d990909/src/compressImage.ts#L6)
174
+
175
+ ___
176
+
177
+ ### downloadFile
178
+
179
+ ▸ **downloadFile**(`data`, `options?`): `void`
180
+
181
+ 通过 a 标签下载文件
182
+
183
+ #### Parameters
184
+
185
+ | Name | Type |
186
+ | :------ | :------ |
187
+ | `data` | `string` \| `Blob` \| `MediaSource` |
188
+ | `options?` | `Object` |
189
+ | `options.fileName?` | `string` |
190
+
191
+ #### Returns
192
+
193
+ `void`
194
+
195
+ #### Defined in
196
+
197
+ [downloadFile.ts:4](https://github.com/daysnap/utils/blob/d990909/src/downloadFile.ts#L4)
198
+
199
+ ___
200
+
201
+ ### each
202
+
203
+ ▸ **each**<`T`\>(`data`, `callback`): `void`
204
+
205
+ 支持遍历数组和对象
206
+
207
+ #### Type parameters
208
+
209
+ | Name |
210
+ | :------ |
211
+ | `T` |
212
+
213
+ #### Parameters
214
+
215
+ | Name | Type |
216
+ | :------ | :------ |
217
+ | `data` | `T`[] |
218
+ | `callback` | (`item`: `T`, `index`: `number`) => `void` |
219
+
220
+ #### Returns
221
+
222
+ `void`
223
+
224
+ #### Defined in
225
+
226
+ [each.ts:4](https://github.com/daysnap/utils/blob/d990909/src/each.ts#L4)
227
+
228
+ ▸ **each**<`T`\>(`data`, `callback`): `void`
229
+
230
+ #### Type parameters
231
+
232
+ | Name |
233
+ | :------ |
234
+ | `T` |
235
+
236
+ #### Parameters
237
+
238
+ | Name | Type |
239
+ | :------ | :------ |
240
+ | `data` | `Record`<`string`, `T`\> |
241
+ | `callback` | (`item`: `T`, `key`: `string`) => `void` |
242
+
243
+ #### Returns
244
+
245
+ `void`
246
+
247
+ #### Defined in
248
+
249
+ [each.ts:8](https://github.com/daysnap/utils/blob/d990909/src/each.ts#L8)
250
+
251
+ ___
252
+
253
+ ### filterBankCardNo
254
+
255
+ ▸ **filterBankCardNo**(`val`): `string`
256
+
257
+ 过滤银行卡号
258
+
259
+ #### Parameters
260
+
261
+ | Name | Type |
262
+ | :------ | :------ |
263
+ | `val` | `string` |
264
+
265
+ #### Returns
266
+
267
+ `string`
268
+
269
+ #### Defined in
270
+
271
+ [filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/d990909/src/filterBankCardNo.ts#L4)
272
+
273
+ ___
274
+
275
+ ### filterEmoji
276
+
277
+ ▸ **filterEmoji**(`val`): `string`
278
+
279
+ 过滤emoji
280
+
281
+ #### Parameters
282
+
283
+ | Name | Type |
284
+ | :------ | :------ |
285
+ | `val` | `string` |
286
+
287
+ #### Returns
288
+
289
+ `string`
290
+
291
+ #### Defined in
292
+
293
+ [filterEmoji.ts:4](https://github.com/daysnap/utils/blob/d990909/src/filterEmoji.ts#L4)
294
+
295
+ ___
296
+
297
+ ### filterIdCard
298
+
299
+ ▸ **filterIdCard**(`val`): `string`
300
+
301
+ 身份证号码加 *
302
+
303
+ #### Parameters
304
+
305
+ | Name | Type |
306
+ | :------ | :------ |
307
+ | `val` | `string` |
308
+
309
+ #### Returns
310
+
311
+ `string`
312
+
313
+ #### Defined in
314
+
315
+ [filterIdCard.ts:4](https://github.com/daysnap/utils/blob/d990909/src/filterIdCard.ts#L4)
316
+
317
+ ___
318
+
319
+ ### filterName
320
+
321
+ ▸ **filterName**(`val`): `string`
322
+
323
+ 过滤姓名
324
+
325
+ #### Parameters
326
+
327
+ | Name | Type |
328
+ | :------ | :------ |
329
+ | `val` | `string` |
330
+
331
+ #### Returns
332
+
333
+ `string`
334
+
335
+ #### Defined in
336
+
337
+ [filterName.ts:4](https://github.com/daysnap/utils/blob/d990909/src/filterName.ts#L4)
338
+
339
+ ___
340
+
341
+ ### filterPhone
342
+
343
+ ▸ **filterPhone**(`val`, `sep?`): `string`
344
+
345
+ 手机号加 *
346
+ filterPhone('13177778888') => 131****8888
347
+ filterPhone('13177778888', ' ') => 131 **** 8888
348
+
349
+ #### Parameters
350
+
351
+ | Name | Type | Default value |
352
+ | :------ | :------ | :------ |
353
+ | `val` | `string` | `undefined` |
354
+ | `sep` | `string` | `''` |
355
+
356
+ #### Returns
357
+
358
+ `string`
359
+
360
+ #### Defined in
361
+
362
+ [filterPhone.ts:6](https://github.com/daysnap/utils/blob/d990909/src/filterPhone.ts#L6)
363
+
364
+ ___
365
+
366
+ ### formatAmount
367
+
368
+ ▸ **formatAmount**(`s`, `radix?`): `string`
369
+
370
+ 格式化金额,默认元
371
+
372
+ #### Parameters
373
+
374
+ | Name | Type | Default value |
375
+ | :------ | :------ | :------ |
376
+ | `s` | `string` | `undefined` |
377
+ | `radix` | `number` | `1` |
378
+
379
+ #### Returns
380
+
381
+ `string`
382
+
383
+ #### Defined in
384
+
385
+ [formatAmount.ts:4](https://github.com/daysnap/utils/blob/d990909/src/formatAmount.ts#L4)
386
+
387
+ ___
388
+
389
+ ### formatDate
390
+
391
+ ▸ **formatDate**(`val`, `fmt?`): `string`
392
+
393
+ 格式化日期
394
+
395
+ #### Parameters
396
+
397
+ | Name | Type | Default value |
398
+ | :------ | :------ | :------ |
399
+ | `val` | `string` \| `number` \| `Date` | `undefined` |
400
+ | `fmt` | `string` | `'yyyy-MM-dd hh:mm:ss'` |
401
+
402
+ #### Returns
403
+
404
+ `string`
405
+
406
+ #### Defined in
407
+
408
+ [formatDate.ts:6](https://github.com/daysnap/utils/blob/d990909/src/formatDate.ts#L6)
409
+
410
+ ___
411
+
412
+ ### getBlobByUrl
413
+
414
+ ▸ **getBlobByUrl**(`url`): `Promise`<`Blob`\>
415
+
416
+ 根据在线 url 返回 blob
417
+
418
+ #### Parameters
419
+
420
+ | Name | Type |
421
+ | :------ | :------ |
422
+ | `url` | `string` |
423
+
424
+ #### Returns
425
+
426
+ `Promise`<`Blob`\>
427
+
428
+ #### Defined in
429
+
430
+ [getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/d990909/src/getBlobByUrl.ts#L4)
431
+
432
+ ___
433
+
434
+ ### getCache
435
+
436
+ ▸ **getCache**(): `Object`
437
+
438
+ #### Returns
439
+
440
+ `Object`
441
+
442
+ | Name | Type |
443
+ | :------ | :------ |
444
+ | `clear` | () => `void` |
445
+ | `generate` | <T\>(`key`: `string`) => { `getItem`: (`defaultVal?`: `Partial`<`T`\>) => `any` ; `removeItem`: () => `void` ; `setItem`: (`val`: `T`) => `T` ; `updateItem`: (`val`: `Partial`<`T`\>) => `T` } |
446
+ | `getItem` | <T\>(`key`: `string`, `defaultVal`: `Partial`<`T`\>) => `any` |
447
+ | `removeItem` | (`key`: `string`) => `void` |
448
+ | `setItem` | <T\>(`key`: `string`, `val`: `T`) => `T` |
449
+ | `updateItem` | <T\>(`key`: `string`, `val`: `Partial`<`T`\>) => `T` |
450
+
451
+ #### Defined in
452
+
453
+ [storage/index.ts:7](https://github.com/daysnap/utils/blob/d990909/src/storage/index.ts#L7)
454
+
455
+ ___
456
+
457
+ ### getDayMillisecond
458
+
459
+ ▸ **getDayMillisecond**(`day?`): `number`
460
+
461
+ 获取多少天的毫秒数 默认获取1天的
462
+
463
+ #### Parameters
464
+
465
+ | Name | Type | Default value |
466
+ | :------ | :------ | :------ |
467
+ | `day` | `number` | `1` |
468
+
469
+ #### Returns
470
+
471
+ `number`
472
+
473
+ #### Defined in
474
+
475
+ [getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/d990909/src/getDayMillisecond.ts#L4)
476
+
477
+ ___
478
+
479
+ ### getImageInfo
480
+
481
+ ▸ **getImageInfo**(`src`): `Promise`<`HTMLImageElement`\>
482
+
483
+ 获取图片信息
484
+
485
+ #### Parameters
486
+
487
+ | Name | Type |
488
+ | :------ | :------ |
489
+ | `src` | `string` |
490
+
491
+ #### Returns
492
+
493
+ `Promise`<`HTMLImageElement`\>
494
+
495
+ #### Defined in
496
+
497
+ [getImageInfo.ts:4](https://github.com/daysnap/utils/blob/d990909/src/getImageInfo.ts#L4)
498
+
499
+ ___
500
+
501
+ ### getLocal
502
+
503
+ ▸ **getLocal**(): `Object`
504
+
505
+ #### Returns
506
+
507
+ `Object`
508
+
509
+ | Name | Type |
510
+ | :------ | :------ |
511
+ | `clear` | () => `void` |
512
+ | `generate` | <T\>(`key`: `string`) => { `getItem`: (`defaultVal?`: `Partial`<`T`\>) => `any` ; `removeItem`: () => `void` ; `setItem`: (`val`: `T`) => `T` ; `updateItem`: (`val`: `Partial`<`T`\>) => `T` } |
513
+ | `getItem` | <T\>(`key`: `string`, `defaultVal`: `Partial`<`T`\>) => `any` |
514
+ | `removeItem` | (`key`: `string`) => `void` |
515
+ | `setItem` | <T\>(`key`: `string`, `val`: `T`) => `T` |
516
+ | `updateItem` | <T\>(`key`: `string`, `val`: `Partial`<`T`\>) => `T` |
517
+
518
+ #### Defined in
519
+
520
+ [storage/index.ts:7](https://github.com/daysnap/utils/blob/d990909/src/storage/index.ts#L7)
521
+
522
+ ___
523
+
524
+ ### getVideoInfo
525
+
526
+ ▸ **getVideoInfo**(`src`): `Promise`<`HTMLVideoElement`\>
527
+
528
+ 获取 video 信息
529
+
530
+ #### Parameters
531
+
532
+ | Name | Type |
533
+ | :------ | :------ |
534
+ | `src` | `string` |
535
+
536
+ #### Returns
537
+
538
+ `Promise`<`HTMLVideoElement`\>
539
+
540
+ #### Defined in
541
+
542
+ [getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/d990909/src/getVideoInfo.ts#L4)
543
+
544
+ ___
545
+
546
+ ### inBrowser
547
+
548
+ ▸ **inBrowser**(): `boolean`
549
+
550
+ 判断是否是浏览器环境
551
+
552
+ #### Returns
553
+
554
+ `boolean`
555
+
556
+ #### Defined in
557
+
558
+ [inBrowser.ts:4](https://github.com/daysnap/utils/blob/d990909/src/inBrowser.ts#L4)
559
+
560
+ ___
561
+
562
+ ### isAndroid
563
+
564
+ ▸ **isAndroid**(): `boolean`
565
+
566
+ 校验是否是安卓
567
+
568
+ #### Returns
569
+
570
+ `boolean`
571
+
572
+ #### Defined in
573
+
574
+ [isAndroid.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isAndroid.ts#L4)
575
+
576
+ ___
577
+
578
+ ### isEmail
579
+
580
+ ▸ **isEmail**(`val`): `boolean`
581
+
582
+ 校验是否是邮箱
583
+
584
+ #### Parameters
585
+
586
+ | Name | Type |
587
+ | :------ | :------ |
588
+ | `val` | `string` |
589
+
590
+ #### Returns
591
+
592
+ `boolean`
593
+
594
+ #### Defined in
595
+
596
+ [isEmail.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isEmail.ts#L4)
597
+
598
+ ___
599
+
600
+ ### isEmpty
601
+
602
+ ▸ **isEmpty**(`val`): `boolean`
603
+
604
+ 校验是否为空 ''、undefined、null
605
+
606
+ #### Parameters
607
+
608
+ | Name | Type |
609
+ | :------ | :------ |
610
+ | `val` | `unknown` |
611
+
612
+ #### Returns
613
+
614
+ `boolean`
615
+
616
+ #### Defined in
617
+
618
+ [isEmpty.ts:6](https://github.com/daysnap/utils/blob/d990909/src/isEmpty.ts#L6)
619
+
620
+ ___
621
+
622
+ ### isEmptyObject
623
+
624
+ ▸ **isEmptyObject**(`v`): `boolean`
625
+
626
+ 判断是否是空对象
627
+
628
+ #### Parameters
629
+
630
+ | Name | Type | Description |
631
+ | :------ | :------ | :------ |
632
+ | `v` | `object` | 对象 |
633
+
634
+ #### Returns
635
+
636
+ `boolean`
637
+
638
+ #### Defined in
639
+
640
+ [isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/d990909/src/isEmptyObject.ts#L5)
641
+
642
+ ___
643
+
644
+ ### isError
645
+
646
+ ▸ **isError**(`val`): val is Error
647
+
648
+ 校验是否是 error
649
+
650
+ #### Parameters
651
+
652
+ | Name | Type |
653
+ | :------ | :------ |
654
+ | `val` | `unknown` |
655
+
656
+ #### Returns
657
+
658
+ val is Error
659
+
660
+ #### Defined in
661
+
662
+ [isError.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isError.ts#L4)
663
+
664
+ ___
665
+
666
+ ### isFunction
667
+
668
+ ▸ **isFunction**(`val`): val is Function
669
+
670
+ 校验是否是函数
671
+
672
+ #### Parameters
673
+
674
+ | Name | Type |
675
+ | :------ | :------ |
676
+ | `val` | `unknown` |
677
+
678
+ #### Returns
679
+
680
+ val is Function
681
+
682
+ #### Defined in
683
+
684
+ [isFunction.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isFunction.ts#L4)
685
+
686
+ ___
687
+
688
+ ### isIOS
689
+
690
+ ▸ **isIOS**(): `boolean`
691
+
692
+ 校验是否是ios
693
+
694
+ #### Returns
695
+
696
+ `boolean`
697
+
698
+ #### Defined in
699
+
700
+ [isIOS.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isIOS.ts#L4)
701
+
702
+ ___
703
+
704
+ ### isIdCard
705
+
706
+ ▸ **isIdCard**(`val`): `boolean`
707
+
708
+ 校验是否是身份证
709
+
710
+ #### Parameters
711
+
712
+ | Name | Type |
713
+ | :------ | :------ |
714
+ | `val` | `string` |
715
+
716
+ #### Returns
717
+
718
+ `boolean`
719
+
720
+ #### Defined in
721
+
722
+ [isIdCard.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isIdCard.ts#L4)
723
+
724
+ ___
725
+
726
+ ### isJSONString
727
+
728
+ ▸ **isJSONString**(`v`): `boolean`
729
+
730
+ 是否是JSON 字符串
731
+
732
+ #### Parameters
733
+
734
+ | Name | Type |
735
+ | :------ | :------ |
736
+ | `v` | `string` |
737
+
738
+ #### Returns
739
+
740
+ `boolean`
741
+
742
+ #### Defined in
743
+
744
+ [isJSONString.ts:7](https://github.com/daysnap/utils/blob/d990909/src/isJSONString.ts#L7)
745
+
746
+ ___
747
+
748
+ ### isLicenseCode
749
+
750
+ ▸ **isLicenseCode**(`v`): `boolean`
751
+
752
+ 校验是否是车牌号
753
+
754
+ #### Parameters
755
+
756
+ | Name | Type | Description |
757
+ | :------ | :------ | :------ |
758
+ | `v` | `string` | 车牌号 |
759
+
760
+ #### Returns
761
+
762
+ `boolean`
763
+
764
+ #### Defined in
765
+
766
+ [isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/d990909/src/isLicenseCode.ts#L5)
767
+
768
+ ___
769
+
770
+ ### isMobile
771
+
772
+ ▸ **isMobile**(): `boolean`
773
+
774
+ 校验设备是否是手机
775
+
776
+ #### Returns
777
+
778
+ `boolean`
779
+
780
+ #### Defined in
781
+
782
+ [isMobile.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isMobile.ts#L4)
783
+
784
+ ___
785
+
786
+ ### isNull
787
+
788
+ ▸ **isNull**(`val`): val is null
789
+
790
+ 校验是否是 null
791
+
792
+ #### Parameters
793
+
794
+ | Name | Type |
795
+ | :------ | :------ |
796
+ | `val` | `unknown` |
797
+
798
+ #### Returns
799
+
800
+ val is null
801
+
802
+ #### Defined in
803
+
804
+ [isNull.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isNull.ts#L4)
805
+
806
+ ___
807
+
808
+ ### isObject
809
+
810
+ ▸ **isObject**(`val`): val is Record<string, any\>
811
+
812
+ 校验是否是对象
813
+
814
+ #### Parameters
815
+
816
+ | Name | Type |
817
+ | :------ | :------ |
818
+ | `val` | `unknown` |
819
+
820
+ #### Returns
821
+
822
+ val is Record<string, any\>
823
+
824
+ #### Defined in
825
+
826
+ [isObject.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isObject.ts#L4)
827
+
828
+ ___
829
+
830
+ ### isPhone
831
+
832
+ ▸ **isPhone**(`val`): `boolean`
833
+
834
+ 校验是否是手机号码
835
+
836
+ #### Parameters
837
+
838
+ | Name | Type |
839
+ | :------ | :------ |
840
+ | `val` | `string` |
841
+
842
+ #### Returns
843
+
844
+ `boolean`
845
+
846
+ #### Defined in
847
+
848
+ [isPhone.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isPhone.ts#L4)
849
+
850
+ ___
851
+
852
+ ### isPromise
853
+
854
+ ▸ **isPromise**<`T`\>(`val`): val is Promise<T\>
855
+
856
+ 校验是否是 promise
857
+
858
+ #### Type parameters
859
+
860
+ | Name | Type |
861
+ | :------ | :------ |
862
+ | `T` | `any` |
863
+
864
+ #### Parameters
865
+
866
+ | Name | Type |
867
+ | :------ | :------ |
868
+ | `val` | `unknown` |
869
+
870
+ #### Returns
871
+
872
+ val is Promise<T\>
873
+
874
+ #### Defined in
875
+
876
+ [isPromise.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isPromise.ts#L4)
877
+
878
+ ___
879
+
880
+ ### isRegExp
881
+
882
+ ▸ **isRegExp**(`val`): val is RegExp
883
+
884
+ 校验是否是正则表达式
885
+
886
+ #### Parameters
887
+
888
+ | Name | Type |
889
+ | :------ | :------ |
890
+ | `val` | `unknown` |
891
+
892
+ #### Returns
893
+
894
+ val is RegExp
895
+
896
+ #### Defined in
897
+
898
+ [isRegExp.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isRegExp.ts#L4)
899
+
900
+ ___
901
+
902
+ ### isString
903
+
904
+ ▸ **isString**(`val`): val is string
905
+
906
+ 校验是否是字符串
907
+
908
+ #### Parameters
909
+
910
+ | Name | Type |
911
+ | :------ | :------ |
912
+ | `val` | `unknown` |
913
+
914
+ #### Returns
915
+
916
+ val is string
917
+
918
+ #### Defined in
919
+
920
+ [isString.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isString.ts#L4)
921
+
922
+ ___
923
+
924
+ ### isUndefined
925
+
926
+ ▸ **isUndefined**(`val`): val is undefined
927
+
928
+ 校验是否是 undefined
929
+
930
+ #### Parameters
931
+
932
+ | Name | Type |
933
+ | :------ | :------ |
934
+ | `val` | `unknown` |
935
+
936
+ #### Returns
937
+
938
+ val is undefined
939
+
940
+ #### Defined in
941
+
942
+ [isUndefined.ts:4](https://github.com/daysnap/utils/blob/d990909/src/isUndefined.ts#L4)
943
+
944
+ ___
945
+
946
+ ### isWindow
947
+
948
+ ▸ **isWindow**(`val`): val is Window
949
+
950
+ 判断是否是 window 对象
951
+
952
+ #### Parameters
953
+
954
+ | Name | Type | Description |
955
+ | :------ | :------ | :------ |
956
+ | `val` | `unknown` | 需要判断的值 |
957
+
958
+ #### Returns
959
+
960
+ val is Window
961
+
962
+ #### Defined in
963
+
964
+ [isWindow.ts:5](https://github.com/daysnap/utils/blob/d990909/src/isWindow.ts#L5)
965
+
966
+ ___
967
+
968
+ ### omit
969
+
970
+ ▸ **omit**<`T`, `K`\>(`obj`, `fields?`): `Omit`<`T`, `K`\>
971
+
972
+ 排除对象里的某些属性,返回剩下的对象,浅拷贝
973
+
974
+ #### Type parameters
975
+
976
+ | Name | Type |
977
+ | :------ | :------ |
978
+ | `T` | extends `object` |
979
+ | `K` | extends `string` \| `number` \| `symbol` |
980
+
981
+ #### Parameters
982
+
983
+ | Name | Type | Default value |
984
+ | :------ | :------ | :------ |
985
+ | `obj` | `T` | `undefined` |
986
+ | `fields` | `K`[] | `[]` |
987
+
988
+ #### Returns
989
+
990
+ `Omit`<`T`, `K`\>
991
+
992
+ #### Defined in
993
+
994
+ [omit.ts:4](https://github.com/daysnap/utils/blob/d990909/src/omit.ts#L4)
995
+
996
+ ___
997
+
998
+ ### parseDate
999
+
1000
+ ▸ **parseDate**(`v`): `Date`
1001
+
1002
+ 解析成Date
1003
+
1004
+ #### Parameters
1005
+
1006
+ | Name | Type |
1007
+ | :------ | :------ |
1008
+ | `v` | `string` \| `number` \| `Date` |
1009
+
1010
+ #### Returns
1011
+
1012
+ `Date`
1013
+
1014
+ #### Defined in
1015
+
1016
+ [parseDate.ts:4](https://github.com/daysnap/utils/blob/d990909/src/parseDate.ts#L4)
1017
+
1018
+ ___
1019
+
1020
+ ### parseError
1021
+
1022
+ ▸ **parseError**(`val`, `keys?`): `string`
1023
+
1024
+ 解析格式化 error 获取对应的 message
1025
+
1026
+ #### Parameters
1027
+
1028
+ | Name | Type |
1029
+ | :------ | :------ |
1030
+ | `val` | `any` |
1031
+ | `keys` | `string`[] |
1032
+
1033
+ #### Returns
1034
+
1035
+ `string`
1036
+
1037
+ #### Defined in
1038
+
1039
+ [parseError.ts:8](https://github.com/daysnap/utils/blob/d990909/src/parseError.ts#L8)
1040
+
1041
+ ___
1042
+
1043
+ ### parsePath
1044
+
1045
+ ▸ **parsePath**(`obj`, `path`): `Record`<`string`, `any`\>
1046
+
1047
+ 根据路径解析值
1048
+
1049
+ #### Parameters
1050
+
1051
+ | Name | Type |
1052
+ | :------ | :------ |
1053
+ | `obj` | `Record`<`string`, `any`\> |
1054
+ | `path` | `string` |
1055
+
1056
+ #### Returns
1057
+
1058
+ `Record`<`string`, `any`\>
1059
+
1060
+ #### Defined in
1061
+
1062
+ [parsePath.ts:4](https://github.com/daysnap/utils/blob/d990909/src/parsePath.ts#L4)
1063
+
1064
+ ___
1065
+
1066
+ ### parseQuery
1067
+
1068
+ ▸ **parseQuery**(`v?`, `k?`): `Object`
1069
+
1070
+ 解析url参数
1071
+
1072
+ #### Parameters
1073
+
1074
+ | Name | Type | Description |
1075
+ | :------ | :------ | :------ |
1076
+ | `v?` | `string` | URl |
1077
+ | `k?` | `string` | 键名 |
1078
+
1079
+ #### Returns
1080
+
1081
+ `Object`
1082
+
1083
+ #### Defined in
1084
+
1085
+ [parseQuery.ts:8](https://github.com/daysnap/utils/blob/d990909/src/parseQuery.ts#L8)
1086
+
1087
+ ___
1088
+
1089
+ ### pick
1090
+
1091
+ ▸ **pick**<`T`, `K`\>(`obj`, `fields?`): `Pick`<`T`, `K`\>
1092
+
1093
+ 挑选对象里的某些属性,新对象返回
1094
+
1095
+ #### Type parameters
1096
+
1097
+ | Name | Type |
1098
+ | :------ | :------ |
1099
+ | `T` | extends `object` |
1100
+ | `K` | extends `string` \| `number` \| `symbol` |
1101
+
1102
+ #### Parameters
1103
+
1104
+ | Name | Type | Default value |
1105
+ | :------ | :------ | :------ |
1106
+ | `obj` | `T` | `undefined` |
1107
+ | `fields` | `K`[] | `[]` |
1108
+
1109
+ #### Returns
1110
+
1111
+ `Pick`<`T`, `K`\>
1112
+
1113
+ #### Defined in
1114
+
1115
+ [pick.ts:4](https://github.com/daysnap/utils/blob/d990909/src/pick.ts#L4)
1116
+
1117
+ ___
1118
+
1119
+ ### replaceCrlf
1120
+
1121
+ ▸ **replaceCrlf**(`val`, `replaceVal`): `string`
1122
+
1123
+ 替换字符串里面的回车换行
1124
+
1125
+ #### Parameters
1126
+
1127
+ | Name | Type |
1128
+ | :------ | :------ |
1129
+ | `val` | `string` |
1130
+ | `replaceVal` | `string` |
1131
+
1132
+ #### Returns
1133
+
1134
+ `string`
1135
+
1136
+ #### Defined in
1137
+
1138
+ [replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/d990909/src/replaceCrlf.ts#L4)
1139
+
1140
+ ___
1141
+
1142
+ ### reserve
1143
+
1144
+ ▸ **reserve**(`val`, `defaultVal?`): `any`
1145
+
1146
+ 值为 ''、undefined、null 则取默认值
1147
+ 解决:
1148
+ 0 || '--' => '--'
1149
+ reserve(0, '--') => 0
1150
+
1151
+ #### Parameters
1152
+
1153
+ | Name | Type |
1154
+ | :------ | :------ |
1155
+ | `val` | `any` |
1156
+ | `defaultVal?` | `any` |
1157
+
1158
+ #### Returns
1159
+
1160
+ `any`
1161
+
1162
+ #### Defined in
1163
+
1164
+ [reserve.ts:8](https://github.com/daysnap/utils/blob/d990909/src/reserve.ts#L8)
1165
+
1166
+ ___
1167
+
1168
+ ### sleep
1169
+
1170
+ ▸ **sleep**(`timeout`, `isSuccess?`): `Promise`<`void`\>
1171
+
1172
+ 说明
1173
+
1174
+ #### Parameters
1175
+
1176
+ | Name | Type | Default value |
1177
+ | :------ | :------ | :------ |
1178
+ | `timeout` | `number` | `undefined` |
1179
+ | `isSuccess` | `boolean` | `true` |
1180
+
1181
+ #### Returns
1182
+
1183
+ `Promise`<`void`\>
1184
+
1185
+ #### Defined in
1186
+
1187
+ [sleep.ts:4](https://github.com/daysnap/utils/blob/d990909/src/sleep.ts#L4)
1188
+
1189
+ ___
1190
+
1191
+ ### stringifyQuery
1192
+
1193
+ ▸ **stringifyQuery**(`v`): `string`
1194
+
1195
+ 说明
1196
+
1197
+ #### Parameters
1198
+
1199
+ | Name | Type |
1200
+ | :------ | :------ |
1201
+ | `v` | `object` |
1202
+
1203
+ #### Returns
1204
+
1205
+ `string`
1206
+
1207
+ #### Defined in
1208
+
1209
+ [stringifyQuery.ts:6](https://github.com/daysnap/utils/blob/d990909/src/stringifyQuery.ts#L6)