@jhqn/utils-core 0.0.1-beta.26 → 0.0.1-beta.27
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 +49 -5
- package/dist/index.d.cts +111 -6
- package/dist/index.d.mts +111 -6
- package/dist/index.d.ts +111 -6
- package/dist/index.mjs +29 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -71,7 +71,32 @@ const jClear = console.clear.bind(console);
|
|
|
71
71
|
|
|
72
72
|
const cnPhoneRE = /^1[3-9]\d{9}$/;
|
|
73
73
|
const cnTelRE = /^0\d{9,11}$/;
|
|
74
|
-
const
|
|
74
|
+
const getVariableType = (val) => {
|
|
75
|
+
const value = Object.prototype.toString.call(val);
|
|
76
|
+
const result = value.match(/\[object (\S*)\]/)?.[1];
|
|
77
|
+
return result?.toLocaleLowerCase();
|
|
78
|
+
};
|
|
79
|
+
const isNumber = (val) => getVariableType(val) === "number";
|
|
80
|
+
const isString = (val) => getVariableType(val) === "string";
|
|
81
|
+
const isBoolean = (val) => getVariableType(val) === "boolean";
|
|
82
|
+
const isNull = (val) => getVariableType(val) === "null";
|
|
83
|
+
const isUndefined = (val) => getVariableType(val) === "undefined";
|
|
84
|
+
const isSymbol = (val) => getVariableType(val) === "symbol";
|
|
85
|
+
const isObject = (val) => getVariableType(val) === "object";
|
|
86
|
+
const isArray = (val) => getVariableType(val) === "array";
|
|
87
|
+
const isFunction = (val) => getVariableType(val) === "function";
|
|
88
|
+
const isDate = (val) => getVariableType(val) === "date";
|
|
89
|
+
const isRegExp = (val) => getVariableType(val) === "regexp";
|
|
90
|
+
const isPromise = (val) => getVariableType(val) === "promise";
|
|
91
|
+
const isSet = (val) => getVariableType(val) === "set";
|
|
92
|
+
const isMap = (val) => getVariableType(val) === "map";
|
|
93
|
+
const isWeakSet = (val) => getVariableType(val) === "weakset";
|
|
94
|
+
const isWeakMap = (val) => getVariableType(val) === "weakmap";
|
|
95
|
+
const isFile = (val) => getVariableType(val) === "file";
|
|
96
|
+
const isBlob = (val) => getVariableType(val) === "blob";
|
|
97
|
+
const isURL = (val) => getVariableType(val) === "url";
|
|
98
|
+
const isError = (val) => getVariableType(val) === "error";
|
|
99
|
+
const isDef = (val) => !isNull(val) && !isUndefined(val);
|
|
75
100
|
const isNumeric = (val) => {
|
|
76
101
|
if (isDef(val))
|
|
77
102
|
return typeof val === "number" || /^\d+(?:\.\d+)?$/.test(val);
|
|
@@ -391,15 +416,13 @@ const toThousands = (num) => {
|
|
|
391
416
|
return `${integer}.${arr[1]}`;
|
|
392
417
|
return integer;
|
|
393
418
|
};
|
|
394
|
-
const currencyFmt = (currency,
|
|
419
|
+
const currencyFmt = (currency, maximumFractionDigits = 2) => {
|
|
395
420
|
if (!isDef(currency))
|
|
396
421
|
return "";
|
|
397
422
|
const num = Number(currency);
|
|
398
423
|
if (Number.isNaN(num))
|
|
399
424
|
return "";
|
|
400
|
-
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits
|
|
401
|
-
num
|
|
402
|
-
);
|
|
425
|
+
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits }).format(num);
|
|
403
426
|
};
|
|
404
427
|
|
|
405
428
|
const resUrl = (url) => {
|
|
@@ -463,6 +486,7 @@ exports.filterObj = filterObj;
|
|
|
463
486
|
exports.fixiOSInputAutoZoomIn = fixiOSInputAutoZoomIn;
|
|
464
487
|
exports.getBaseAttachUrl = getBaseAttachUrl;
|
|
465
488
|
exports.getHostEnv = getHostEnv;
|
|
489
|
+
exports.getVariableType = getVariableType;
|
|
466
490
|
exports.hideBankCard = hideBankCard;
|
|
467
491
|
exports.hideCardNo = hideCardNo;
|
|
468
492
|
exports.hideEmail = hideEmail;
|
|
@@ -476,20 +500,40 @@ exports.hideTail = hideTail;
|
|
|
476
500
|
exports.hideThird = hideThird;
|
|
477
501
|
exports.inBrowser = inBrowser;
|
|
478
502
|
exports.isArrStr = isArrStr;
|
|
503
|
+
exports.isArray = isArray;
|
|
504
|
+
exports.isBlob = isBlob;
|
|
505
|
+
exports.isBoolean = isBoolean;
|
|
506
|
+
exports.isDate = isDate;
|
|
479
507
|
exports.isDef = isDef;
|
|
480
508
|
exports.isEmail = isEmail;
|
|
481
509
|
exports.isEmpty = isEmpty;
|
|
510
|
+
exports.isError = isError;
|
|
511
|
+
exports.isFile = isFile;
|
|
512
|
+
exports.isFunction = isFunction;
|
|
482
513
|
exports.isIdCard = isIdCard;
|
|
483
514
|
exports.isJSONStr = isJSONStr;
|
|
515
|
+
exports.isMap = isMap;
|
|
516
|
+
exports.isNull = isNull;
|
|
517
|
+
exports.isNumber = isNumber;
|
|
484
518
|
exports.isNumeric = isNumeric;
|
|
519
|
+
exports.isObject = isObject;
|
|
485
520
|
exports.isPhone = isPhone;
|
|
521
|
+
exports.isPromise = isPromise;
|
|
522
|
+
exports.isRegExp = isRegExp;
|
|
523
|
+
exports.isSet = isSet;
|
|
524
|
+
exports.isString = isString;
|
|
525
|
+
exports.isSymbol = isSymbol;
|
|
486
526
|
exports.isTel = isTel;
|
|
527
|
+
exports.isURL = isURL;
|
|
528
|
+
exports.isUndefined = isUndefined;
|
|
487
529
|
exports.isValidArrRes = isValidArrRes;
|
|
488
530
|
exports.isValidFileType = isValidFileType;
|
|
489
531
|
exports.isValidKey = isValidKey;
|
|
490
532
|
exports.isValidPageRes = isValidPageRes;
|
|
491
533
|
exports.isValidRes = isValidRes;
|
|
492
534
|
exports.isValidResCode = isValidResCode;
|
|
535
|
+
exports.isWeakMap = isWeakMap;
|
|
536
|
+
exports.isWeakSet = isWeakSet;
|
|
493
537
|
exports.jClear = jClear;
|
|
494
538
|
exports.jDebug = jDebug;
|
|
495
539
|
exports.jError = jError;
|
package/dist/index.d.cts
CHANGED
|
@@ -558,10 +558,10 @@ declare function getBaseAttachUrl(): string;
|
|
|
558
558
|
declare const toThousands: (num: number) => string | undefined;
|
|
559
559
|
/**
|
|
560
560
|
* 货币格式化
|
|
561
|
-
* @param currency
|
|
562
|
-
* @param
|
|
561
|
+
* @param {number | string | bigint} currency - 金额
|
|
562
|
+
* @param {number} [maximumFractionDigits] - 小数位数
|
|
563
563
|
*/
|
|
564
|
-
declare const currencyFmt: (currency: UnDef<Numeric | bigint>,
|
|
564
|
+
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
565
565
|
|
|
566
566
|
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
567
567
|
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
@@ -654,8 +654,113 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
|
654
654
|
}[];
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
|
-
*
|
|
658
|
-
* @param val
|
|
657
|
+
* 检测变量类型
|
|
658
|
+
* @param {any} val 检测的目标
|
|
659
|
+
*/
|
|
660
|
+
declare const getVariableType: (val: any) => string | undefined;
|
|
661
|
+
/**
|
|
662
|
+
* 是否是数字
|
|
663
|
+
* @param {any} val 检测的目标
|
|
664
|
+
*/
|
|
665
|
+
declare const isNumber: (val: any) => val is number;
|
|
666
|
+
/**
|
|
667
|
+
* 是否是字符串
|
|
668
|
+
* @param {any} val 检测的目标
|
|
669
|
+
*/
|
|
670
|
+
declare const isString: (val: any) => val is string;
|
|
671
|
+
/**
|
|
672
|
+
* 是否是布尔值
|
|
673
|
+
* @param {any} val 检测的目标
|
|
674
|
+
*/
|
|
675
|
+
declare const isBoolean: (val: any) => val is boolean;
|
|
676
|
+
/**
|
|
677
|
+
* 是否是null
|
|
678
|
+
* @param {any} val 检测的目标
|
|
679
|
+
*/
|
|
680
|
+
declare const isNull: (val: any) => val is null;
|
|
681
|
+
/**
|
|
682
|
+
* 是否是undefined
|
|
683
|
+
* @param {any} val 检测的目标
|
|
684
|
+
*/
|
|
685
|
+
declare const isUndefined: (val: any) => val is undefined;
|
|
686
|
+
/**
|
|
687
|
+
* 是否是symbol
|
|
688
|
+
* @param {any} val 检测的目标
|
|
689
|
+
*/
|
|
690
|
+
declare const isSymbol: (val: any) => val is symbol;
|
|
691
|
+
/**
|
|
692
|
+
* 是否是对象
|
|
693
|
+
* @param {any} val 检测的目标
|
|
694
|
+
*/
|
|
695
|
+
declare const isObject: (val: any) => val is Record<any, any>;
|
|
696
|
+
/**
|
|
697
|
+
* 是否是数组
|
|
698
|
+
* @param {any} val 检测的目标
|
|
699
|
+
*/
|
|
700
|
+
declare const isArray: (val: any) => val is any[];
|
|
701
|
+
/**
|
|
702
|
+
* 是否是函数
|
|
703
|
+
* @param {any} val 检测的目标
|
|
704
|
+
*/
|
|
705
|
+
declare const isFunction: (val: any) => val is Function;
|
|
706
|
+
/**
|
|
707
|
+
* 是否是日期
|
|
708
|
+
* @param {any} val 检测的目标
|
|
709
|
+
*/
|
|
710
|
+
declare const isDate: (val: any) => val is Date;
|
|
711
|
+
/**
|
|
712
|
+
* 是否是正则
|
|
713
|
+
* @param {any} val 检测的目标
|
|
714
|
+
*/
|
|
715
|
+
declare const isRegExp: (val: any) => val is RegExp;
|
|
716
|
+
/**
|
|
717
|
+
* 是否是期望(Promise)
|
|
718
|
+
* @param {any} val 检测的目标
|
|
719
|
+
*/
|
|
720
|
+
declare const isPromise: (val: any) => val is Promise<any>;
|
|
721
|
+
/**
|
|
722
|
+
* 是否是集合(Set)
|
|
723
|
+
* @param {any} val 检测的目标
|
|
724
|
+
*/
|
|
725
|
+
declare const isSet: (val: any) => val is Set<any>;
|
|
726
|
+
/**
|
|
727
|
+
* 是否是映射(Map)
|
|
728
|
+
* @param {any} val 检测的目标
|
|
729
|
+
*/
|
|
730
|
+
declare const isMap: (val: any) => val is Map<any, any>;
|
|
731
|
+
/**
|
|
732
|
+
* 是否是弱集合(WeakSet)
|
|
733
|
+
* @param {any} val 检测的目标
|
|
734
|
+
*/
|
|
735
|
+
declare const isWeakSet: (val: any) => val is WeakSet<any>;
|
|
736
|
+
/**
|
|
737
|
+
* 是否是弱映射(WeakMap)
|
|
738
|
+
* @param {any} val 检测的目标
|
|
739
|
+
*/
|
|
740
|
+
declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
|
|
741
|
+
/**
|
|
742
|
+
* 是否是File
|
|
743
|
+
* @param {any} val 检测的目标
|
|
744
|
+
*/
|
|
745
|
+
declare const isFile: (val: any) => val is File;
|
|
746
|
+
/**
|
|
747
|
+
* 是否是Blob
|
|
748
|
+
* @param {any} val 检测的目标
|
|
749
|
+
*/
|
|
750
|
+
declare const isBlob: (val: any) => val is Blob;
|
|
751
|
+
/**
|
|
752
|
+
* 是否是URL
|
|
753
|
+
* @param {any} val 检测的目标
|
|
754
|
+
*/
|
|
755
|
+
declare const isURL: (val: any) => val is URL;
|
|
756
|
+
/**
|
|
757
|
+
* 是否是错误(Error)
|
|
758
|
+
* @param {any} val 检测的目标
|
|
759
|
+
*/
|
|
760
|
+
declare const isError: (val: any) => val is Error;
|
|
761
|
+
/**
|
|
762
|
+
* 是否既不是 null 也不是 undefined
|
|
763
|
+
* @param {any} val 检测的目标
|
|
659
764
|
*/
|
|
660
765
|
declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
661
766
|
/**
|
|
@@ -754,4 +859,4 @@ declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
|
754
859
|
*/
|
|
755
860
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
756
861
|
|
|
757
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isDef, isEmail, isEmpty, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
862
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.d.mts
CHANGED
|
@@ -558,10 +558,10 @@ declare function getBaseAttachUrl(): string;
|
|
|
558
558
|
declare const toThousands: (num: number) => string | undefined;
|
|
559
559
|
/**
|
|
560
560
|
* 货币格式化
|
|
561
|
-
* @param currency
|
|
562
|
-
* @param
|
|
561
|
+
* @param {number | string | bigint} currency - 金额
|
|
562
|
+
* @param {number} [maximumFractionDigits] - 小数位数
|
|
563
563
|
*/
|
|
564
|
-
declare const currencyFmt: (currency: UnDef<Numeric | bigint>,
|
|
564
|
+
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
565
565
|
|
|
566
566
|
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
567
567
|
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
@@ -654,8 +654,113 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
|
654
654
|
}[];
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
|
-
*
|
|
658
|
-
* @param val
|
|
657
|
+
* 检测变量类型
|
|
658
|
+
* @param {any} val 检测的目标
|
|
659
|
+
*/
|
|
660
|
+
declare const getVariableType: (val: any) => string | undefined;
|
|
661
|
+
/**
|
|
662
|
+
* 是否是数字
|
|
663
|
+
* @param {any} val 检测的目标
|
|
664
|
+
*/
|
|
665
|
+
declare const isNumber: (val: any) => val is number;
|
|
666
|
+
/**
|
|
667
|
+
* 是否是字符串
|
|
668
|
+
* @param {any} val 检测的目标
|
|
669
|
+
*/
|
|
670
|
+
declare const isString: (val: any) => val is string;
|
|
671
|
+
/**
|
|
672
|
+
* 是否是布尔值
|
|
673
|
+
* @param {any} val 检测的目标
|
|
674
|
+
*/
|
|
675
|
+
declare const isBoolean: (val: any) => val is boolean;
|
|
676
|
+
/**
|
|
677
|
+
* 是否是null
|
|
678
|
+
* @param {any} val 检测的目标
|
|
679
|
+
*/
|
|
680
|
+
declare const isNull: (val: any) => val is null;
|
|
681
|
+
/**
|
|
682
|
+
* 是否是undefined
|
|
683
|
+
* @param {any} val 检测的目标
|
|
684
|
+
*/
|
|
685
|
+
declare const isUndefined: (val: any) => val is undefined;
|
|
686
|
+
/**
|
|
687
|
+
* 是否是symbol
|
|
688
|
+
* @param {any} val 检测的目标
|
|
689
|
+
*/
|
|
690
|
+
declare const isSymbol: (val: any) => val is symbol;
|
|
691
|
+
/**
|
|
692
|
+
* 是否是对象
|
|
693
|
+
* @param {any} val 检测的目标
|
|
694
|
+
*/
|
|
695
|
+
declare const isObject: (val: any) => val is Record<any, any>;
|
|
696
|
+
/**
|
|
697
|
+
* 是否是数组
|
|
698
|
+
* @param {any} val 检测的目标
|
|
699
|
+
*/
|
|
700
|
+
declare const isArray: (val: any) => val is any[];
|
|
701
|
+
/**
|
|
702
|
+
* 是否是函数
|
|
703
|
+
* @param {any} val 检测的目标
|
|
704
|
+
*/
|
|
705
|
+
declare const isFunction: (val: any) => val is Function;
|
|
706
|
+
/**
|
|
707
|
+
* 是否是日期
|
|
708
|
+
* @param {any} val 检测的目标
|
|
709
|
+
*/
|
|
710
|
+
declare const isDate: (val: any) => val is Date;
|
|
711
|
+
/**
|
|
712
|
+
* 是否是正则
|
|
713
|
+
* @param {any} val 检测的目标
|
|
714
|
+
*/
|
|
715
|
+
declare const isRegExp: (val: any) => val is RegExp;
|
|
716
|
+
/**
|
|
717
|
+
* 是否是期望(Promise)
|
|
718
|
+
* @param {any} val 检测的目标
|
|
719
|
+
*/
|
|
720
|
+
declare const isPromise: (val: any) => val is Promise<any>;
|
|
721
|
+
/**
|
|
722
|
+
* 是否是集合(Set)
|
|
723
|
+
* @param {any} val 检测的目标
|
|
724
|
+
*/
|
|
725
|
+
declare const isSet: (val: any) => val is Set<any>;
|
|
726
|
+
/**
|
|
727
|
+
* 是否是映射(Map)
|
|
728
|
+
* @param {any} val 检测的目标
|
|
729
|
+
*/
|
|
730
|
+
declare const isMap: (val: any) => val is Map<any, any>;
|
|
731
|
+
/**
|
|
732
|
+
* 是否是弱集合(WeakSet)
|
|
733
|
+
* @param {any} val 检测的目标
|
|
734
|
+
*/
|
|
735
|
+
declare const isWeakSet: (val: any) => val is WeakSet<any>;
|
|
736
|
+
/**
|
|
737
|
+
* 是否是弱映射(WeakMap)
|
|
738
|
+
* @param {any} val 检测的目标
|
|
739
|
+
*/
|
|
740
|
+
declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
|
|
741
|
+
/**
|
|
742
|
+
* 是否是File
|
|
743
|
+
* @param {any} val 检测的目标
|
|
744
|
+
*/
|
|
745
|
+
declare const isFile: (val: any) => val is File;
|
|
746
|
+
/**
|
|
747
|
+
* 是否是Blob
|
|
748
|
+
* @param {any} val 检测的目标
|
|
749
|
+
*/
|
|
750
|
+
declare const isBlob: (val: any) => val is Blob;
|
|
751
|
+
/**
|
|
752
|
+
* 是否是URL
|
|
753
|
+
* @param {any} val 检测的目标
|
|
754
|
+
*/
|
|
755
|
+
declare const isURL: (val: any) => val is URL;
|
|
756
|
+
/**
|
|
757
|
+
* 是否是错误(Error)
|
|
758
|
+
* @param {any} val 检测的目标
|
|
759
|
+
*/
|
|
760
|
+
declare const isError: (val: any) => val is Error;
|
|
761
|
+
/**
|
|
762
|
+
* 是否既不是 null 也不是 undefined
|
|
763
|
+
* @param {any} val 检测的目标
|
|
659
764
|
*/
|
|
660
765
|
declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
661
766
|
/**
|
|
@@ -754,4 +859,4 @@ declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
|
754
859
|
*/
|
|
755
860
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
756
861
|
|
|
757
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isDef, isEmail, isEmpty, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
862
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.d.ts
CHANGED
|
@@ -558,10 +558,10 @@ declare function getBaseAttachUrl(): string;
|
|
|
558
558
|
declare const toThousands: (num: number) => string | undefined;
|
|
559
559
|
/**
|
|
560
560
|
* 货币格式化
|
|
561
|
-
* @param currency
|
|
562
|
-
* @param
|
|
561
|
+
* @param {number | string | bigint} currency - 金额
|
|
562
|
+
* @param {number} [maximumFractionDigits] - 小数位数
|
|
563
563
|
*/
|
|
564
|
-
declare const currencyFmt: (currency: UnDef<Numeric | bigint>,
|
|
564
|
+
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
565
565
|
|
|
566
566
|
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
567
567
|
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
@@ -654,8 +654,113 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
|
654
654
|
}[];
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
|
-
*
|
|
658
|
-
* @param val
|
|
657
|
+
* 检测变量类型
|
|
658
|
+
* @param {any} val 检测的目标
|
|
659
|
+
*/
|
|
660
|
+
declare const getVariableType: (val: any) => string | undefined;
|
|
661
|
+
/**
|
|
662
|
+
* 是否是数字
|
|
663
|
+
* @param {any} val 检测的目标
|
|
664
|
+
*/
|
|
665
|
+
declare const isNumber: (val: any) => val is number;
|
|
666
|
+
/**
|
|
667
|
+
* 是否是字符串
|
|
668
|
+
* @param {any} val 检测的目标
|
|
669
|
+
*/
|
|
670
|
+
declare const isString: (val: any) => val is string;
|
|
671
|
+
/**
|
|
672
|
+
* 是否是布尔值
|
|
673
|
+
* @param {any} val 检测的目标
|
|
674
|
+
*/
|
|
675
|
+
declare const isBoolean: (val: any) => val is boolean;
|
|
676
|
+
/**
|
|
677
|
+
* 是否是null
|
|
678
|
+
* @param {any} val 检测的目标
|
|
679
|
+
*/
|
|
680
|
+
declare const isNull: (val: any) => val is null;
|
|
681
|
+
/**
|
|
682
|
+
* 是否是undefined
|
|
683
|
+
* @param {any} val 检测的目标
|
|
684
|
+
*/
|
|
685
|
+
declare const isUndefined: (val: any) => val is undefined;
|
|
686
|
+
/**
|
|
687
|
+
* 是否是symbol
|
|
688
|
+
* @param {any} val 检测的目标
|
|
689
|
+
*/
|
|
690
|
+
declare const isSymbol: (val: any) => val is symbol;
|
|
691
|
+
/**
|
|
692
|
+
* 是否是对象
|
|
693
|
+
* @param {any} val 检测的目标
|
|
694
|
+
*/
|
|
695
|
+
declare const isObject: (val: any) => val is Record<any, any>;
|
|
696
|
+
/**
|
|
697
|
+
* 是否是数组
|
|
698
|
+
* @param {any} val 检测的目标
|
|
699
|
+
*/
|
|
700
|
+
declare const isArray: (val: any) => val is any[];
|
|
701
|
+
/**
|
|
702
|
+
* 是否是函数
|
|
703
|
+
* @param {any} val 检测的目标
|
|
704
|
+
*/
|
|
705
|
+
declare const isFunction: (val: any) => val is Function;
|
|
706
|
+
/**
|
|
707
|
+
* 是否是日期
|
|
708
|
+
* @param {any} val 检测的目标
|
|
709
|
+
*/
|
|
710
|
+
declare const isDate: (val: any) => val is Date;
|
|
711
|
+
/**
|
|
712
|
+
* 是否是正则
|
|
713
|
+
* @param {any} val 检测的目标
|
|
714
|
+
*/
|
|
715
|
+
declare const isRegExp: (val: any) => val is RegExp;
|
|
716
|
+
/**
|
|
717
|
+
* 是否是期望(Promise)
|
|
718
|
+
* @param {any} val 检测的目标
|
|
719
|
+
*/
|
|
720
|
+
declare const isPromise: (val: any) => val is Promise<any>;
|
|
721
|
+
/**
|
|
722
|
+
* 是否是集合(Set)
|
|
723
|
+
* @param {any} val 检测的目标
|
|
724
|
+
*/
|
|
725
|
+
declare const isSet: (val: any) => val is Set<any>;
|
|
726
|
+
/**
|
|
727
|
+
* 是否是映射(Map)
|
|
728
|
+
* @param {any} val 检测的目标
|
|
729
|
+
*/
|
|
730
|
+
declare const isMap: (val: any) => val is Map<any, any>;
|
|
731
|
+
/**
|
|
732
|
+
* 是否是弱集合(WeakSet)
|
|
733
|
+
* @param {any} val 检测的目标
|
|
734
|
+
*/
|
|
735
|
+
declare const isWeakSet: (val: any) => val is WeakSet<any>;
|
|
736
|
+
/**
|
|
737
|
+
* 是否是弱映射(WeakMap)
|
|
738
|
+
* @param {any} val 检测的目标
|
|
739
|
+
*/
|
|
740
|
+
declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
|
|
741
|
+
/**
|
|
742
|
+
* 是否是File
|
|
743
|
+
* @param {any} val 检测的目标
|
|
744
|
+
*/
|
|
745
|
+
declare const isFile: (val: any) => val is File;
|
|
746
|
+
/**
|
|
747
|
+
* 是否是Blob
|
|
748
|
+
* @param {any} val 检测的目标
|
|
749
|
+
*/
|
|
750
|
+
declare const isBlob: (val: any) => val is Blob;
|
|
751
|
+
/**
|
|
752
|
+
* 是否是URL
|
|
753
|
+
* @param {any} val 检测的目标
|
|
754
|
+
*/
|
|
755
|
+
declare const isURL: (val: any) => val is URL;
|
|
756
|
+
/**
|
|
757
|
+
* 是否是错误(Error)
|
|
758
|
+
* @param {any} val 检测的目标
|
|
759
|
+
*/
|
|
760
|
+
declare const isError: (val: any) => val is Error;
|
|
761
|
+
/**
|
|
762
|
+
* 是否既不是 null 也不是 undefined
|
|
763
|
+
* @param {any} val 检测的目标
|
|
659
764
|
*/
|
|
660
765
|
declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
661
766
|
/**
|
|
@@ -754,4 +859,4 @@ declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
|
754
859
|
*/
|
|
755
860
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
756
861
|
|
|
757
|
-
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isDef, isEmail, isEmpty, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
862
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/dist/index.mjs
CHANGED
|
@@ -60,7 +60,32 @@ const jClear = console.clear.bind(console);
|
|
|
60
60
|
|
|
61
61
|
const cnPhoneRE = /^1[3-9]\d{9}$/;
|
|
62
62
|
const cnTelRE = /^0\d{9,11}$/;
|
|
63
|
-
const
|
|
63
|
+
const getVariableType = (val) => {
|
|
64
|
+
const value = Object.prototype.toString.call(val);
|
|
65
|
+
const result = value.match(/\[object (\S*)\]/)?.[1];
|
|
66
|
+
return result?.toLocaleLowerCase();
|
|
67
|
+
};
|
|
68
|
+
const isNumber = (val) => getVariableType(val) === "number";
|
|
69
|
+
const isString = (val) => getVariableType(val) === "string";
|
|
70
|
+
const isBoolean = (val) => getVariableType(val) === "boolean";
|
|
71
|
+
const isNull = (val) => getVariableType(val) === "null";
|
|
72
|
+
const isUndefined = (val) => getVariableType(val) === "undefined";
|
|
73
|
+
const isSymbol = (val) => getVariableType(val) === "symbol";
|
|
74
|
+
const isObject = (val) => getVariableType(val) === "object";
|
|
75
|
+
const isArray = (val) => getVariableType(val) === "array";
|
|
76
|
+
const isFunction = (val) => getVariableType(val) === "function";
|
|
77
|
+
const isDate = (val) => getVariableType(val) === "date";
|
|
78
|
+
const isRegExp = (val) => getVariableType(val) === "regexp";
|
|
79
|
+
const isPromise = (val) => getVariableType(val) === "promise";
|
|
80
|
+
const isSet = (val) => getVariableType(val) === "set";
|
|
81
|
+
const isMap = (val) => getVariableType(val) === "map";
|
|
82
|
+
const isWeakSet = (val) => getVariableType(val) === "weakset";
|
|
83
|
+
const isWeakMap = (val) => getVariableType(val) === "weakmap";
|
|
84
|
+
const isFile = (val) => getVariableType(val) === "file";
|
|
85
|
+
const isBlob = (val) => getVariableType(val) === "blob";
|
|
86
|
+
const isURL = (val) => getVariableType(val) === "url";
|
|
87
|
+
const isError = (val) => getVariableType(val) === "error";
|
|
88
|
+
const isDef = (val) => !isNull(val) && !isUndefined(val);
|
|
64
89
|
const isNumeric = (val) => {
|
|
65
90
|
if (isDef(val))
|
|
66
91
|
return typeof val === "number" || /^\d+(?:\.\d+)?$/.test(val);
|
|
@@ -380,15 +405,13 @@ const toThousands = (num) => {
|
|
|
380
405
|
return `${integer}.${arr[1]}`;
|
|
381
406
|
return integer;
|
|
382
407
|
};
|
|
383
|
-
const currencyFmt = (currency,
|
|
408
|
+
const currencyFmt = (currency, maximumFractionDigits = 2) => {
|
|
384
409
|
if (!isDef(currency))
|
|
385
410
|
return "";
|
|
386
411
|
const num = Number(currency);
|
|
387
412
|
if (Number.isNaN(num))
|
|
388
413
|
return "";
|
|
389
|
-
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits
|
|
390
|
-
num
|
|
391
|
-
);
|
|
414
|
+
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits }).format(num);
|
|
392
415
|
};
|
|
393
416
|
|
|
394
417
|
const resUrl = (url) => {
|
|
@@ -438,4 +461,4 @@ const attachFmt = (data) => {
|
|
|
438
461
|
return attachList.map(recoverFile);
|
|
439
462
|
};
|
|
440
463
|
|
|
441
|
-
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isDef, isEmail, isEmpty, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
|
464
|
+
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jhqn/utils-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.27",
|
|
5
5
|
"author": "jade-gjz <jiangang.zhang@jaderd.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"dayjs": "^1.11.
|
|
40
|
+
"dayjs": "^1.11.10",
|
|
41
41
|
"detect-browser": "^5.3.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|