util-helpers 4.3.0 → 4.6.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.
@@ -0,0 +1,62 @@
1
+ import normalizeString from './normalizeString'; // ref: https://github.com/ant-design/ant-design-mobile/blob/v2/components/input-item/index.tsx#L240
2
+
3
+ /**
4
+ * 计算输入框的值格式化后光标位置
5
+ *
6
+ * @static
7
+ * @alias module:Other.calculateCursorPosition
8
+ * @since 4.6.0
9
+ * @see 格式化手机号码 {@link https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile|formatMobile}
10
+ * @see 格式化银行卡号 {@link https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard|formatBankCard}
11
+ * @see 示例 {@link https://2950v9.csb.app/|点击查看}
12
+ * @param {number} prevPos 赋值前的光标位置,onChange/onInput的光标位置 e.target.selectionEnd
13
+ * @param {string} prevCtrlValue 上一个格式化后的值
14
+ * @param {string} rawValue 当前输入原值
15
+ * @param {string} ctrlValue 当前格式化后的值
16
+ * @param {Object} [options] 配置项
17
+ * @param {string[]|string} [options.placeholderChar=' '] 占位符
18
+ * @param {RegExp} [options.maskReg=/\D/g] 需要遮盖的字符规则。默认去掉非数字,意味着 ctrlValue 需要去掉非数字。
19
+ * @param {'mobile'|'bankCard'} [options.type] 格式化类型,内置手机号码和银行卡号特殊处理
20
+ * @returns {number} 格式化后的光标位置
21
+ */
22
+
23
+ function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue) {
24
+ var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
25
+ _ref$placeholderChar = _ref.placeholderChar,
26
+ placeholderChar = _ref$placeholderChar === void 0 ? ' ' : _ref$placeholderChar,
27
+ _ref$maskReg = _ref.maskReg,
28
+ maskReg = _ref$maskReg === void 0 ? /\D/g : _ref$maskReg,
29
+ type = _ref.type;
30
+
31
+ var realCtrlValue = normalizeString(prevCtrlValue);
32
+ var realRawValue = normalizeString(rawValue);
33
+ var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
34
+ var editLength = realRawValue.length - realCtrlValue.length;
35
+ var isAddition = editLength > 0;
36
+ var pos = prevPos;
37
+
38
+ if (isAddition) {
39
+ var additionStr = realRawValue.substring(pos - editLength, pos);
40
+ var ctrlCharCount = additionStr.replace(maskReg, '').length;
41
+ pos -= editLength - ctrlCharCount;
42
+ var placeholderCharCount = 0;
43
+
44
+ while (ctrlCharCount > 0) {
45
+ if (placeholderChars.indexOf(ctrlValue.charAt(pos - ctrlCharCount + placeholderCharCount)) !== -1) {
46
+ placeholderCharCount++;
47
+ } else {
48
+ ctrlCharCount--;
49
+ }
50
+ }
51
+
52
+ pos += placeholderCharCount;
53
+ }
54
+
55
+ if (type === 'mobile' && (pos === 4 || pos === 9) || type === 'bankCard' && pos > 0 && pos % 5 === 0) {
56
+ pos -= 1;
57
+ }
58
+
59
+ return pos;
60
+ }
61
+
62
+ export default calculateCursorPosition;
@@ -42,9 +42,8 @@ function formatBankCard() {
42
42
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
43
43
  var regChar = new RegExp("".concat(_char), 'g');
44
44
  var realValue = normalizeString(bankCardNo).replace(regChar, '');
45
- var needRemoveLastChar = realValue.length % length === 0;
46
45
  var str = realValue.replace(reg, "$1".concat(_char));
47
- return needRemoveLastChar ? str.substring(0, str.length - 1) : str;
46
+ return realValue.length % length === 0 ? str.substring(0, str.length - 1) : str;
48
47
  }
49
48
 
50
49
  export default formatBankCard;
