ph-utils 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
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.round(mobile.length / 2);
26
- let x2 = Math.round(x1 / 2);
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.round(mobile.length / 2);
22
- let x2 = Math.round(x1 / 2);
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
  * 验证参数是否是数字
@@ -29,7 +29,7 @@ declare class Validator {
29
29
  */
30
30
  constructor(schemas: SchemaType[]);
31
31
  /**
32
- * 进行数据验证,同时根据 type 进行数据类型转换
32
+ * 进行数据验证
33
33
  * @param data 待验证的数据
34
34
  * @returns
35
35
  */
package/lib/validator.js CHANGED
@@ -94,7 +94,7 @@ class Validator {
94
94
  this.rules = parsedRules;
95
95
  }
96
96
  /**
97
- * 进行数据验证,同时根据 type 进行数据类型转换
97
+ * 进行数据验证
98
98
  * @param data 待验证的数据
99
99
  * @returns
100
100
  */
@@ -29,7 +29,7 @@ declare class Validator {
29
29
  */
30
30
  constructor(schemas: SchemaType[]);
31
31
  /**
32
- * 进行数据验证,同时根据 type 进行数据类型转换
32
+ * 进行数据验证
33
33
  * @param data 待验证的数据
34
34
  * @returns
35
35
  */
@@ -90,7 +90,7 @@ class Validator {
90
90
  this.rules = parsedRules;
91
91
  }
92
92
  /**
93
- * 进行数据验证,同时根据 type 进行数据类型转换
93
+ * 进行数据验证
94
94
  * @param data 待验证的数据
95
95
  * @returns
96
96
  */
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index_m.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "browser": "lib/index_m.js",
8
- "version": "0.2.18",
8
+ "version": "0.2.19",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https//gitee.com/towardly/ph.git",