ph-utils 0.2.18 → 0.2.19
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/lib/index.js +4 -4
- package/lib/index_m.js +4 -4
- package/lib/validator.d.ts +1 -1
- package/lib/validator.js +1 -1
- package/lib/validator_m.d.ts +1 -1
- package/lib/validator_m.js +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
@@ -22,14 +22,14 @@ exports.isBlank = isBlank;
|
|
22
22
|
* @returns 屏蔽后的手机号,例如:123 **** 1234
|
23
23
|
*/
|
24
24
|
function shieldMobile(mobile) {
|
25
|
-
let x1 = Math.
|
26
|
-
let x2 = Math.
|
25
|
+
let x1 = Math.floor(mobile.length / 2);
|
26
|
+
let x2 = Math.ceil(x1 / 2);
|
27
27
|
let shields = [' '];
|
28
|
-
for (let i = 0; i < x1; i++) {
|
28
|
+
for (let i = 0; i < x1 - 1; i++) {
|
29
29
|
shields.push('*');
|
30
30
|
}
|
31
31
|
shields.push(' ');
|
32
|
-
return mobile.substring(0, x2) + shields.join('') + mobile.substring(x2 + x1);
|
32
|
+
return (mobile.substring(0, x2) + shields.join('') + mobile.substring(x2 + x1 - 1));
|
33
33
|
}
|
34
34
|
exports.shieldMobile = shieldMobile;
|
35
35
|
/**
|
package/lib/index_m.js
CHANGED
@@ -18,14 +18,14 @@ export function isBlank(str, ignoreWhitespace = true) {
|
|
18
18
|
* @returns 屏蔽后的手机号,例如:123 **** 1234
|
19
19
|
*/
|
20
20
|
export function shieldMobile(mobile) {
|
21
|
-
let x1 = Math.
|
22
|
-
let x2 = Math.
|
21
|
+
let x1 = Math.floor(mobile.length / 2);
|
22
|
+
let x2 = Math.ceil(x1 / 2);
|
23
23
|
let shields = [' '];
|
24
|
-
for (let i = 0; i < x1; i++) {
|
24
|
+
for (let i = 0; i < x1 - 1; i++) {
|
25
25
|
shields.push('*');
|
26
26
|
}
|
27
27
|
shields.push(' ');
|
28
|
-
return mobile.substring(0, x2) + shields.join('') + mobile.substring(x2 + x1);
|
28
|
+
return (mobile.substring(0, x2) + shields.join('') + mobile.substring(x2 + x1 - 1));
|
29
29
|
}
|
30
30
|
/**
|
31
31
|
* 验证参数是否是数字
|
package/lib/validator.d.ts
CHANGED
package/lib/validator.js
CHANGED
package/lib/validator_m.d.ts
CHANGED
package/lib/validator_m.js
CHANGED