util-helpers 4.12.8 → 4.12.10

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 (44) hide show
  1. package/README.md +3 -1
  2. package/dist/util-helpers.js +81 -88
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/calculateCursorPosition.js +6 -7
  7. package/esm/formatBankCard.js +5 -5
  8. package/esm/formatMobile.js +4 -3
  9. package/esm/formatMoney.js +9 -10
  10. package/esm/isBankCard.js +5 -6
  11. package/esm/isChinese.js +5 -6
  12. package/esm/isIdCard.js +5 -6
  13. package/esm/isPassword.js +7 -8
  14. package/esm/isTWCard.js +3 -4
  15. package/esm/numberToChinese.js +14 -15
  16. package/esm/replaceChar.js +10 -9
  17. package/esm/utils/config.js +1 -1
  18. package/esm/validatePassword.js +7 -8
  19. package/lib/calculateCursorPosition.js +6 -7
  20. package/lib/formatBankCard.js +5 -5
  21. package/lib/formatMobile.js +4 -3
  22. package/lib/formatMoney.js +9 -10
  23. package/lib/isBankCard.js +5 -6
  24. package/lib/isChinese.js +5 -6
  25. package/lib/isIdCard.js +5 -6
  26. package/lib/isPassword.js +7 -8
  27. package/lib/isTWCard.js +3 -4
  28. package/lib/numberToChinese.js +14 -15
  29. package/lib/replaceChar.js +10 -9
  30. package/lib/utils/config.js +1 -1
  31. package/lib/validatePassword.js +7 -8
  32. package/package.json +2 -1
  33. package/types/calculateCursorPosition.d.ts +1 -1
  34. package/types/formatBankCard.d.ts +1 -1
  35. package/types/formatMobile.d.ts +1 -1
  36. package/types/formatMoney.d.ts +1 -1
  37. package/types/isBankCard.d.ts +1 -1
  38. package/types/isChinese.d.ts +1 -1
  39. package/types/isIdCard.d.ts +1 -1
  40. package/types/isPassword.d.ts +1 -1
  41. package/types/isTWCard.d.ts +1 -1
  42. package/types/numberToChinese.d.ts +1 -1
  43. package/types/replaceChar.d.ts +1 -1
  44. package/types/validatePassword.d.ts +1 -1
@@ -28,12 +28,12 @@ import normalizeString from './normalizeString';
28
28
 
