tools-min-ns 1.9.12 → 1.10.1

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 CHANGED
@@ -5,6 +5,12 @@ cnpm i tools-min-ns --save
5
5
  ```
6
6
 
7
7
  # updates
8
+ ## v1.10.1
9
+ > TransferUtil
10
+ getFileSizeByBytes修复参数n
11
+ ## v1.10.0
12
+ > ExtractUtil
13
+ 提取工具,文本中提取手机号、身份证
8
14
  ## v1.9.12
9
15
  > RequestUtil
10
16
  mgopRequest 请求失败后端回调不显示
@@ -0,0 +1,5 @@
1
+ declare namespace ExtractUtil {
2
+ const mobile: (text: string) => string[] | undefined;
3
+ const idCard: (text: string) => string[] | undefined;
4
+ }
5
+ export default ExtractUtil;
@@ -0,0 +1,23 @@
1
+ import CheckUtil from '../check/CheckUtil';
2
+ var ExtractUtil;
3
+ (function (ExtractUtil) {
4
+ ExtractUtil.mobile = function (text) {
5
+ // 定义一个匹配手机号的正则表达式
6
+ var regex = /\b\d{11}\b/g;
7
+ // 使用正则表达式查找所有匹配的手机号
8
+ var matches = text.match(regex);
9
+ return matches === null || matches === void 0 ? void 0 : matches.filter(function (e) {
10
+ return CheckUtil.phoneIsValid(e);
11
+ });
12
+ };
13
+ ExtractUtil.idCard = function (text) {
14
+ // 定义一个匹配手机号的正则表达式
15
+ var regex = /\b\d{18}\b/g;
16
+ // 使用正则表达式查找所有匹配的手机号
17
+ var matches = text.match(regex);
18
+ return matches === null || matches === void 0 ? void 0 : matches.filter(function (e) {
19
+ return CheckUtil.idcardIsValid(e);
20
+ });
21
+ };
22
+ })(ExtractUtil || (ExtractUtil = {}));
23
+ export default ExtractUtil;
package/esm/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export { default as SystemUtil } from './system/SystemUtil';
17
17
  export { default as MapTransferUtil } from './transfer/MapTransferUtil';
18
18
  export { default as TransferUtil } from './transfer/TransferUtil';
19
19
  export { default as UrlUtil } from './url/UrlUtil';
20
+ export { default as ExtractUtil } from './extract/ExtractUtil';
package/esm/index.js CHANGED
@@ -16,4 +16,5 @@ export { default as StringUtil } from './string/StringUtil';
16
16
  export { default as SystemUtil } from './system/SystemUtil';
17
17
  export { default as MapTransferUtil } from './transfer/MapTransferUtil';
18
18
  export { default as TransferUtil } from './transfer/TransferUtil';
19
- export { default as UrlUtil } from './url/UrlUtil';
19
+ export { default as UrlUtil } from './url/UrlUtil';
20
+ export { default as ExtractUtil } from './extract/ExtractUtil';
@@ -92,7 +92,8 @@ declare namespace TransferUtil {
92
92
  /**
93
93
  * 字节转单位
94
94
  * @param bytes - 字节
95
+ * @param n - 保留小数默认2
95
96
  */
96
- const getFileSizeByBytes: (bytes: number) => string;
97
+ const getFileSizeByBytes: (bytes: number, n: number) => string;
97
98
  }
98
99
  export default TransferUtil;
@@ -4,6 +4,7 @@
4
4
  * @author nanshen
5
5
  * @creat 2021-09-15 14:40:07
6
6
  */
7
+ import NumberUtil from 'src/number/NumberUtil';
7
8
  import BaseUtil from '../base/BaseUtil';
8
9
  var TransferUtil;
9
10
  (function (TransferUtil) {
@@ -307,8 +308,9 @@ var TransferUtil;
307
308
  /**
308
309
  * 字节转单位
309
310
  * @param bytes - 字节
311
+ * @param n - 保留小数默认2
310
312
  */
311
- TransferUtil.getFileSizeByBytes = function (bytes) {
313
+ TransferUtil.getFileSizeByBytes = function (bytes, n) {
312
314
  var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
313
315
  if (bytes === 0) {
314
316
  return '0B';
@@ -317,7 +319,7 @@ var TransferUtil;
317
319
  if (i === 0) {
318
320
  return bytes + sizes[i];
319
321
  }
320
- return (bytes / Math.pow(1024, i)).toFixed(2) + sizes[i];
322
+ return NumberUtil.correctNumberInput(bytes / Math.pow(1024, i), n) + sizes[i];
321
323
  };
322
324
  })(TransferUtil || (TransferUtil = {}));
323
325
  export default TransferUtil;
@@ -0,0 +1,5 @@
1
+ declare namespace ExtractUtil {
2
+ const mobile: (text: string) => string[] | undefined;
3
+ const idCard: (text: string) => string[] | undefined;
4
+ }
5
+ export default ExtractUtil;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ var CheckUtil_1 = __importDefault(require("../check/CheckUtil"));
12
+ var ExtractUtil;
13
+ (function (ExtractUtil) {
14
+ ExtractUtil.mobile = function (text) {
15
+ // 定义一个匹配手机号的正则表达式
16
+ var regex = /\b\d{11}\b/g;
17
+ // 使用正则表达式查找所有匹配的手机号
18
+ var matches = text.match(regex);
19
+ return matches === null || matches === void 0 ? void 0 : matches.filter(function (e) {
20
+ return CheckUtil_1.default.phoneIsValid(e);
21
+ });
22
+ };
23
+ ExtractUtil.idCard = function (text) {
24
+ // 定义一个匹配手机号的正则表达式
25
+ var regex = /\b\d{18}\b/g;
26
+ // 使用正则表达式查找所有匹配的手机号
27
+ var matches = text.match(regex);
28
+ return matches === null || matches === void 0 ? void 0 : matches.filter(function (e) {
29
+ return CheckUtil_1.default.idcardIsValid(e);
30
+ });
31
+ };
32
+ })(ExtractUtil || (ExtractUtil = {}));
33
+ exports.default = ExtractUtil;
package/lib/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export { default as SystemUtil } from './system/SystemUtil';
17
17
  export { default as MapTransferUtil } from './transfer/MapTransferUtil';
18
18
  export { default as TransferUtil } from './transfer/TransferUtil';
19
19
  export { default as UrlUtil } from './url/UrlUtil';
20
+ export { default as ExtractUtil } from './extract/ExtractUtil';
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
8
8
  Object.defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
- exports.UrlUtil = exports.TransferUtil = exports.MapTransferUtil = exports.SystemUtil = exports.StringUtil = exports.StorageUtil = exports.RequestUtil = exports.PasswordUtil = exports.ObjectUtil = exports.NumberUtil = exports.FunctionUtil = exports.EnvUtil = exports.DateUtil = exports.CookieUtil = exports.CheckUtil = exports.BrowserUtil = exports.BaseUtil = exports.TreeUtil = exports.ArrayUtil = void 0;
11
+ exports.ExtractUtil = exports.UrlUtil = exports.TransferUtil = exports.MapTransferUtil = exports.SystemUtil = exports.StringUtil = exports.StorageUtil = exports.RequestUtil = exports.PasswordUtil = exports.ObjectUtil = exports.NumberUtil = exports.FunctionUtil = exports.EnvUtil = exports.DateUtil = exports.CookieUtil = exports.CheckUtil = exports.BrowserUtil = exports.BaseUtil = exports.TreeUtil = exports.ArrayUtil = void 0;
12
12
  var ArrayUtil_1 = require("./array/ArrayUtil");
13
13
  Object.defineProperty(exports, "ArrayUtil", {
14
14
  enumerable: true,
@@ -141,4 +141,11 @@ Object.defineProperty(exports, "UrlUtil", {
141
141
  get: function get() {
142
142
  return __importDefault(UrlUtil_1).default;
143
143
  }
144
+ });
145
+ var ExtractUtil_1 = require("./extract/ExtractUtil");
146
+ Object.defineProperty(exports, "ExtractUtil", {
147
+ enumerable: true,
148
+ get: function get() {
149
+ return __importDefault(ExtractUtil_1).default;
150
+ }
144
151
  });
@@ -92,7 +92,8 @@ declare namespace TransferUtil {
92
92
  /**
93
93
  * 字节转单位
94
94
  * @param bytes - 字节
95
+ * @param n - 保留小数默认2
95
96
  */
96
- const getFileSizeByBytes: (bytes: number) => string;
97
+ const getFileSizeByBytes: (bytes: number, n: number) => string;
97
98
  }
98
99
  export default TransferUtil;
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  * @author nanshen
15
15
  * @creat 2021-09-15 14:40:07
16
16
  */
17
+ var NumberUtil_1 = __importDefault(require("src/number/NumberUtil"));
17
18
  var BaseUtil_1 = __importDefault(require("../base/BaseUtil"));
18
19
  var TransferUtil;
19
20
  (function (TransferUtil) {
@@ -317,8 +318,9 @@ var TransferUtil;
317
318
  /**
318
319
  * 字节转单位
319
320
  * @param bytes - 字节
321
+ * @param n - 保留小数默认2
320
322
  */
321
- TransferUtil.getFileSizeByBytes = function (bytes) {
323
+ TransferUtil.getFileSizeByBytes = function (bytes, n) {
322
324
  var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
323
325
  if (bytes === 0) {
324
326
  return '0B';
@@ -327,7 +329,7 @@ var TransferUtil;
327
329
  if (i === 0) {
328
330
  return bytes + sizes[i];
329
331
  }
330
- return (bytes / Math.pow(1024, i)).toFixed(2) + sizes[i];
332
+ return NumberUtil_1.default.correctNumberInput(bytes / Math.pow(1024, i), n) + sizes[i];
331
333
  };
332
334
  })(TransferUtil || (TransferUtil = {}));
333
335
  exports.default = TransferUtil;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tools-min-ns",
3
3
  "description": "工具包适用于前端以及node",
4
- "version": "1.9.12",
4
+ "version": "1.10.1",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",
7
7
  "author": "nanshen",