@jhqn/utils-core 0.0.3-beta.8 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +82 -106
- package/dist/index.d.cts +138 -48
- package/dist/index.d.mts +138 -48
- package/dist/index.d.ts +138 -48
- package/dist/index.mjs +74 -106
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,37 @@ type Dict<T = string> = Record<string, T>;
|
|
|
60
60
|
*/
|
|
61
61
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
62
62
|
|
|
63
|
+
interface HostEnv {
|
|
64
|
+
/**
|
|
65
|
+
* 是否是浙里办
|
|
66
|
+
*/
|
|
67
|
+
readonly zlb: boolean
|
|
68
|
+
/**
|
|
69
|
+
* 是否是专有钉
|
|
70
|
+
*/
|
|
71
|
+
readonly zyd: boolean
|
|
72
|
+
/**
|
|
73
|
+
* 是否是浙政钉
|
|
74
|
+
*/
|
|
75
|
+
readonly zzd: boolean
|
|
76
|
+
/**
|
|
77
|
+
* 是否是钉钉/专有钉/浙政钉
|
|
78
|
+
*/
|
|
79
|
+
readonly dd: boolean
|
|
80
|
+
/**
|
|
81
|
+
* 是否是微信
|
|
82
|
+
*/
|
|
83
|
+
readonly wx: boolean
|
|
84
|
+
/**
|
|
85
|
+
* 是否是支付宝
|
|
86
|
+
*/
|
|
87
|
+
readonly zfb: boolean
|
|
88
|
+
/**
|
|
89
|
+
* 是否是小程序
|
|
90
|
+
*/
|
|
91
|
+
readonly mini: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
63
94
|
/**
|
|
64
95
|
* snake2Kebab
|
|
65
96
|
* @param {string} str 字符串
|
|
@@ -273,94 +304,126 @@ declare const jLogOnce: (...args: any[]) => void;
|
|
|
273
304
|
/**
|
|
274
305
|
* 隐藏中间部分
|
|
275
306
|
* @param {string} str 需要隐藏的字符串
|
|
307
|
+
* @returns {string} 隐藏后的字符串
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* hideMiddle('A') // '*'
|
|
311
|
+
* hideMiddle('AB') // '**'
|
|
312
|
+
* hideMiddle('ABC') // 'A*C'
|
|
313
|
+
* hideMiddle('ABCD') // 'A**D'
|
|
314
|
+
* hideMiddle('ABCDE') // 'A***E'
|
|
315
|
+
* ```
|
|
276
316
|
*/
|
|
277
317
|
declare const hideMiddle: (str: UnDef<string>) => string;
|
|
278
318
|
/**
|
|
279
319
|
* 隐藏首尾仅保留中间3分之1
|
|
280
320
|
* @param {string} str 需要隐藏的字符串
|
|
321
|
+
* @returns {string} 隐藏后的字符串
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* hideThird('A') // '*'
|
|
325
|
+
* hideThird('AB') // '**'
|
|
326
|
+
* hideThird('ABC') // 'A*C'
|
|
327
|
+
* hideThird('ABCD') // 'A**D'
|
|
328
|
+
* hideThird('ABCDE') // 'AB*DE'
|
|
329
|
+
* ```
|
|
281
330
|
*/
|
|
282
331
|
declare const hideThird: (str: UnDef<string>) => string;
|
|
283
332
|
/**
|
|
284
333
|
* 隐藏首部
|
|
285
334
|
* @param {string} str 需要隐藏的字符串
|
|
286
335
|
* @param {number} count 隐藏的字符数
|
|
336
|
+
* @returns {string} 隐藏后的字符串
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* hideHead('A') // '*'
|
|
340
|
+
* hideHead('AB') // '*B'
|
|
341
|
+
* hideHead('ABC') // '**C'
|
|
342
|
+
* hideHead('ABC', 1) // '*BC'
|
|
343
|
+
* ```
|
|
287
344
|
*/
|
|
288
345
|
declare const hideHead: (str: UnDef<string>, count?: number) => string;
|
|
289
346
|
/**
|
|
290
347
|
* 隐藏尾部
|
|
291
348
|
* @param {string} str 需要隐藏的字符串
|
|
292
349
|
* @param {number} count 隐藏的字符数
|
|
350
|
+
* @returns {string} 隐藏后的字符串
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* hideTail('A') // '*'
|
|
354
|
+
* hideTail('AB') // 'A*'
|
|
355
|
+
* hideTail('ABC') // 'A**'
|
|
356
|
+
* hideTail('ABC', 1) // 'AB*'
|
|
357
|
+
* ```
|
|
293
358
|
*/
|
|
294
359
|
declare const hideTail: (str: UnDef<string>, count?: number) => string;
|
|
295
360
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @param {string} phone
|
|
361
|
+
* 隐藏手机号/座机号
|
|
362
|
+
* @param {string} phone 手机号/座机号
|
|
363
|
+
* @returns {string} 隐藏后的手机号/座机号
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* hidePhone('13800138000') // '138****8000'
|
|
367
|
+
* hidePhone('010-12345678') // '010****5678'
|
|
368
|
+
* hidePhone('(010)12345678') // '(010)****5678'
|
|
369
|
+
* ```
|
|
298
370
|
*/
|
|
299
371
|
declare const hidePhone: (phone: UnDef<string>) => string;
|
|
300
372
|
/**
|
|
301
373
|
* 隐藏身份证号
|
|
302
374
|
* @param {string} cardNo 身份证号
|
|
303
375
|
* @param {boolean} strong 是否强化隐藏
|
|
376
|
+
* @returns {string} 隐藏后的身份证号
|
|
377
|
+
* @example
|
|
378
|
+
* ```ts
|
|
379
|
+
* hideCardNo('33072319641008384x') // '3****************x'
|
|
380
|
+
* hideCardNo('33072319641008384x', false) // '3***23196410*****x'
|
|
381
|
+
* ```
|
|
304
382
|
*/
|
|
305
383
|
declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
|
|
306
|
-
/**
|
|
307
|
-
* 隐藏姓名第一个字
|
|
308
|
-
* @param {string} name 姓名
|
|
309
|
-
* @deprecated 请使用 hideSurname
|
|
310
|
-
*/
|
|
311
|
-
declare const hideName: (name: UnDef<string>) => string;
|
|
312
384
|
/**
|
|
313
385
|
* 隐藏姓氏
|
|
314
386
|
* @param {string} name 姓名
|
|
387
|
+
* @returns {string} 隐藏后的姓名
|
|
388
|
+
* @example
|
|
389
|
+
* ```ts
|
|
390
|
+
* hideSurname('张三') // '*三'
|
|
391
|
+
* hideSurname('司马懿') // '*马懿'
|
|
392
|
+
* ```
|
|
315
393
|
*/
|
|
316
394
|
declare const hideSurname: (name: UnDef<string>) => string;
|
|
317
395
|
/**
|
|
318
396
|
* 隐藏名字
|
|
319
397
|
* @param {string} name 姓名
|
|
398
|
+
* @returns {string} 隐藏后的姓名
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* hideFirstName('张三') // '张*'
|
|
402
|
+
* hideFirstName('司马懿') // '司马*'
|
|
403
|
+
* ```
|
|
320
404
|
*/
|
|
321
405
|
declare const hideFirstName: (name: UnDef<string>) => string;
|
|
322
406
|
/**
|
|
323
407
|
* 隐藏邮箱
|
|
324
408
|
* @param {string} email 邮箱
|
|
409
|
+
* @returns {string} 隐藏后的邮箱
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* hideEmail('example@hotmail.com') // 'exam***@hotmail.com'
|
|
413
|
+
* ```
|
|
325
414
|
*/
|
|
326
415
|
declare const hideEmail: (email: UnDef<string>) => string;
|
|
327
416
|
/**
|
|
328
417
|
* 隐藏银行卡号
|
|
329
418
|
* @param {string} bankCard 银行卡号
|
|
419
|
+
* @returns {string} 隐藏后的银行卡号
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* hideBankCard('6222021001123456789') // '622202********6789'
|
|
423
|
+
* ```
|
|
330
424
|
*/
|
|
331
425
|
declare const hideBankCard: (bankCard: UnDef<string>) => string;
|
|
332
426
|
|
|
333
|
-
interface HostEnv {
|
|
334
|
-
/**
|
|
335
|
-
* 是否是浙里办
|
|
336
|
-
*/
|
|
337
|
-
readonly zlb: boolean
|
|
338
|
-
/**
|
|
339
|
-
* 是否是专有钉
|
|
340
|
-
*/
|
|
341
|
-
readonly zyd: boolean
|
|
342
|
-
/**
|
|
343
|
-
* 是否是浙政钉
|
|
344
|
-
*/
|
|
345
|
-
readonly zzd: boolean
|
|
346
|
-
/**
|
|
347
|
-
* 是否是钉钉/专有钉/浙政钉
|
|
348
|
-
*/
|
|
349
|
-
readonly dd: boolean
|
|
350
|
-
/**
|
|
351
|
-
* 是否是微信
|
|
352
|
-
*/
|
|
353
|
-
readonly wx: boolean
|
|
354
|
-
/**
|
|
355
|
-
* 是否是支付宝
|
|
356
|
-
*/
|
|
357
|
-
readonly zfb: boolean
|
|
358
|
-
/**
|
|
359
|
-
* 是否是小程序
|
|
360
|
-
*/
|
|
361
|
-
readonly mini: boolean
|
|
362
|
-
}
|
|
363
|
-
|
|
364
427
|
/**
|
|
365
428
|
* 判断是否是浏览器环境
|
|
366
429
|
*/
|
|
@@ -419,23 +482,42 @@ declare function setBaseAttachUrl(baseUrl: string): void;
|
|
|
419
482
|
declare function getBaseAttachUrl(): string;
|
|
420
483
|
|
|
421
484
|
/**
|
|
422
|
-
*
|
|
423
|
-
* @
|
|
424
|
-
* @param
|
|
485
|
+
* JSON 字符串转对象
|
|
486
|
+
* @template T - 解析数据类型
|
|
487
|
+
* @param {string} str - JSON字符串
|
|
488
|
+
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
489
|
+
* @returns {Nullable<T>} 解析后的对象
|
|
490
|
+
* @deprecated 请使用 `parseJSON`
|
|
491
|
+
*/
|
|
492
|
+
declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
493
|
+
/**
|
|
494
|
+
* JSON 字符串转对象
|
|
495
|
+
* @alias parseToJSON
|
|
496
|
+
* @template T - 解析数据类型
|
|
497
|
+
* @param {string} str - JSON字符串
|
|
498
|
+
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
499
|
+
* @returns {Nullable<T>} 解析后的对象
|
|
500
|
+
*/
|
|
501
|
+
declare function parseJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
502
|
+
/**
|
|
503
|
+
* 对象转 JSON 字符串
|
|
504
|
+
* @param {any} value - 对象
|
|
505
|
+
* @param {(this: any, key: string, value: any) => any} replacerFn - 替换函数
|
|
506
|
+
* @returns {string} JSON 字符串
|
|
425
507
|
*/
|
|
426
|
-
declare
|
|
508
|
+
declare function stringifyJSON(value: any, replacerFn?: (this: any, key: string, value: any) => any): string;
|
|
427
509
|
/**
|
|
428
510
|
* JSON.stringify() second param
|
|
429
|
-
* @param
|
|
511
|
+
* @param _key
|
|
430
512
|
* @param value
|
|
431
513
|
*/
|
|
432
|
-
declare
|
|
514
|
+
declare function replacer(_key: any, value: any): any;
|
|
433
515
|
/**
|
|
434
516
|
* JSON.parse() second param
|
|
435
|
-
* @param
|
|
517
|
+
* @param _key
|
|
436
518
|
* @param value
|
|
437
519
|
*/
|
|
438
|
-
declare
|
|
520
|
+
declare function reviver(_key: any, value: any): any;
|
|
439
521
|
/**
|
|
440
522
|
* 过滤obj中仅包括keys的部分
|
|
441
523
|
* @param {Record<string,any>} obj 对象
|
|
@@ -714,6 +796,13 @@ declare const isValidKey: (key: string | number | symbol, object: object) => key
|
|
|
714
796
|
*/
|
|
715
797
|
declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
|
|
716
798
|
|
|
799
|
+
declare const cnPhoneRE: RegExp;
|
|
800
|
+
declare const cnTelRE: RegExp;
|
|
801
|
+
declare const cnTelRE2: RegExp;
|
|
802
|
+
declare const cnUSCIRE: RegExp;
|
|
803
|
+
declare const cnIdCard15Re: RegExp;
|
|
804
|
+
declare const cnIdCard18Re: RegExp;
|
|
805
|
+
declare const emailRE: RegExp;
|
|
717
806
|
/**
|
|
718
807
|
* 是否是[统一社会信用代码](https://zh.wikipedia.org/zh-cn/%E7%BB%9F%E4%B8%80%E7%A4%BE%E4%BC%9A%E4%BF%A1%E7%94%A8%E4%BB%A3%E7%A0%81)
|
|
719
808
|
* @example
|
|
@@ -793,4 +882,5 @@ declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
|
793
882
|
*/
|
|
794
883
|
declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
795
884
|
|
|
796
|
-
export {
|
|
885
|
+
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, cnIdCard15Re, cnIdCard18Re, cnPhoneRE, cnTelRE, cnTelRE2, cnUSCIRE, currencyFmt, dateDuration, dateFmt, emailRE, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUSCI, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseJSON, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, stringifyJSON, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
886
|
+
export type { Dict, HostEnv, MaybeArray, NullOrUndefinable, Nullable, Numeric, PageReq, PageRes, PageResData, PartialBy, Res, UnDef, Undefinable, VK };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,37 @@ type Dict<T = string> = Record<string, T>;
|
|
|
60
60
|
*/
|
|
61
61
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
62
62
|
|
|
63
|
+
interface HostEnv {
|
|
64
|
+
/**
|
|
65
|
+
* 是否是浙里办
|
|
66
|
+
*/
|
|
67
|
+
readonly zlb: boolean
|
|
68
|
+
/**
|
|
69
|
+
* 是否是专有钉
|
|
70
|
+
*/
|
|
71
|
+
readonly zyd: boolean
|
|
72
|
+
/**
|
|
73
|
+
* 是否是浙政钉
|
|
74
|
+
*/
|
|
75
|
+
readonly zzd: boolean
|
|
76
|
+
/**
|
|
77
|
+
* 是否是钉钉/专有钉/浙政钉
|
|
78
|
+
*/
|
|
79
|
+
readonly dd: boolean
|
|
80
|
+
/**
|
|
81
|
+
* 是否是微信
|
|
82
|
+
*/
|
|
83
|
+
readonly wx: boolean
|
|
84
|
+
/**
|
|
85
|
+
* 是否是支付宝
|
|
86
|
+
*/
|
|
87
|
+
readonly zfb: boolean
|
|
88
|
+
/**
|
|
89
|
+
* 是否是小程序
|
|
90
|
+
*/
|
|
91
|
+
readonly mini: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
63
94
|
/**
|
|
64
95
|
* snake2Kebab
|
|
65
96
|
* @param {string} str 字符串
|
|
@@ -273,94 +304,126 @@ declare const jLogOnce: (...args: any[]) => void;
|
|
|
273
304
|
/**
|
|
274
305
|
* 隐藏中间部分
|
|
275
306
|
* @param {string} str 需要隐藏的字符串
|
|
307
|
+
* @returns {string} 隐藏后的字符串
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* hideMiddle('A') // '*'
|
|
311
|
+
* hideMiddle('AB') // '**'
|
|
312
|
+
* hideMiddle('ABC') // 'A*C'
|
|
313
|
+
* hideMiddle('ABCD') // 'A**D'
|
|
314
|
+
* hideMiddle('ABCDE') // 'A***E'
|
|
315
|
+
* ```
|
|
276
316
|
*/
|
|
277
317
|
declare const hideMiddle: (str: UnDef<string>) => string;
|
|
278
318
|
/**
|
|
279
319
|
* 隐藏首尾仅保留中间3分之1
|
|
280
320
|
* @param {string} str 需要隐藏的字符串
|
|
321
|
+
* @returns {string} 隐藏后的字符串
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* hideThird('A') // '*'
|
|
325
|
+
* hideThird('AB') // '**'
|
|
326
|
+
* hideThird('ABC') // 'A*C'
|
|
327
|
+
* hideThird('ABCD') // 'A**D'
|
|
328
|
+
* hideThird('ABCDE') // 'AB*DE'
|
|
329
|
+
* ```
|
|
281
330
|
*/
|
|
282
331
|
declare const hideThird: (str: UnDef<string>) => string;
|
|
283
332
|
/**
|
|
284
333
|
* 隐藏首部
|
|
285
334
|
* @param {string} str 需要隐藏的字符串
|
|
286
335
|
* @param {number} count 隐藏的字符数
|
|
336
|
+
* @returns {string} 隐藏后的字符串
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* hideHead('A') // '*'
|
|
340
|
+
* hideHead('AB') // '*B'
|
|
341
|
+
* hideHead('ABC') // '**C'
|
|
342
|
+
* hideHead('ABC', 1) // '*BC'
|
|
343
|
+
* ```
|
|
287
344
|
*/
|
|
288
345
|
declare const hideHead: (str: UnDef<string>, count?: number) => string;
|
|
289
346
|
/**
|
|
290
347
|
* 隐藏尾部
|
|
291
348
|
* @param {string} str 需要隐藏的字符串
|
|
292
349
|
* @param {number} count 隐藏的字符数
|
|
350
|
+
* @returns {string} 隐藏后的字符串
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* hideTail('A') // '*'
|
|
354
|
+
* hideTail('AB') // 'A*'
|
|
355
|
+
* hideTail('ABC') // 'A**'
|
|
356
|
+
* hideTail('ABC', 1) // 'AB*'
|
|
357
|
+
* ```
|
|
293
358
|
*/
|
|
294
359
|
declare const hideTail: (str: UnDef<string>, count?: number) => string;
|
|
295
360
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @param {string} phone
|
|
361
|
+
* 隐藏手机号/座机号
|
|
362
|
+
* @param {string} phone 手机号/座机号
|
|
363
|
+
* @returns {string} 隐藏后的手机号/座机号
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* hidePhone('13800138000') // '138****8000'
|
|
367
|
+
* hidePhone('010-12345678') // '010****5678'
|
|
368
|
+
* hidePhone('(010)12345678') // '(010)****5678'
|
|
369
|
+
* ```
|
|
298
370
|
*/
|
|
299
371
|
declare const hidePhone: (phone: UnDef<string>) => string;
|
|
300
372
|
/**
|
|
301
373
|
* 隐藏身份证号
|
|
302
374
|
* @param {string} cardNo 身份证号
|
|
303
375
|
* @param {boolean} strong 是否强化隐藏
|
|
376
|
+
* @returns {string} 隐藏后的身份证号
|
|
377
|
+
* @example
|
|
378
|
+
* ```ts
|
|
379
|
+
* hideCardNo('33072319641008384x') // '3****************x'
|
|
380
|
+
* hideCardNo('33072319641008384x', false) // '3***23196410*****x'
|
|
381
|
+
* ```
|
|
304
382
|
*/
|
|
305
383
|
declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
|
|
306
|
-
/**
|
|
307
|
-
* 隐藏姓名第一个字
|
|
308
|
-
* @param {string} name 姓名
|
|
309
|
-
* @deprecated 请使用 hideSurname
|
|
310
|
-
*/
|
|
311
|
-
declare const hideName: (name: UnDef<string>) => string;
|
|
312
384
|
/**
|
|
313
385
|
* 隐藏姓氏
|
|
314
386
|
* @param {string} name 姓名
|
|
387
|
+
* @returns {string} 隐藏后的姓名
|
|
388
|
+
* @example
|
|
389
|
+
* ```ts
|
|
390
|
+
* hideSurname('张三') // '*三'
|
|
391
|
+
* hideSurname('司马懿') // '*马懿'
|
|
392
|
+
* ```
|
|
315
393
|
*/
|
|
316
394
|
declare const hideSurname: (name: UnDef<string>) => string;
|
|
317
395
|
/**
|
|
318
396
|
* 隐藏名字
|
|
319
397
|
* @param {string} name 姓名
|
|
398
|
+
* @returns {string} 隐藏后的姓名
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* hideFirstName('张三') // '张*'
|
|
402
|
+
* hideFirstName('司马懿') // '司马*'
|
|
403
|
+
* ```
|
|
320
404
|
*/
|
|
321
405
|
declare const hideFirstName: (name: UnDef<string>) => string;
|
|
322
406
|
/**
|
|
323
407
|
* 隐藏邮箱
|
|
324
408
|
* @param {string} email 邮箱
|
|
409
|
+
* @returns {string} 隐藏后的邮箱
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* hideEmail('example@hotmail.com') // 'exam***@hotmail.com'
|
|
413
|
+
* ```
|
|
325
414
|
*/
|
|
326
415
|
declare const hideEmail: (email: UnDef<string>) => string;
|
|
327
416
|
/**
|
|
328
417
|
* 隐藏银行卡号
|
|
329
418
|
* @param {string} bankCard 银行卡号
|
|
419
|
+
* @returns {string} 隐藏后的银行卡号
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* hideBankCard('6222021001123456789') // '622202********6789'
|
|
423
|
+
* ```
|
|
330
424
|
*/
|
|
331
425
|
declare const hideBankCard: (bankCard: UnDef<string>) => string;
|
|
332
426
|
|
|
333
|
-
interface HostEnv {
|
|
334
|
-
/**
|
|
335
|
-
* 是否是浙里办
|
|
336
|
-
*/
|
|
337
|
-
readonly zlb: boolean
|
|
338
|
-
/**
|
|
339
|
-
* 是否是专有钉
|
|
340
|
-
*/
|
|
341
|
-
readonly zyd: boolean
|
|
342
|
-
/**
|
|
343
|
-
* 是否是浙政钉
|
|
344
|
-
*/
|
|
345
|
-
readonly zzd: boolean
|
|
346
|
-
/**
|
|
347
|
-
* 是否是钉钉/专有钉/浙政钉
|
|
348
|
-
*/
|
|
349
|
-
readonly dd: boolean
|
|
350
|
-
/**
|
|
351
|
-
* 是否是微信
|
|
352
|
-
*/
|
|
353
|
-
readonly wx: boolean
|
|
354
|
-
/**
|
|
355
|
-
* 是否是支付宝
|
|
356
|
-
*/
|
|
357
|
-
readonly zfb: boolean
|
|
358
|
-
/**
|
|
359
|
-
* 是否是小程序
|
|
360
|
-
*/
|
|
361
|
-
readonly mini: boolean
|
|
362
|
-
}
|
|
363
|
-
|
|
364
427
|
/**
|
|
365
428
|
* 判断是否是浏览器环境
|
|
366
429
|
*/
|
|
@@ -419,23 +482,42 @@ declare function setBaseAttachUrl(baseUrl: string): void;
|
|
|
419
482
|
declare function getBaseAttachUrl(): string;
|
|
420
483
|
|
|
421
484
|
/**
|
|
422
|
-
*
|
|
423
|
-
* @
|
|
424
|
-
* @param
|
|
485
|
+
* JSON 字符串转对象
|
|
486
|
+
* @template T - 解析数据类型
|
|
487
|
+
* @param {string} str - JSON字符串
|
|
488
|
+
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
489
|
+
* @returns {Nullable<T>} 解析后的对象
|
|
490
|
+
* @deprecated 请使用 `parseJSON`
|
|
491
|
+
*/
|
|
492
|
+
declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
493
|
+
/**
|
|
494
|
+
* JSON 字符串转对象
|
|
495
|
+
* @alias parseToJSON
|
|
496
|
+
* @template T - 解析数据类型
|
|
497
|
+
* @param {string} str - JSON字符串
|
|
498
|
+
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
499
|
+
* @returns {Nullable<T>} 解析后的对象
|
|
500
|
+
*/
|
|
501
|
+
declare function parseJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
502
|
+
/**
|
|
503
|
+
* 对象转 JSON 字符串
|
|
504
|
+
* @param {any} value - 对象
|
|
505
|
+
* @param {(this: any, key: string, value: any) => any} replacerFn - 替换函数
|
|
506
|
+
* @returns {string} JSON 字符串
|
|
425
507
|
*/
|
|
426
|
-
declare
|
|
508
|
+
declare function stringifyJSON(value: any, replacerFn?: (this: any, key: string, value: any) => any): string;
|
|
427
509
|
/**
|
|
428
510
|
* JSON.stringify() second param
|
|
429
|
-
* @param
|
|
511
|
+
* @param _key
|
|
430
512
|
* @param value
|
|
431
513
|
*/
|
|
432
|
-
declare
|
|
514
|
+
declare function replacer(_key: any, value: any): any;
|
|
433
515
|
/**
|
|
434
516
|
* JSON.parse() second param
|
|
435
|
-
* @param
|
|
517
|
+
* @param _key
|
|
436
518
|
* @param value
|
|
437
519
|
*/
|
|
438
|
-
declare
|
|
520
|
+
declare function reviver(_key: any, value: any): any;
|
|
439
521
|
/**
|
|
440
522
|
* 过滤obj中仅包括keys的部分
|
|
441
523
|
* @param {Record<string,any>} obj 对象
|
|
@@ -714,6 +796,13 @@ declare const isValidKey: (key: string | number | symbol, object: object) => key
|
|
|
714
796
|
*/
|
|
715
797
|
declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
|
|
716
798
|
|
|
799
|
+
declare const cnPhoneRE: RegExp;
|
|
800
|
+
declare const cnTelRE: RegExp;
|
|
801
|
+
declare const cnTelRE2: RegExp;
|
|
802
|
+
declare const cnUSCIRE: RegExp;
|
|
803
|
+
declare const cnIdCard15Re: RegExp;
|
|
804
|
+
declare const cnIdCard18Re: RegExp;
|
|
805
|
+
declare const emailRE: RegExp;
|
|
717
806
|
/**
|
|
718
807
|
* 是否是[统一社会信用代码](https://zh.wikipedia.org/zh-cn/%E7%BB%9F%E4%B8%80%E7%A4%BE%E4%BC%9A%E4%BF%A1%E7%94%A8%E4%BB%A3%E7%A0%81)
|
|
719
808
|
* @example
|
|
@@ -793,4 +882,5 @@ declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
|
793
882
|
*/
|
|
794
883
|
declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
795
884
|
|
|
796
|
-
export {
|
|
885
|
+
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, cnIdCard15Re, cnIdCard18Re, cnPhoneRE, cnTelRE, cnTelRE2, cnUSCIRE, currencyFmt, dateDuration, dateFmt, emailRE, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUSCI, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseJSON, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, stringifyJSON, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
886
|
+
export type { Dict, HostEnv, MaybeArray, NullOrUndefinable, Nullable, Numeric, PageReq, PageRes, PageResData, PartialBy, Res, UnDef, Undefinable, VK };
|