29
29
  function formatBankCard() {
30
30
  var bankCardNo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
31
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
32
 
32
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
33
- _ref$char = _ref["char"],
34
- _char = _ref$char === void 0 ? ' ' : _ref$char,
35
- _ref$length = _ref.length,
36
- length = _ref$length === void 0 ? 4 : _ref$length;
33
+ var _options$char = options["char"],
34
+ _char = _options$char === void 0 ? ' ' : _options$char,
35
+ _options$length = options.length,
36
+ length = _options$length === void 0 ? 4 : _options$length;
37
37
 
38
38
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
39
39
  var regChar = new RegExp("".concat(_char), 'g');
@@ -26,9 +26,10 @@ import normalizeString from './normalizeString';
26
26
  */
27
27
 
28
28
  function formatMobile(mobileNo) {
29
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
30
- _ref$char = _ref["char"],
31
- _char = _ref$char === void 0 ? ' ' : _ref$char;
29
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
+
31
+ var _options$char = options["char"],
32
+ _char = _options$char === void 0 ? ' ' : _options$char;
32
33
 
33
34
  var regChar = new RegExp(_char, 'g');
34
35
  var realValue = normalizeString(mobileNo).replace(regChar, '').substring(0, 11);
@@ -118,17 +118,16 @@ function formatDec(decStr, precision, decimal) {
118
118
 
119
119
 
120
120
  var formatMoney = function formatMoney(num) {
121
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
122
- _ref$precision = _ref.precision,
123
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
124
- symbol = _ref.symbol,
125
- _ref$thousand = _ref.thousand,
126
- thousand = _ref$thousand === void 0 ? ',' : _ref$thousand,
127
- _ref$decimal = _ref.decimal,
128
- decimal = _ref$decimal === void 0 ? '.' : _ref$decimal;
129
-
130
- // 数字参数不正确,返回空字符串
121
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
122
+ var _options$precision = options.precision,
123
+ precision = _options$precision === void 0 ? 2 : _options$precision,
124
+ symbol = options.symbol,
125
+ _options$thousand = options.thousand,
126
+ thousand = _options$thousand === void 0 ? ',' : _options$thousand,
127
+ _options$decimal = options.decimal,
128
+ decimal = _options$decimal === void 0 ? '.' : _options$decimal; // 数字参数不正确,返回空字符串
131
129
  // @ts-ignore
130
+
132
131
  if (!checkNumber(num)) {
133
132
  return '';
134
133
  } // 参数规整化
package/esm/isBankCard.js CHANGED
@@ -47,12 +47,11 @@ function sumCheckCode(numStr) {
47
47
 
48
48
 
49
49
  function isBankCard(value) {
50
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
51
- _ref$loose = _ref.loose,
52
- loose = _ref$loose === void 0 ? false : _ref$loose,
53
- _ref$luhn = _ref.luhn,
54
- luhn = _ref$luhn === void 0 ? false : _ref$luhn;
55
-
50
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
51
+ var _options$loose = options.loose,
52
+ loose = _options$loose === void 0 ? false : _options$loose,
53
+ _options$luhn = options.luhn,
54
+ luhn = _options$luhn === void 0 ? false : _options$luhn;
56
55
  var valueStr = normalizeString(value);
57
56
  var validateResult = loose ? regLoose.test(valueStr) : reg.test(valueStr);
58
57
 
package/esm/isChinese.js CHANGED
@@ -55,12 +55,11 @@ var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
55
55
  */
56
56
 
57
57
  function isChinese(value) {
58
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
59
- _ref$loose = _ref.loose,
60
- loose = _ref$loose === void 0 ? false : _ref$loose,
61
- _ref$useExtend = _ref.useExtend,
62
- useExtend = _ref$useExtend === void 0 ? false : _ref$useExtend;
63
-
58
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59
+ var _options$loose = options.loose,
60
+ loose = _options$loose === void 0 ? false : _options$loose,
61
+ _options$useExtend = options.useExtend,
62
+ useExtend = _options$useExtend === void 0 ? false : _options$useExtend;
64
63
  var valueStr = normalizeString(value);
65
64
  var basicRegExp = loose ? looseChineseRegExp : chineseRegExp;
66
65
  var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
package/esm/isIdCard.js CHANGED
@@ -55,12 +55,11 @@ function check(id) {
55
55
 
56
56
 
57
57
  function isIdCard(value) {
58
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
59
- _ref$loose = _ref.loose,
60
- loose = _ref$loose === void 0 ? false : _ref$loose,
61
- _ref$checkCode = _ref.checkCode,
62
- checkCode = _ref$checkCode === void 0 ? true : _ref$checkCode;
63
-
58
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59
+ var _options$loose = options.loose,
60
+ loose = _options$loose === void 0 ? false : _options$loose,
61
+ _options$checkCode = options.checkCode,
62
+ checkCode = _options$checkCode === void 0 ? true : _options$checkCode;
64
63
  var valueStr = normalizeString(value);
65
64
 
66
65
  if (valueStr.length === 15 && loose) {
package/esm/isPassword.js CHANGED
@@ -34,14 +34,13 @@ import validatePassword from './validatePassword';
34
34
  */
35
35
 
36
36
  function isPassword(value) {
37
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
38
- _ref$level = _ref.level,
39
- level = _ref$level === void 0 ? 2 : _ref$level,
40
- _ref$ignoreCase = _ref.ignoreCase,
41
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
42
- _ref$special = _ref.special,
43
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
44
-
37
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ var _options$level = options.level,
39
+ level = _options$level === void 0 ? 2 : _options$level,
40
+ _options$ignoreCase = options.ignoreCase,
41
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
42
+ _options$special = options.special,
43
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
45
44
  return validatePassword(value, {
46
45
  level: level,
47
46
  ignoreCase: ignoreCase,
package/esm/isTWCard.js CHANGED
@@ -27,10 +27,9 @@ var singleRegTWCard = /^[\da-z]{10,12}$/i;
27
27
  */
28
28
 
29
29
  function isTWCard(value) {
30
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
31
- _ref$loose = _ref.loose,
32
- loose = _ref$loose === void 0 ? false : _ref$loose;
33
-
30
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
+ var _options$loose = options.loose,
32
+ loose = _options$loose === void 0 ? false : _options$loose;
34
33
  var valueStr = normalizeString(value);
35
34
 
36
35
  if (regTWCard.test(valueStr)) {
@@ -180,21 +180,20 @@ function mapNumberChar(num) {
180
180
 
181
181
 
182
182
  function numberToChinese(num) {
183
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
184
- _ref$big = _ref.big5,
185
- big5 = _ref$big === void 0 ? false : _ref$big,
186
- _ref$unit = _ref.unit,
187
- unit = _ref$unit === void 0 ? true : _ref$unit,
188
- _ref$decimal = _ref.decimal,
189
- decimal = _ref$decimal === void 0 ? '' : _ref$decimal,
190
- _ref$zero = _ref.zero,
191
- zero = _ref$zero === void 0 ? '' : _ref$zero,
192
- _ref$negative = _ref.negative,
193
- negative = _ref$negative === void 0 ? '负' : _ref$negative,
194
- _ref$unitConfig = _ref.unitConfig,
195
- unitConfig = _ref$unitConfig === void 0 ? {} : _ref$unitConfig;
196
-
197
- // 非数字 或 NaN 不处理
183
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
184
+ var _options$big = options.big5,
185
+ big5 = _options$big === void 0 ? false : _options$big,
186
+ _options$unit = options.unit,
187
+ unit = _options$unit === void 0 ? true : _options$unit,
188
+ _options$zero = options.zero,
189
+ zero = _options$zero === void 0 ? '' : _options$zero,
190
+ _options$negative = options.negative,
191
+ negative = _options$negative === void 0 ? '' : _options$negative,
192
+ _options$unitConfig = options.unitConfig,
193
+ unitConfig = _options$unitConfig === void 0 ? {} : _options$unitConfig;
194
+ var _options$decimal = options.decimal,
195
+ decimal = _options$decimal === void 0 ? '' : _options$decimal; // 非数字 或 NaN 不处理
196
+
198
197
  if (typeof num !== 'number' || isNaN(num)) {
199
198
  devWarn("\u53C2\u6570\u9519\u8BEF ".concat(num, "\uFF0C\u8BF7\u4F20\u5165\u6570\u5B57"));
200
199
  return '';
@@ -39,16 +39,17 @@ import normalizeString from './normalizeString';
39
39
  */
40
40
 
41
41
  function replaceChar(str) {
42
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
43
- _ref$start = _ref.start,
44
- start = _ref$start === void 0 ? 3 : _ref$start,
45
- _ref$end = _ref.end,
46
- end = _ref$end === void 0 ? -4 : _ref$end,
47
- _ref$char = _ref["char"],
48
- _char = _ref$char === void 0 ? '*' : _ref$char,
49
- repeat = _ref.repeat,
50
- exclude = _ref.exclude;
42
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
51
43
 
44
+ var _options$char = options["char"],
45
+ _char = _options$char === void 0 ? '*' : _options$char,
46
+ exclude = options.exclude;
47
+
48
+ var _options$start = options.start,
49
+ start = _options$start === void 0 ? 3 : _options$start,
50
+ _options$end = options.end,
51
+ end = _options$end === void 0 ? -4 : _options$end,
52
+ repeat = options.repeat;
52
53
  var realStr = normalizeString(str);
53
54
  var strLen = realStr.length; // 开始位置超过str长度
54
55
 
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- var version = "4.12.8";
2
+ var version = "4.12.10";
3
3
  var config = {
4
4
  // 禁用warning提示
5
5
  disableWarning: true
@@ -217,14 +217,13 @@ function hasUnallowableCharacter(val, chars) {
217
217
 
218
218
 
219
219
  function validatePassword(value) {
220
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
221
- _ref$level = _ref.level,
222
- level = _ref$level === void 0 ? 2 : _ref$level,
223
- _ref$ignoreCase = _ref.ignoreCase,
224
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
225
- _ref$special = _ref.special,
226
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
227
-
220
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
221
+ var _options$level = options.level,
222
+ level = _options$level === void 0 ? 2 : _options$level,
223
+ _options$ignoreCase = options.ignoreCase,
224
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
225
+ _options$special = options.special,
226
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
228
227
  var valStr = value;
229
228
 
230
229
  if (typeof value !== 'string') {
@@ -32,13 +32,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
32
32
  * @returns {number} 格式化后的光标位置
33
33
  */
34
34
  function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue) {
35
- var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
36
- _ref$placeholderChar = _ref.placeholderChar,
37
- placeholderChar = _ref$placeholderChar === void 0 ? ' ' : _ref$placeholderChar,
38
- _ref$maskReg = _ref.maskReg,
39
- maskReg = _ref$maskReg === void 0 ? /\D/g : _ref$maskReg,
40
- type = _ref.type;
41
-
35
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
36
+ var _options$placeholderC = options.placeholderChar,
37
+ placeholderChar = _options$placeholderC === void 0 ? ' ' : _options$placeholderC,
38
+ _options$maskReg = options.maskReg,
39
+ maskReg = _options$maskReg === void 0 ? /\D/g : _options$maskReg,
40
+ type = options.type;
42
41
  var realCtrlValue = (0, _normalizeString["default"])(prevCtrlValue);
43
42
  var realRawValue = (0, _normalizeString["default"])(rawValue);
44
43
  var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
@@ -37,12 +37,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
37
37
  */
38
38
  function formatBankCard() {
39
39
  var bankCardNo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
40
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40
41
 
41
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
42
- _ref$char = _ref["char"],
43
- _char = _ref$char === void 0 ? ' ' : _ref$char,
44
- _ref$length = _ref.length,
45
- length = _ref$length === void 0 ? 4 : _ref$length;
42
+ var _options$char = options["char"],
43
+ _char = _options$char === void 0 ? ' ' : _options$char,
44
+ _options$length = options.length,
45
+ length = _options$length === void 0 ? 4 : _options$length;
46
46
 
47
47
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
48
48
  var regChar = new RegExp("".concat(_char), 'g');
@@ -35,9 +35,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
35
35
  *
36
36
  */
37
37
  function formatMobile(mobileNo) {
38
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
39
- _ref$char = _ref["char"],
40
- _char = _ref$char === void 0 ? ' ' : _ref$char;
38
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
+
40
+ var _options$char = options["char"],
41
+ _char = _options$char === void 0 ? ' ' : _options$char;
41
42
 
42
43
  var regChar = new RegExp(_char, 'g');
43
44
  var realValue = (0, _normalizeString["default"])(mobileNo).replace(regChar, '').substring(0, 11);
@@ -140,17 +140,16 @@ function formatDec(decStr, precision, decimal) {
140
140
 
141
141
 
142
142
  var formatMoney = function formatMoney(num) {
143
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
144
- _ref$precision = _ref.precision,
145
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
146
- symbol = _ref.symbol,
147
- _ref$thousand = _ref.thousand,
148
- thousand = _ref$thousand === void 0 ? ',' : _ref$thousand,
149
- _ref$decimal = _ref.decimal,
150
- decimal = _ref$decimal === void 0 ? '.' : _ref$decimal;
151
-
152
- // 数字参数不正确,返回空字符串
143
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
144
+ var _options$precision = options.precision,
145
+ precision = _options$precision === void 0 ? 2 : _options$precision,
146
+ symbol = options.symbol,
147
+ _options$thousand = options.thousand,
148
+ thousand = _options$thousand === void 0 ? ',' : _options$thousand,
149
+ _options$decimal = options.decimal,
150
+ decimal = _options$decimal === void 0 ? '.' : _options$decimal; // 数字参数不正确,返回空字符串
153
151
  // @ts-ignore
152
+
154
153
  if (!checkNumber(num)) {
155
154
  return '';
156
155
  } // 参数规整化
package/lib/isBankCard.js CHANGED
@@ -57,12 +57,11 @@ function sumCheckCode(numStr) {
57
57
 
58
58
 
59
59
  function isBankCard(value) {
60
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
61
- _ref$loose = _ref.loose,
62
- loose = _ref$loose === void 0 ? false : _ref$loose,
63
- _ref$luhn = _ref.luhn,
64
- luhn = _ref$luhn === void 0 ? false : _ref$luhn;
65
-
60
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
61
+ var _options$loose = options.loose,
62
+ loose = _options$loose === void 0 ? false : _options$loose,
63
+ _options$luhn = options.luhn,
64
+ luhn = _options$luhn === void 0 ? false : _options$luhn;
66
65
  var valueStr = (0, _normalizeString["default"])(value);
67
66
  var validateResult = loose ? regLoose.test(valueStr) : reg.test(valueStr);
68
67
 
package/lib/isChinese.js CHANGED
@@ -65,12 +65,11 @@ var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
65
65
  */
66
66
 
67
67
  function isChinese(value) {
68
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
69
- _ref$loose = _ref.loose,
70
- loose = _ref$loose === void 0 ? false : _ref$loose,
71
- _ref$useExtend = _ref.useExtend,
72
- useExtend = _ref$useExtend === void 0 ? false : _ref$useExtend;
73
-
68
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
69
+ var _options$loose = options.loose,
70
+ loose = _options$loose === void 0 ? false : _options$loose,
71
+ _options$useExtend = options.useExtend,
72
+ useExtend = _options$useExtend === void 0 ? false : _options$useExtend;
74
73
  var valueStr = (0, _normalizeString["default"])(value);
75
74
  var basicRegExp = loose ? looseChineseRegExp : chineseRegExp;
76
75
  var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
package/lib/isIdCard.js CHANGED
@@ -65,12 +65,11 @@ function check(id) {
65
65
 
66
66
 
67
67
  function isIdCard(value) {
68
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
69
- _ref$loose = _ref.loose,
70
- loose = _ref$loose === void 0 ? false : _ref$loose,
71
- _ref$checkCode = _ref.checkCode,
72
- checkCode = _ref$checkCode === void 0 ? true : _ref$checkCode;
73
-
68
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
69
+ var _options$loose = options.loose,
70
+ loose = _options$loose === void 0 ? false : _options$loose,
71
+ _options$checkCode = options.checkCode,
72
+ checkCode = _options$checkCode === void 0 ? true : _options$checkCode;
74
73
  var valueStr = (0, _normalizeString["default"])(value);
75
74
 
76
75
  if (valueStr.length === 15 && loose) {
package/lib/isPassword.js CHANGED
@@ -43,14 +43,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
43
43
  *
44
44
  */
45
45
  function isPassword(value) {
46
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
47
- _ref$level = _ref.level,
48
- level = _ref$level === void 0 ? 2 : _ref$level,
49
- _ref$ignoreCase = _ref.ignoreCase,
50
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
51
- _ref$special = _ref.special,
52
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
53
-
46
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
47
+ var _options$level = options.level,
48
+ level = _options$level === void 0 ? 2 : _options$level,
49
+ _options$ignoreCase = options.ignoreCase,
50
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
51
+ _options$special = options.special,
52
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
54
53
  return (0, _validatePassword["default"])(value, {
55
54
  level: level,
56
55
  ignoreCase: ignoreCase,
package/lib/isTWCard.js CHANGED
@@ -37,10 +37,9 @@ var singleRegTWCard = /^[\da-z]{10,12}$/i;
37
37
  */
38
38
 
39
39
  function isTWCard(value) {
40
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
41
- _ref$loose = _ref.loose,
42
- loose = _ref$loose === void 0 ? false : _ref$loose;
43
-
40
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
41
+ var _options$loose = options.loose,
42
+ loose = _options$loose === void 0 ? false : _options$loose;
44
43
  var valueStr = (0, _normalizeString["default"])(value);
45
44
 
46
45
  if (regTWCard.test(valueStr)) {
@@ -191,21 +191,20 @@ function mapNumberChar(num) {
191
191
 
192
192
 
193
193
  function numberToChinese(num) {
194
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
195
- _ref$big = _ref.big5,
196
- big5 = _ref$big === void 0 ? false : _ref$big,
197
- _ref$unit = _ref.unit,
198
- unit = _ref$unit === void 0 ? true : _ref$unit,
199
- _ref$decimal = _ref.decimal,
200
- decimal = _ref$decimal === void 0 ? '' : _ref$decimal,
201
- _ref$zero = _ref.zero,
202
- zero = _ref$zero === void 0 ? '' : _ref$zero,
203
- _ref$negative = _ref.negative,
204
- negative = _ref$negative === void 0 ? '负' : _ref$negative,
205
- _ref$unitConfig = _ref.unitConfig,
206
- unitConfig = _ref$unitConfig === void 0 ? {} : _ref$unitConfig;
207
-
208
- // 非数字 或 NaN 不处理
194
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
195
+ var _options$big = options.big5,
196
+ big5 = _options$big === void 0 ? false : _options$big,
197
+ _options$unit = options.unit,
198
+ unit = _options$unit === void 0 ? true : _options$unit,
199
+ _options$zero = options.zero,
200
+ zero = _options$zero === void 0 ? '' : _options$zero,
201
+ _options$negative = options.negative,
202
+ negative = _options$negative === void 0 ? '' : _options$negative,
203
+ _options$unitConfig = options.unitConfig,
204
+ unitConfig = _options$unitConfig === void 0 ? {} : _options$unitConfig;
205
+ var _options$decimal = options.decimal,
206
+ decimal = _options$decimal === void 0 ? '' : _options$decimal; // 非数字 或 NaN 不处理
207
+
209
208
  if (typeof num !== 'number' || isNaN(num)) {
210
209
  (0, _devWarn["default"])("\u53C2\u6570\u9519\u8BEF ".concat(num, "\uFF0C\u8BF7\u4F20\u5165\u6570\u5B57"));
211
210
  return '';
@@ -48,16 +48,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
48
48
  *
49
49
  */
50
50
  function replaceChar(str) {
51
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
52
- _ref$start = _ref.start,
53
- start = _ref$start === void 0 ? 3 : _ref$start,
54
- _ref$end = _ref.end,
55
- end = _ref$end === void 0 ? -4 : _ref$end,
56
- _ref$char = _ref["char"],
57
- _char = _ref$char === void 0 ? '*' : _ref$char,
58
- repeat = _ref.repeat,
59
- exclude = _ref.exclude;
51
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
52
 
53
+ var _options$char = options["char"],
54
+ _char = _options$char === void 0 ? '*' : _options$char,
55
+ exclude = options.exclude;
56
+
57
+ var _options$start = options.start,
58
+ start = _options$start === void 0 ? 3 : _options$start,
59
+ _options$end = options.end,
60
+ end = _options$end === void 0 ? -4 : _options$end,
61
+ repeat = options.repeat;
61
62
  var realStr = (0, _normalizeString["default"])(str);
62
63
  var strLen = realStr.length; // 开始位置超过str长度
63
64
 
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.setDisableWarning = setDisableWarning;
7
7
  exports.version = exports.config = void 0;
8
8
  // @ts-ignore
9
- var version = "4.12.8";
9
+ var version = "4.12.10";
10
10
  exports.version = version;
11
11
  var config = {
12
12
  // 禁用warning提示
@@ -227,14 +227,13 @@ function hasUnallowableCharacter(val, chars) {
227
227
 
228
228
 
229
229
  function validatePassword(value) {
230
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
231
- _ref$level = _ref.level,
232
- level = _ref$level === void 0 ? 2 : _ref$level,
233
- _ref$ignoreCase = _ref.ignoreCase,
234
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
235
- _ref$special = _ref.special,
236
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
237
-
230
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
231
+ var _options$level = options.level,
232
+ level = _options$level === void 0 ? 2 : _options$level,
233
+ _options$ignoreCase = options.ignoreCase,
234
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
235
+ _options$special = options.special,
236
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
238
237
  var valStr = value;
239
238
 
240
239
  if (typeof value !== 'string') {
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.12.8",
3
+ "version": "4.12.10",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
7
+ "unpkg": "dist/util-helpers.min.js",
7
8
  "sideEffects": false,
8
9
  "types": "types/index.d.ts",
9
10
  "scripts": {
@@ -19,7 +19,7 @@ export default calculateCursorPosition;
19
19
  * @param {'mobile'|'bankCard'} [options.type] 格式化类型,内置手机号码和银行卡号特殊处理
20
20
  * @returns {number} 格式化后的光标位置
21
21
  */
22
- declare function calculateCursorPosition(prevPos: number, prevCtrlValue: string, rawValue: string, ctrlValue: string, { placeholderChar, maskReg, type }?: {
22
+ declare function calculateCursorPosition(prevPos: number, prevCtrlValue: string, rawValue: string, ctrlValue: string, options?: {
23
23
  placeholderChar?: string | string[] | undefined;
24
24
  maskReg?: RegExp | undefined;
25
25
  type?: "mobile" | "bankCard" | undefined;
@@ -25,7 +25,7 @@ export default formatBankCard;
25
25
  * formatBankCard('6228480402564890', {char: '-'}); // 6228-4804-0256-4890
26
26
  *
27
27
  */
28
- declare function formatBankCard(bankCardNo?: string, { char, length }?: {
28
+ declare function formatBankCard(bankCardNo?: string, options?: {
29
29
  char?: string | undefined;
30
30
  length?: number | undefined;
31
31
  } | undefined): string;
@@ -24,6 +24,6 @@ export default formatMobile;
24
24
  * formatMobile('13345678'); // 133 4567 8
25
25
  *
26
26
  */
27
- declare function formatMobile(mobileNo: string, { char }?: {
27
+ declare function formatMobile(mobileNo: string, options?: {
28
28
  char?: string | undefined;
29
29
  } | undefined): string;
@@ -36,7 +36,7 @@ export default formatMoney;
36
36
  * formatMoney(1000.00, { decimal: '&' }); // 1,000&00
37
37
  *
38
38
  */
39
- declare function formatMoney(num: string | number, { precision, symbol, thousand, decimal }?: {
39
+ declare function formatMoney(num: string | number, options?: {
40
40
  precision?: string | number | undefined;
41
41
  symbol?: string | undefined;
42
42
  thousand?: string | undefined;
@@ -21,7 +21,7 @@ export default isBankCard;
21
21
  * isBankCard('123456789', { loose: true }); // true
22
22
  *
23
23
  */
24
- declare function isBankCard(value: any, { loose, luhn }?: {
24
+ declare function isBankCard(value: any, options?: {
25
25
  loose?: boolean | undefined;
26
26
  luhn?: boolean | undefined;
27
27
  } | undefined): boolean;
@@ -28,7 +28,7 @@ export default isChinese;
28
28
  * isChinese('𠮷aa', { useExtend: true, loose: true }); // true
29
29
  *
30
30
  */
31
- declare function isChinese(value: any, { loose, useExtend }?: {
31
+ declare function isChinese(value: any, options?: {
32
32
  loose?: boolean | undefined;
33
33
  useExtend?: boolean | undefined;
34
34
  } | undefined): boolean;
@@ -25,7 +25,7 @@ export default isIdCard;
25
25
  * isIdCard('320311770706001', { loose: true }); // true
26
26
  *
27
27
  */
28
- declare function isIdCard(value: any, { loose, checkCode }?: {
28
+ declare function isIdCard(value: any, options?: {
29
29
  loose?: boolean | undefined;
30
30
  checkCode?: boolean | undefined;
31
31
  } | undefined): boolean;