@@ -0,0 +1,45 @@
1
+ import normalizeString from './normalizeString';
2
+ /**
3
+ * 格式化手机号码
4
+ *
5
+ * @static
6
+ * @alias module:Processor.formatMobile
7
+ * @since 4.5.0
8
+ * @param {string} mobileNo 手机号码
9
+ * @param {object} [options] 配置项
10
+ * @param {string} [options.char=' '] 间隔字符
11
+ * @returns {string} 格式化后的手机号码
12
+ * @example
13
+ * formatMobile('13345678900') // '133 4567 8900'
14
+ * formatMobile('13345678900', { char: '-' }) // '133-4567-8900'
15
+ *
16
+ * // 脱敏手机号码
17
+ * formatMobile('133****1234') // '133 **** 1234'
18
+ * formatMobile('133****1234', { char: '-' }) // '133-****-1234'
19
+ *
20
+ * // 手机号码位数不够
21
+ * formatMobile('133') // '133'
22
+ * formatMobile('133456') // '133 456'
23
+ * formatMobile('13345678') // '133 4567 8'
24
+ */
25
+
26
+ function formatMobile(mobileNo) {
27
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
28
+ _ref$char = _ref["char"],
29
+ _char = _ref$char === void 0 ? ' ' : _ref$char;
30
+
31
+ var regChar = new RegExp(_char, 'g');
32
+ var realValue = normalizeString(mobileNo).replace(regChar, '').substring(0, 11);
33
+
34
+ if (realValue.length > 7) {
35
+ return realValue.replace(/^(...)(....)/g, "$1".concat(_char, "$2").concat(_char));
36
+ }
37
+
38
+ if (realValue.length > 3) {
39
+ return realValue.replace(/^(...)/g, "$1".concat(_char));
40
+ }
41
+
42
+ return realValue;
43
+ }
44
+
45
+ export default formatMobile;
package/esm/index.js CHANGED
@@ -42,6 +42,8 @@ export { default as blobToDataURL } from './blobToDataURL';
42
42
  export { default as dataURLToBlob } from './dataURLToBlob';
43
43
  export { default as setDataURLPrefix } from './setDataURLPrefix';
44
44
  export { default as normalizeString } from './normalizeString';
45
+ export { default as safeDate } from './safeDate';
46
+ export { default as formatMobile } from './formatMobile';
45
47
  /**
46
48
  * 数学计算,修正浮点数计算问题
47
49
  *
@@ -64,6 +66,7 @@ export { default as round } from './round';
64
66
  */
65
67
 
66
68
  export { default as waitTime } from './waitTime';
69
+ export { default as calculateCursorPosition } from './calculateCursorPosition';
67
70
  /**
68
71
  * 调试相关
69
72
  *
package/esm/isHMCard.js CHANGED
@@ -10,6 +10,18 @@ var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
10
10
  * @see 参考 {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证|港澳居民来往内地通行证}
11
11
  * @param {*} value 要检测的值
12
12
  * @returns {boolean} 是否为港澳居民来往内地通行证
13
+ * @example
14
+ * // 第一代 11 位
15
+ * isHMCard('h3203117707') // true
16
+ * isHMCard('H3203117707') // true
17
+ * isHMCard('m3203117707') // true
18
+ * isHMCard('M3203117707') // true
19
+ *
20
+ * // 第二代 9 位
21
+ * isHMCard('h32031177') // true
22
+ * isHMCard('H32031177') // true
23
+ * isHMCard('m32031177') // true
24
+ * isHMCard('M32031177') // true
13
25
  */
14
26
 
