util-helpers 4.17.2 → 4.18.0
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/README.md +1 -1
- package/dist/util-helpers.js +305 -184
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +4 -0
- package/esm/calculateCursorPosition.js +3 -3
- package/esm/divide.js +2 -2
- package/esm/download.js +1 -2
- package/esm/filterTree.js +1 -1
- package/esm/findTreeNode.js +1 -1
- package/esm/findTreeNodes.js +1 -1
- package/esm/findTreeSelect.js +1 -1
- package/esm/formatBankCard.js +2 -2
- package/esm/formatMobile.js +2 -2
- package/esm/formatMoney.js +3 -3
- package/esm/index.js +6 -1
- package/esm/isBankCard.js +2 -2
- package/esm/isBusinessLicense.js +2 -2
- package/esm/isChinese.js +2 -2
- package/esm/isEmail.js +2 -2
- package/esm/isHMCard.js +2 -2
- package/esm/isIPv4.js +2 -2
- package/esm/isIPv6.js +2 -2
- package/esm/isIdCard.js +2 -2
- package/esm/isMobile.js +2 -2
- package/esm/isPassport.js +2 -2
- package/esm/isPostcode.js +2 -2
- package/esm/isPromiseLike.js +3 -1
- package/esm/isQQ.js +2 -2
- package/esm/isSocialCreditCode.js +2 -2
- package/esm/isSwiftCode.js +2 -2
- package/esm/isTWCard.js +2 -2
- package/esm/isTelephone.js +2 -2
- package/esm/isUrl.js +2 -2
- package/esm/isValidNumber.js +1 -1
- package/esm/isVehicle.js +2 -2
- package/esm/isWX.js +2 -2
- package/esm/listToTree.js +1 -1
- package/esm/minus.js +2 -2
- package/esm/normalizeString.js +2 -6
- package/esm/padZero.js +2 -2
- package/esm/plus.js +2 -2
- package/esm/replaceChar.js +2 -2
- package/esm/round.js +2 -2
- package/esm/strlen.js +2 -2
- package/esm/times.js +2 -2
- package/esm/transformFieldNames.js +1 -1
- package/esm/treeToList.js +1 -1
- package/esm/utils/config.js +1 -2
- package/esm/utils/math.util.js +1 -4
- package/esm/waitTime.js +3 -3
- package/lib/VERSION.js +6 -0
- package/lib/calculateCursorPosition.js +3 -3
- package/lib/divide.js +2 -2
- package/lib/download.js +4 -5
- package/lib/filterTree.js +3 -3
- package/lib/findTreeNode.js +2 -2
- package/lib/findTreeNodes.js +2 -2
- package/lib/findTreeSelect.js +2 -2
- package/lib/formatBankCard.js +2 -2
- package/lib/formatMobile.js +2 -2
- package/lib/formatMoney.js +3 -3
- package/lib/index.js +3 -5
- package/lib/isBankCard.js +2 -2
- package/lib/isBusinessLicense.js +2 -2
- package/lib/isChinese.js +2 -2
- package/lib/isEmail.js +2 -2
- package/lib/isHMCard.js +2 -2
- package/lib/isIPv4.js +2 -2
- package/lib/isIPv6.js +2 -2
- package/lib/isIdCard.js +2 -2
- package/lib/isMobile.js +2 -2
- package/lib/isPassport.js +2 -2
- package/lib/isPostcode.js +2 -2
- package/lib/isPromiseLike.js +3 -1
- package/lib/isQQ.js +2 -2
- package/lib/isSocialCreditCode.js +2 -2
- package/lib/isSwiftCode.js +2 -2
- package/lib/isTWCard.js +2 -2
- package/lib/isTelephone.js +2 -2
- package/lib/isUrl.js +2 -2
- package/lib/isValidNumber.js +2 -2
- package/lib/isVehicle.js +2 -2
- package/lib/isWX.js +2 -2
- package/lib/listToTree.js +2 -2
- package/lib/minus.js +2 -2
- package/lib/normalizeString.js +2 -6
- package/lib/padZero.js +2 -2
- package/lib/plus.js +2 -2
- package/lib/replaceChar.js +2 -2
- package/lib/round.js +2 -2
- package/lib/strlen.js +2 -2
- package/lib/times.js +2 -2
- package/lib/transformFieldNames.js +2 -2
- package/lib/treeToList.js +2 -2
- package/lib/utils/config.js +0 -1
- package/lib/utils/math.util.js +5 -8
- package/lib/waitTime.js +3 -3
- package/package.json +22 -23
- package/types/VERSION.d.ts +8 -0
- package/types/ajax.d.ts +1 -1
- package/types/blobToDataURL.d.ts +1 -1
- package/types/calculateCursorPosition.d.ts +1 -1
- package/types/download.d.ts +7 -3
- package/types/filterTree.d.ts +3 -1
- package/types/formatBankCard.d.ts +1 -1
- package/types/formatMobile.d.ts +1 -1
- package/types/index.d.ts +7 -1
- package/types/isIdCard.d.ts +3 -1
- package/types/isPromiseLike.d.ts +1 -0
- package/types/normalizeString.d.ts +2 -1
- package/types/numberToChinese.d.ts +1 -1
- package/types/padZero.d.ts +1 -1
- package/types/replaceChar.d.ts +4 -1
- package/types/setDataURLPrefix.d.ts +2 -1
- package/types/treeToList.d.ts +3 -6
- package/types/utils/config.d.ts +1 -2
- package/types/waitTime.d.ts +2 -1
- package/esm/utils/constants.js +0 -4
- package/esm/utils/convertToString.js +0 -7
- package/esm/utils/type/isBlob.js +0 -7
- package/esm/utils/type/isNaN.js +0 -7
- package/esm/utils/type/isNil.js +0 -8
- package/esm/utils/type/isNull.js +0 -5
- package/esm/utils/type/isNumber.js +0 -7
- package/esm/utils/type/isObject.js +0 -6
- package/esm/utils/type/isString.js +0 -7
- package/esm/utils/type/isSymbol.js +0 -7
- package/esm/utils/type/isType.js +0 -6
- package/esm/utils/type/isUndefined.js +0 -5
- package/lib/utils/constants.js +0 -4
- package/lib/utils/convertToString.js +0 -9
- package/lib/utils/type/isBlob.js +0 -9
- package/lib/utils/type/isNaN.js +0 -9
- package/lib/utils/type/isNil.js +0 -10
- package/lib/utils/type/isNull.js +0 -7
- package/lib/utils/type/isNumber.js +0 -9
- package/lib/utils/type/isObject.js +0 -8
- package/lib/utils/type/isString.js +0 -9
- package/lib/utils/type/isSymbol.js +0 -9
- package/lib/utils/type/isType.js +0 -8
- package/lib/utils/type/isUndefined.js +0 -7
- package/types/utils/constants.d.ts +0 -2
- package/types/utils/convertToString.d.ts +0 -8
- package/types/utils/type/index.d.ts +0 -28
- package/types/utils/type/isArguments.d.ts +0 -18
- package/types/utils/type/isArray.d.ts +0 -18
- package/types/utils/type/isArrayBuffer.d.ts +0 -21
- package/types/utils/type/isBlob.d.ts +0 -23
- package/types/utils/type/isBoolean.d.ts +0 -18
- package/types/utils/type/isDate.d.ts +0 -18
- package/types/utils/type/isError.d.ts +0 -18
- package/types/utils/type/isFunction.d.ts +0 -18
- package/types/utils/type/isMap.d.ts +0 -18
- package/types/utils/type/isNaN.d.ts +0 -18
- package/types/utils/type/isNil.d.ts +0 -11
- package/types/utils/type/isNull.d.ts +0 -18
- package/types/utils/type/isNumber.d.ts +0 -27
- package/types/utils/type/isObject.d.ts +0 -21
- package/types/utils/type/isRegExp.d.ts +0 -18
- package/types/utils/type/isSet.d.ts +0 -18
- package/types/utils/type/isString.d.ts +0 -18
- package/types/utils/type/isSymbol.d.ts +0 -18
- package/types/utils/type/isType.d.ts +0 -11
- package/types/utils/type/isUndefined.d.ts +0 -21
- package/types/utils/type/isWeakMap.d.ts +0 -18
- package/types/utils/type/isWeakSet.d.ts +0 -18
package/esm/VERSION.js
ADDED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue, options) {
|
|
4
4
|
if (options === void 0) { options = {}; }
|
|
5
5
|
var _a = options.placeholderChar, placeholderChar = _a === void 0 ? ' ' : _a, _b = options.maskReg, maskReg = _b === void 0 ? /\D/g : _b, type = options.type;
|
|
6
|
-
var realCtrlValue =
|
|
7
|
-
var realRawValue =
|
|
6
|
+
var realCtrlValue = toString(prevCtrlValue);
|
|
7
|
+
var realRawValue = toString(rawValue);
|
|
8
8
|
var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
|
|
9
9
|
var editLength = realRawValue.length - realCtrlValue.length;
|
|
10
10
|
var isAddition = editLength > 0;
|
package/esm/divide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from 'tslib';
|
|
2
|
+
import { isNaN } from 'ut2';
|
|
2
3
|
import { transformEffectiveNumber, float2Fixed, checkBoundary, strip, digitLength } from './utils/math.util.js';
|
|
3
4
|
import times from './times.js';
|
|
4
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
5
5
|
|
|
6
6
|
function divide() {
|
|
7
7
|
var nums = [];
|
|
@@ -14,7 +14,7 @@ function divide() {
|
|
|
14
14
|
}
|
|
15
15
|
num1 = transformEffectiveNumber(num1);
|
|
16
16
|
num2 = transformEffectiveNumber(num2);
|
|
17
|
-
if (
|
|
17
|
+
if (isNaN(num1) || isNaN(num2)) {
|
|
18
18
|
return Number.NaN;
|
|
19
19
|
}
|
|
20
20
|
var num1Changed = float2Fixed(num1);
|
package/esm/download.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { isBlob, isPromiseLike } from 'ut2';
|
|
2
3
|
import dataURLToBlob from './dataURLToBlob.js';
|
|
3
4
|
import isUrl from './isUrl.js';
|
|
4
5
|
import ajax from './ajax.js';
|
|
5
|
-
import isBlob from './utils/type/isBlob.js';
|
|
6
|
-
import isPromiseLike from './isPromiseLike.js';
|
|
7
6
|
|
|
8
7
|
function saver(blobUrl, fileName) {
|
|
9
8
|
if (fileName === void 0) { fileName = ''; }
|
package/esm/filterTree.js
CHANGED
package/esm/findTreeNode.js
CHANGED
package/esm/findTreeNodes.js
CHANGED
package/esm/findTreeSelect.js
CHANGED
package/esm/formatBankCard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function formatBankCard(bankCardNo, options) {
|
|
4
4
|
if (bankCardNo === void 0) { bankCardNo = ''; }
|
|
@@ -7,7 +7,7 @@ function formatBankCard(bankCardNo, options) {
|
|
|
7
7
|
var realSpaceMark = 'spaceMark' in options ? options.spaceMark : char;
|
|
8
8
|
var reg = new RegExp("(.{".concat(length, "})"), 'g');
|
|
9
9
|
var regChar = new RegExp("".concat(realSpaceMark), 'g');
|
|
10
|
-
var realValue =
|
|
10
|
+
var realValue = toString(bankCardNo).replace(regChar, '');
|
|
11
11
|
var str = realValue.replace(reg, "$1".concat(realSpaceMark));
|
|
12
12
|
return realValue.length % length === 0 ? str.substring(0, str.length - 1) : str;
|
|
13
13
|
}
|
package/esm/formatMobile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function formatMobile(mobileNo, options) {
|
|
4
4
|
if (mobileNo === void 0) { mobileNo = ''; }
|
|
@@ -6,7 +6,7 @@ function formatMobile(mobileNo, options) {
|
|
|
6
6
|
var _a = options.char, char = _a === void 0 ? ' ' : _a;
|
|
7
7
|
var realSpaceMark = 'spaceMark' in options ? options.spaceMark : char;
|
|
8
8
|
var regChar = new RegExp(realSpaceMark, 'g');
|
|
9
|
-
var realValue =
|
|
9
|
+
var realValue = toString(mobileNo).replace(regChar, '').substring(0, 11);
|
|
10
10
|
if (realValue.length > 7) {
|
|
11
11
|
return realValue.replace(/^(...)(....)/g, "$1".concat(realSpaceMark, "$2").concat(realSpaceMark));
|
|
12
12
|
}
|
package/esm/formatMoney.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __read } from 'tslib';
|
|
2
|
+
import { isNaN } from 'ut2';
|
|
2
3
|
import { scientificToNumber, isScientificNumber, checkBoundary, trimLeftZero } from './utils/math.util.js';
|
|
3
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
4
4
|
import devWarn from './utils/devWarn.js';
|
|
5
5
|
|
|
6
6
|
var reg = /^[+-]?\d*\.?\d*$/;
|
|
7
7
|
function checkNumber(num) {
|
|
8
|
-
if ((typeof num !== 'number' && typeof num !== 'string') || (typeof num === 'number' &&
|
|
8
|
+
if ((typeof num !== 'number' && typeof num !== 'string') || (typeof num === 'number' && isNaN(num)) || (typeof num === 'string' && (!(reg.test(num) || isScientificNumber(num)) || num === ''))) {
|
|
9
9
|
devWarn("".concat(num, " invalid parameter."));
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
@@ -49,7 +49,7 @@ var formatMoney = function (num, options) {
|
|
|
49
49
|
if (typeof num === 'number' && !isFinite(num)) {
|
|
50
50
|
return num + '';
|
|
51
51
|
}
|
|
52
|
-
if (typeof precision !== 'number' ||
|
|
52
|
+
if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
|
|
53
53
|
precision = 2;
|
|
54
54
|
}
|
|
55
55
|
else if (precision > 10) {
|
package/esm/index.js
CHANGED
|
@@ -53,4 +53,9 @@ export { default as filterTree } from './filterTree.js';
|
|
|
53
53
|
export { default as findTreeNode } from './findTreeNode.js';
|
|
54
54
|
export { default as findTreeNodes } from './findTreeNodes.js';
|
|
55
55
|
export { default as findTreeSelect } from './findTreeSelect.js';
|
|
56
|
-
export { setDisableWarning
|
|
56
|
+
export { setDisableWarning } from './utils/config.js';
|
|
57
|
+
export { default as VERSION } from './VERSION.js';
|
|
58
|
+
|
|
59
|
+
var version = "4.18.0";
|
|
60
|
+
|
|
61
|
+
export { version };
|
package/esm/isBankCard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^[1-9]\d{9,20}$/;
|
|
4
4
|
var regLoose = /^\d{8,30}$/;
|
|
@@ -15,7 +15,7 @@ function sumCheckCode(numStr) {
|
|
|
15
15
|
function isBankCard(value, options) {
|
|
16
16
|
if (options === void 0) { options = {}; }
|
|
17
17
|
var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.luhn, luhn = _b === void 0 ? false : _b;
|
|
18
|
-
var valueStr =
|
|
18
|
+
var valueStr = toString(value);
|
|
19
19
|
var validateResult = loose ? regLoose.test(valueStr) : reg.test(valueStr);
|
|
20
20
|
if (validateResult && luhn) {
|
|
21
21
|
var precode = valueStr.substring(0, valueStr.length - 1);
|
package/esm/isBusinessLicense.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var baseReg = /^\d{15}$/;
|
|
4
4
|
function sumCheckCode(preCode) {
|
|
@@ -21,7 +21,7 @@ function sumCheckCode(preCode) {
|
|
|
21
21
|
}
|
|
22
22
|
function isBusinessLicense(value, options) {
|
|
23
23
|
if (options === void 0) { options = {}; }
|
|
24
|
-
var valueStr =
|
|
24
|
+
var valueStr = toString(value);
|
|
25
25
|
var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.checkCode, cc = _b === void 0 ? true : _b;
|
|
26
26
|
var needCheckCode = !loose && cc;
|
|
27
27
|
var passBaseRule = baseReg.test(valueStr);
|
package/esm/isChinese.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var chineseDictionary = {
|
|
4
4
|
chineseBasic: '[\u4e00-\u9fa5]',
|
|
@@ -19,7 +19,7 @@ var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
|
|
|
19
19
|
function isChinese(value, options) {
|
|
20
20
|
if (options === void 0) { options = {}; }
|
|
21
21
|
var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.useExtend, useExtend = _b === void 0 ? false : _b;
|
|
22
|
-
var valueStr =
|
|
22
|
+
var valueStr = toString(value);
|
|
23
23
|
var basicRegExp = loose ? looseChineseRegExp : chineseRegExp;
|
|
24
24
|
var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
|
|
25
25
|
var hasExtend = useExtend && supportRegExpUnicode;
|
package/esm/isEmail.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^[\da-z]+([-._]?[\da-z]+)*@[\da-z]+([-.]?[\da-z]+)*(\.[a-z]{2,})+$/i;
|
|
4
4
|
function isEmail(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isHMCard.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
|
|
4
4
|
function isHMCard(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return regHMCard.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isIPv4.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
4
4
|
function isIPv4(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isIPv6.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;
|
|
4
4
|
function isIPv6(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isIdCard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var regIdCard = /^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;
|
|
4
4
|
function check(id) {
|
|
@@ -17,7 +17,7 @@ function check(id) {
|
|
|
17
17
|
function isIdCard(value, options) {
|
|
18
18
|
if (options === void 0) { options = {}; }
|
|
19
19
|
var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.checkCode, checkCode = _b === void 0 ? true : _b;
|
|
20
|
-
var valueStr =
|
|
20
|
+
var valueStr = toString(value);
|
|
21
21
|
if (valueStr.length === 15 && loose) {
|
|
22
22
|
return regIdCard.test(valueStr);
|
|
23
23
|
}
|
package/esm/isMobile.js
CHANGED
package/esm/isPassport.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^((e[\da-z])|(de)|(se)|(pe)|([khm][\da-z]))[\da-z]{7}$/i;
|
|
4
4
|
function isPassport(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isPostcode.js
CHANGED
package/esm/isPromiseLike.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isPromiseLike as isPromiseLike$1 } from 'ut2';
|
|
2
|
+
|
|
1
3
|
function isPromiseLike(obj) {
|
|
2
|
-
return
|
|
4
|
+
return isPromiseLike$1(obj);
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
export { isPromiseLike as default };
|
package/esm/isQQ.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var baseReg = /^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/;
|
|
4
4
|
var baseCodeArr = '0123456789ABCDEFGHJKLMNPQRTUWXY'.split('');
|
|
@@ -18,7 +18,7 @@ function sumCheckCode(preCode) {
|
|
|
18
18
|
}
|
|
19
19
|
function isSocialCreditCode(value, options) {
|
|
20
20
|
if (options === void 0) { options = {}; }
|
|
21
|
-
var valueStr =
|
|
21
|
+
var valueStr = toString(value);
|
|
22
22
|
var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.checkCode, cc = _b === void 0 ? true : _b;
|
|
23
23
|
var needCheckCode = !loose && cc;
|
|
24
24
|
var passBaseRule = baseReg.test(valueStr);
|
package/esm/isSwiftCode.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^[A-Z]{6}[A-Z\d]{2}(?:[A-Z\d]{3})?$/;
|
|
4
4
|
function isSwiftCode(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isTWCard.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var regTWCard = /^\d{8}$/i;
|
|
4
4
|
var singleRegTWCard = /^[\da-z]{10,12}$/i;
|
|
5
5
|
function isTWCard(value, options) {
|
|
6
6
|
if (options === void 0) { options = {}; }
|
|
7
7
|
var _a = options.loose, loose = _a === void 0 ? false : _a;
|
|
8
|
-
var valueStr =
|
|
8
|
+
var valueStr = toString(value);
|
|
9
9
|
if (regTWCard.test(valueStr)) {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
package/esm/isTelephone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^(0\d{2,3}-)?([2-9]\d{6,7})(-\d{1,6})?$/;
|
|
4
4
|
function isTelephone(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isUrl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var protocalReg = '[\\w-.]+:\\/\\/';
|
|
4
4
|
var credentialsReg = '[-;:&=\\+\\$,\\w]+@';
|
|
@@ -10,7 +10,7 @@ var hashReg = '#.*';
|
|
|
10
10
|
var regWithProtocal = new RegExp("^".concat(protocalReg, "(?:").concat(credentialsReg, ")?(?:").concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
|
|
11
11
|
var regNonProtocal = new RegExp("^(?:".concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
|
|
12
12
|
function isUrl(value) {
|
|
13
|
-
var valueStr =
|
|
13
|
+
var valueStr = toString(value);
|
|
14
14
|
return regWithProtocal.test(valueStr) || regNonProtocal.test(valueStr);
|
|
15
15
|
}
|
|
16
16
|
|
package/esm/isValidNumber.js
CHANGED
package/esm/isVehicle.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;
|
|
4
4
|
function isVehicle(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/isWX.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
var reg = /^[a-z]([-_a-z0-9]{5,19})+$/i;
|
|
4
4
|
function isWX(value) {
|
|
5
|
-
var valueStr =
|
|
5
|
+
var valueStr = toString(value);
|
|
6
6
|
return reg.test(valueStr);
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/listToTree.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
|
-
import isObject from '
|
|
2
|
+
import { isObject } from 'ut2';
|
|
3
3
|
|
|
4
4
|
function processEmptyChildren(arr, options) {
|
|
5
5
|
var _a = options.childrenField, childrenField = _a === void 0 ? 'children' : _a, _b = options.emptyChildrenValue, emptyChildrenValue = _b === void 0 ? 'none' : _b;
|
package/esm/minus.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from 'tslib';
|
|
2
|
+
import { isNaN } from 'ut2';
|
|
2
3
|
import { transformEffectiveNumber, digitLength } from './utils/math.util.js';
|
|
3
4
|
import times from './times.js';
|
|
4
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
5
5
|
|
|
6
6
|
function minus() {
|
|
7
7
|
var nums = [];
|
|
@@ -14,7 +14,7 @@ function minus() {
|
|
|
14
14
|
}
|
|
15
15
|
num1 = transformEffectiveNumber(num1);
|
|
16
16
|
num2 = transformEffectiveNumber(num2);
|
|
17
|
-
if (
|
|
17
|
+
if (isNaN(num1) || isNaN(num2)) {
|
|
18
18
|
return Number.NaN;
|
|
19
19
|
}
|
|
20
20
|
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
package/esm/normalizeString.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import convertToString from './utils/convertToString.js';
|
|
1
|
+
import { toString } from 'ut2';
|
|
3
2
|
|
|
4
3
|
function normalizeString(value) {
|
|
5
|
-
|
|
6
|
-
return '';
|
|
7
|
-
}
|
|
8
|
-
return convertToString(value);
|
|
4
|
+
return toString(value);
|
|
9
5
|
}
|
|
10
6
|
|
|
11
7
|
export { normalizeString as default };
|
package/esm/padZero.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function padZero(value, size) {
|
|
4
4
|
if (size === void 0) { size = 2; }
|
|
5
|
-
var str =
|
|
5
|
+
var str = toString(value);
|
|
6
6
|
var len = str.length;
|
|
7
7
|
if (typeof size !== 'number' || size < 0) {
|
|
8
8
|
size = 0;
|
package/esm/plus.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from 'tslib';
|
|
2
|
+
import { isNaN } from 'ut2';
|
|
2
3
|
import { transformEffectiveNumber, digitLength } from './utils/math.util.js';
|
|
3
4
|
import times from './times.js';
|
|
4
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
5
5
|
|
|
6
6
|
function plus() {
|
|
7
7
|
var nums = [];
|
|
@@ -14,7 +14,7 @@ function plus() {
|
|
|
14
14
|
}
|
|
15
15
|
num1 = transformEffectiveNumber(num1);
|
|
16
16
|
num2 = transformEffectiveNumber(num2);
|
|
17
|
-
if (
|
|
17
|
+
if (isNaN(num1) || isNaN(num2)) {
|
|
18
18
|
return Number.NaN;
|
|
19
19
|
}
|
|
20
20
|
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
package/esm/replaceChar.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function replaceChar(str, options) {
|
|
4
4
|
if (options === void 0) { options = {}; }
|
|
5
5
|
var _a = options.char, char = _a === void 0 ? '*' : _a, exclude = options.exclude;
|
|
6
6
|
var _b = options.start, start = _b === void 0 ? 3 : _b, _c = options.end, end = _c === void 0 ? -4 : _c, repeat = options.repeat;
|
|
7
|
-
var realStr =
|
|
7
|
+
var realStr = toString(str);
|
|
8
8
|
var strLen = realStr.length;
|
|
9
9
|
if (Math.abs(start) >= strLen) {
|
|
10
10
|
return realStr;
|
package/esm/round.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { isNaN } from 'ut2';
|
|
1
2
|
import divide from './divide.js';
|
|
2
3
|
import times from './times.js';
|
|
3
4
|
import { transformEffectiveNumber } from './utils/math.util.js';
|
|
4
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
5
5
|
|
|
6
6
|
function round(num, precision) {
|
|
7
7
|
if (precision === void 0) { precision = 0; }
|
|
8
8
|
num = transformEffectiveNumber(num);
|
|
9
|
-
if (
|
|
9
|
+
if (isNaN(num)) {
|
|
10
10
|
return Number.NaN;
|
|
11
11
|
}
|
|
12
12
|
var base = Math.pow(10, precision);
|
package/esm/strlen.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toString } from 'ut2';
|
|
2
2
|
|
|
3
3
|
function strlen(str) {
|
|
4
|
-
var realStr =
|
|
4
|
+
var realStr = toString(str);
|
|
5
5
|
var len = 0;
|
|
6
6
|
for (var i = 0; i < realStr.length; i++) {
|
|
7
7
|
var c = realStr.charCodeAt(i);
|
package/esm/times.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __read, __spreadArray } from 'tslib';
|
|
2
|
+
import { isNaN } from 'ut2';
|
|
2
3
|
import { transformEffectiveNumber, float2Fixed, digitLength, checkBoundary } from './utils/math.util.js';
|
|
3
|
-
import _isNaN from './utils/type/isNaN.js';
|
|
4
4
|
|
|
5
5
|
function times() {
|
|
6
6
|
var nums = [];
|
|
@@ -13,7 +13,7 @@ function times() {
|
|
|
13
13
|
}
|
|
14
14
|
num1 = transformEffectiveNumber(num1);
|
|
15
15
|
num2 = transformEffectiveNumber(num2);
|
|
16
|
-
if (
|
|
16
|
+
if (isNaN(num1) || isNaN(num2)) {
|
|
17
17
|
return Number.NaN;
|
|
18
18
|
}
|
|
19
19
|
var num1Changed = float2Fixed(num1);
|
package/esm/treeToList.js
CHANGED
package/esm/utils/config.js
CHANGED
package/esm/utils/math.util.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from '
|
|
1
|
+
import { isString, isSymbol, isNumber, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from 'ut2';
|
|
2
2
|
import devWarn from './devWarn.js';
|
|
3
|
-
import isNumber from './type/isNumber.js';
|
|
4
|
-
import isString from './type/isString.js';
|
|
5
|
-
import isSymbol from './type/isSymbol.js';
|
|
6
3
|
|
|
7
4
|
function transformEffectiveNumber(value) {
|
|
8
5
|
var ret;
|
package/esm/waitTime.js
CHANGED
package/lib/VERSION.js
ADDED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var ut2 = require('ut2');
|
|
4
4
|
|
|
5
5
|
function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue, options) {
|
|
6
6
|
if (options === void 0) { options = {}; }
|
|
7
7
|
var _a = options.placeholderChar, placeholderChar = _a === void 0 ? ' ' : _a, _b = options.maskReg, maskReg = _b === void 0 ? /\D/g : _b, type = options.type;
|
|
8
|
-
var realCtrlValue =
|
|
9
|
-
var realRawValue =
|
|
8
|
+
var realCtrlValue = ut2.toString(prevCtrlValue);
|
|
9
|
+
var realRawValue = ut2.toString(rawValue);
|
|
10
10
|
var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
|
|
11
11
|
var editLength = realRawValue.length - realCtrlValue.length;
|
|
12
12
|
var isAddition = editLength > 0;
|