15
27
  function isHMCard(value) {
package/esm/isIdCard.js CHANGED
@@ -8,7 +8,7 @@ var regIdCard = /^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|
8
8
  * @see 参考 {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码|中华人民共和国公民身份号码}
9
9
  * @see 参考 {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
10
10
  * @param {string} id 身份证号码
11
- * @returns 校验码是否正确
11
+ * @returns {boolean} 校验码是否正确
12
12
  */
13
13
 
14
14
  function check(id) {
package/esm/isTWCard.js CHANGED
@@ -10,6 +10,12 @@ var regTWCard = /^(\d{8}|[\da-z]{10})$/i;
10
10
  * @see 参考 {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证|台湾居民来往大陆通行证}
11
11
  * @param {*} value 要检测的值
12
12
  * @returns {boolean} 是否为台湾居民来往大陆通行证
13
+ * @example
14
+ * isTWCard('12345678') // true
15
+ * isTWCard('07257456') // true
16
+ *
17
+ * // 一次性短期
18
+ * isTWCard('F290299977') // true
13
19
  */
14
20
 
15
21
  function isTWCard(value) {
@@ -5,6 +5,7 @@ import convertToString from './utils/convertToString';
5
5
  *
6
6
  * @static
7
7
  * @alias module:Processor.normalizeString
8
+ * @see 参考 {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances|String}
8
9
  * @since 4.3.0
9
10
  * @param {*} value 待处理的值
10
11
  * @returns {string} 规整化的值
@@ -38,38 +38,58 @@ var Provinces = [// 华北地区:北京市|110000,天津市|120000,河北
38
38
  // ['8', '港澳地区']
39
39
  // ];
40
40
 
41
+ /**
42
+ * @typedef {Object} IdCardOrigin - 解析身份证原数据
43
+ * @property {string} province - 省份编码
44
+ * @property {string} city - 城市编码
45
+ * @property {string} area - 地区编码
46
+ * @property {string} year - 出生年
47
+ * @property {string} month - 出生月
48
+ * @property {string} day - 出生日
49
+ * @property {string} gender - 性别 能整除2为女,否则为男
50
+ */
51
+
52
+ /**
53
+ * @typedef {Object} IdCardInfo - 身份证信息
54
+ * @property {string} province - 省份
55
+ * @property {string} birthday - 生日
56
+ * @property {string} gender - 性别
57
+ * @property {IdCardOrigin} origin - 解析身份证原数据
58
+ */
59
+
41
60
  /**
42
61
  * 解析身份证号码,支持15、18位身份证号码
43
- *
62
+ *
44
63
  * @static
45
64
  * @alias module:Processor.parseIdCard
46
65
  * @since 4.0.0
47
66
  * @see 参考 {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
48
67
  * @param {string} id 身份证号码,支持15位
49
- * @returns null 或 省份、生日、性别,省/市/区/年/月/日/性别编码
68
+ * @returns {null|IdCardInfo} null 或 省份、生日、性别,省/市/区/年/月/日/性别编码
50
69
  * @example
51
70
  * parseIdCard('123456789123456');
52
71
  * // => null
53
- *
72
+ *
54
73
  * // 18位身份证号码
55
74
  * parseIdCard('130701199310302288')
56
75
  * // =>
57
76
  * {
58
- birthday: "1993-10-30",
59
- gender: "女",
60
- origin: { province: "13", city: "07", area: "01", year: "1993", month: "10", day: "30", gender: "8" },
61
- province: "河北省"
62
- }
77
+ * birthday: "1993-10-30",
78
+ * gender: "女",
79
+ * origin: { province: "13", city: "07", area: "01", year: "1993", month: "10", day: "30", gender: "8" },
80
+ * province: "河北省"
81
+ * }
82
+ *
63
83
  * // 15位身份证号码
64
84
  * parseIdCard('130701931030228');
65
85
  * // =>
66
86
  * {
67
- birthday: "93-10-30",
68
- gender: "女",
69
- origin: { province: "13", city: "07", area: "01", year: "93", month: "10", day: "30", gender: "8" },
70
- province: "河北省"
71
- }
72
- *
87
+ * birthday: "93-10-30",
88
+ * gender: "女",
89
+ * origin: { province: "13", city: "07", area: "01", year: "93", month: "10", day: "30", gender: "8" },
90
+ * province: "河北省"
91
+ * }
92
+ *
73
93
  */
74
94
 
75
95
  function parseIdCard(id) {
@@ -0,0 +1,41 @@
1
+ import _construct from "@babel/runtime/helpers/construct";
2
+ import isNil from './utils/type/isNil'; // TODO: 函数重载,类型参照 Date
3
+
4
+ /**
5
+ * 创建一个 Date 实例日期对象,同 new Date() 。<br/>
6
+ * 规避了苹果设备浏览器不支持部分格式(YYYY-MM-DD HH-mm 或 YYYY.MM.DD)。
7
+ *
8
+ * @static
9
+ * @alias module:Processor.safeDate
10
+ * @see 参考 {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date|Date}
11
+ * @since 4.4.0
12
+ * @param {string|number|Date} [value] 日期时间字符串、毫秒数、日期对象
13
+ * @param {...number} args 月/日/时/分/秒/毫秒
14
+ * @returns {Date} Date 实例日期对象
15
+ * @example
16
+ * safeDate('2022-1-1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
17
+ * safeDate('2022/1/1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
18
+ * safeDate('2022.1.1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
19
+ * safeDate('2022.1.1 11:11'); // Sat Jan 01 2022 11:11:00 GMT+0800 (中国标准时间)
20
+ * safeDate(99, 1); // Mon Feb 01 1999 00:00:00 GMT+0800 (中国标准时间)
21
+ * safeDate(1646711233171); // Tue Mar 08 2022 11:47:13 GMT+0800 (中国标准时间)
22
+ *
23
+ */
24
+
25
+ function safeDate(value) {
26
+ var safeValue = typeof value === 'string' ? value.replace(/[\\.-]/g, '/') : value;
27
+
28
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
29
+ args[_key - 1] = arguments[_key];
30
+ }
31
+
32
+ if (args && args.length > 0) {
33
+ // @ts-ignore
34
+ return _construct(Date, [safeValue].concat(args));
35
+ } // @ts-ignore
36
+
37
+
38
+ return isNil(safeValue) ? new Date() : new Date(safeValue);
39
+ }
40
+
41
+ export default safeDate;
@@ -1,6 +1,5 @@
1
1
  /**
2
- * 设置 DataURL 前缀、MIME 类型、base64 标识。<br/><br/>
3
- *
2
+ * 设置 DataURL 前缀、MIME 类型、base64 标识。<br/>
4
3
  * 如果你需要获取DataURL 的 MIME 类型和数据本身,推荐使用 <a href="https://www.npmjs.com/package/data-urls">data-urls</a>。
5
4
  *
6
5
  * @static
@@ -118,6 +118,22 @@ function hasUnallowableCharacter(val) {
118
118
  });
119
119
  return ret;
120
120
  }
121
+ /**
122
+ * @typedef {Object} PasswordContaines - 验证密码的包含内容
123
+ * @property {boolean} number - 包含数字
124
+ * @property {boolean} lowerCaseLetter - 包含小写字母
125
+ * @property {boolean} upperCaseLetter - 包含大写字母
126
+ * @property {boolean} specialCharacter - 包含特殊字符
127
+ * @property {boolean} unallowableCharacter - 包含非法字符
128
+ */
129
+
130
+ /**
131
+ * @typedef {Object} ValidatePasswordReturn - 验证结果
132
+ * @property {boolean} validated - 验证结果,根据密码强度、是否包含非法字符得出
133
+ * @property {number} level - 强度级别,包含数字/大小写字母/特殊字符
134
+ * @property {PasswordContaines} containes - 包含内容
135
+ */
136
+
121
137
  /**
122
138
  * 验证密码(数字、大小写字母、特殊字符、非法字符)
123
139
  *
@@ -130,7 +146,7 @@ function hasUnallowableCharacter(val) {
130
146
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
131
147
  * @param {boolean} [options.ignoreCase=false] 是否忽略大小写,为 ture 时,大小写字母视为一种字符
132
148
  * @param {string} [options.special="!@#$%^&*()-=_+[]\|{},./?<>~"] 支持的特殊字符
133
- * @returns 验证结果
149
+ * @returns {ValidatePasswordReturn} 验证结果
134
150
  * @example
135
151
  *
136
152
  * validatePassword('a12345678');
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _normalizeString = _interopRequireDefault(require("./normalizeString"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ // ref: https://github.com/ant-design/ant-design-mobile/blob/v2/components/input-item/index.tsx#L240
13
+
14
+ /**
15
+ * 计算输入框的值格式化后光标位置
16
+ *
17
+ * @static
18
+ * @alias module:Other.calculateCursorPosition
19
+ * @since 4.6.0
20
+ * @see 格式化手机号码 {@link https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile|formatMobile}
21
+ * @see 格式化银行卡号 {@link https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard|formatBankCard}
22
+ * @see 示例 {@link https://2950v9.csb.app/|点击查看}
23
+ * @param {number} prevPos 赋值前的光标位置,onChange/onInput的光标位置 e.target.selectionEnd
24
+ * @param {string} prevCtrlValue 上一个格式化后的值
25
+ * @param {string} rawValue 当前输入原值
26
+ * @param {string} ctrlValue 当前格式化后的值
27
+ * @param {Object} [options] 配置项
28
+ * @param {string[]|string} [options.placeholderChar=' '] 占位符
29
+ * @param {RegExp} [options.maskReg=/\D/g] 需要遮盖的字符规则。默认去掉非数字,意味着 ctrlValue 需要去掉非数字。
30
+ * @param {'mobile'|'bankCard'} [options.type] 格式化类型,内置手机号码和银行卡号特殊处理
31
+ * @returns {number} 格式化后的光标位置
32
+ */
33
+ function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue) {
34
+ var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
35
+ _ref$placeholderChar = _ref.placeholderChar,
36
+ placeholderChar = _ref$placeholderChar === void 0 ? ' ' : _ref$placeholderChar,
37
+ _ref$maskReg = _ref.maskReg,
38
+ maskReg = _ref$maskReg === void 0 ? /\D/g : _ref$maskReg,
39
+ type = _ref.type;
40
+
41
+ var realCtrlValue = (0, _normalizeString["default"])(prevCtrlValue);
42
+ var realRawValue = (0, _normalizeString["default"])(rawValue);
43
+ var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
44
+ var editLength = realRawValue.length - realCtrlValue.length;
45
+ var isAddition = editLength > 0;
46
+ var pos = prevPos;
47
+
48
+ if (isAddition) {
49
+ var additionStr = realRawValue.substring(pos - editLength, pos);
50
+ var ctrlCharCount = additionStr.replace(maskReg, '').length;
51
+ pos -= editLength - ctrlCharCount;
52
+ var placeholderCharCount = 0;
53
+
54
+ while (ctrlCharCount > 0) {
55
+ if (placeholderChars.indexOf(ctrlValue.charAt(pos - ctrlCharCount + placeholderCharCount)) !== -1) {
56
+ placeholderCharCount++;
57
+ } else {
58
+ ctrlCharCount--;
59
+ }
60
+ }
61
+
62
+ pos += placeholderCharCount;
63
+ }
64
+
65
+ if (type === 'mobile' && (pos === 4 || pos === 9) || type === 'bankCard' && pos > 0 && pos % 5 === 0) {
66
+ pos -= 1;
67
+ }
68
+
69
+ return pos;
70
+ }
71
+
72
+ var _default = calculateCursorPosition;
73
+ exports["default"] = _default;
@@ -51,9 +51,8 @@ function formatBankCard() {
51
51
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
52
52
  var regChar = new RegExp("".concat(_char), 'g');
53
53
  var realValue = (0, _normalizeString["default"])(bankCardNo).replace(regChar, '');
54
- var needRemoveLastChar = realValue.length % length === 0;
55
54
  var str = realValue.replace(reg, "$1".concat(_char));
56
- return needRemoveLastChar ? str.substring(0, str.length - 1) : str;
55
+ return realValue.length % length === 0 ? str.substring(0, str.length - 1) : str;
57
56
  }
58
57
 
59
58
  var _default = formatBankCard;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _normalizeString = _interopRequireDefault(require("./normalizeString"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ /**
13
+ * 格式化手机号码
14
+ *
15
+ * @static
16
+ * @alias module:Processor.formatMobile
17
+ * @since 4.5.0
18
+ * @param {string} mobileNo 手机号码
19
+ * @param {object} [options] 配置项
20
+ * @param {string} [options.char=' '] 间隔字符
21
+ * @returns {string} 格式化后的手机号码
22
+ * @example
23
+ * formatMobile('13345678900') // '133 4567 8900'
24
+ * formatMobile('13345678900', { char: '-' }) // '133-4567-8900'
25
+ *
26
+ * // 脱敏手机号码
27
+ * formatMobile('133****1234') // '133 **** 1234'
28
+ * formatMobile('133****1234', { char: '-' }) // '133-****-1234'
29
+ *
30
+ * // 手机号码位数不够
31
+ * formatMobile('133') // '133'
32
+ * formatMobile('133456') // '133 456'
33
+ * formatMobile('13345678') // '133 4567 8'
34
+ */
35
+ function formatMobile(mobileNo) {
36
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
37
+ _ref$char = _ref["char"],
38
+ _char = _ref$char === void 0 ? ' ' : _ref$char;
39
+
40
+ var regChar = new RegExp(_char, 'g');
41
+ var realValue = (0, _normalizeString["default"])(mobileNo).replace(regChar, '').substring(0, 11);
42
+
43
+ if (realValue.length > 7) {
44
+ return realValue.replace(/^(...)(....)/g, "$1".concat(_char, "$2").concat(_char));
45
+ }
46
+
47
+ if (realValue.length > 3) {
48
+ return realValue.replace(/^(...)/g, "$1".concat(_char));
49
+ }
50
+
51
+ return realValue;
52
+ }
53
+
54
+ var _default = formatMobile;
55
+ exports["default"] = _default;
package/lib/index.js CHANGED
@@ -189,6 +189,18 @@ Object.defineProperty(exports, "normalizeString", {
189
189
  return _normalizeString["default"];
190
190
  }
191
191
  });
192
+ Object.defineProperty(exports, "safeDate", {
193
+ enumerable: true,
194
+ get: function get() {
195
+ return _safeDate["default"];
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "formatMobile", {
199
+ enumerable: true,
200
+ get: function get() {
201
+ return _formatMobile["default"];
202
+ }
203
+ });
192
204
  Object.defineProperty(exports, "plus", {
193
205
  enumerable: true,
194
206
  get: function get() {
@@ -225,6 +237,12 @@ Object.defineProperty(exports, "waitTime", {
225
237
  return _waitTime["default"];
226
238
  }
227
239
  });
240
+ Object.defineProperty(exports, "calculateCursorPosition", {
241
+ enumerable: true,
242
+ get: function get() {
243
+ return _calculateCursorPosition["default"];
244
+ }
245
+ });
228
246
  Object.defineProperty(exports, "setDisableWarning", {
229
247
  enumerable: true,
230
248
  get: function get() {
@@ -294,6 +312,10 @@ var _setDataURLPrefix = _interopRequireDefault(require("./setDataURLPrefix"));
294
312
 
295
313
  var _normalizeString = _interopRequireDefault(require("./normalizeString"));
296
314
 
315
+ var _safeDate = _interopRequireDefault(require("./safeDate"));
316
+
317
+ var _formatMobile = _interopRequireDefault(require("./formatMobile"));
318
+
297
319
  var _plus = _interopRequireDefault(require("./plus"));
298
320
 
299
321
  var _minus = _interopRequireDefault(require("./minus"));
@@ -306,6 +328,8 @@ var _round = _interopRequireDefault(require("./round"));
306
328
 
307
329
  var _waitTime = _interopRequireDefault(require("./waitTime"));
308
330
 
331
+ var _calculateCursorPosition = _interopRequireDefault(require("./calculateCursorPosition"));
332
+
309
333
  var _config = require("./utils/config");
310
334
 
311
335
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
package/lib/isHMCard.js CHANGED
@@ -20,6 +20,18 @@ var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
20
20
  * @see 参考 {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证|港澳居民来往内地通行证}
21
21
  * @param {*} value 要检测的值
22
22
  * @returns {boolean} 是否为港澳居民来往内地通行证
23
+ * @example
24
+ * // 第一代 11 位
25
+ * isHMCard('h3203117707') // true
26
+ * isHMCard('H3203117707') // true
27
+ * isHMCard('m3203117707') // true
28
+ * isHMCard('M3203117707') // true
29
+ *
30
+ * // 第二代 9 位
31
+ * isHMCard('h32031177') // true
32
+ * isHMCard('H32031177') // true
33
+ * isHMCard('m32031177') // true
34
+ * isHMCard('M32031177') // true
23
35
  */
24
36
 
25
37
  function isHMCard(value) {
package/lib/isIdCard.js CHANGED
@@ -18,7 +18,7 @@ var regIdCard = /^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|
18
18
  * @see 参考 {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码|中华人民共和国公民身份号码}
19
19
  * @see 参考 {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
20
20
  * @param {string} id 身份证号码
21
- * @returns 校验码是否正确
21
+ * @returns {boolean} 校验码是否正确
22
22
  */
23
23
 
24
24
  function check(id) {
package/lib/isTWCard.js CHANGED
@@ -20,6 +20,12 @@ var regTWCard = /^(\d{8}|[\da-z]{10})$/i;
20
20
  * @see 参考 {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证|台湾居民来往大陆通行证}
21
21
  * @param {*} value 要检测的值
22
22
  * @returns {boolean} 是否为台湾居民来往大陆通行证
23
+ * @example
24
+ * isTWCard('12345678') // true
25
+ * isTWCard('07257456') // true
26
+ *
27
+ * // 一次性短期
28
+ * isTWCard('F290299977') // true
23
29
  */
24
30
 
25
31
  function isTWCard(value) {
@@ -16,6 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
16
16
  *
17
17
  * @static
18
18
  * @alias module:Processor.normalizeString
19
+ * @see 参考 {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances|String}
19
20
  * @since 4.3.0
20
21
  * @param {*} value 待处理的值
21
22
  * @returns {string} 规整化的值