util-helpers 4.15.0 → 4.15.2

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.
@@ -24,5 +24,5 @@ function setDisableWarning(bool) {
24
24
  }
25
25
 
26
26
  // eslint-disable-next-line no-undef
27
- var version = "4.15.0";
27
+ var version = "4.15.2";
28
28
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.15.0",
3
+ "version": "4.15.2",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -10,6 +10,7 @@
10
10
  "scripts": {
11
11
  "test": "jest --verbose",
12
12
  "test:coverage": "jest --coverage",
13
+ "test:coverage:local": "cross-env COVERAGE_LOCAL=1 jest --coverage",
13
14
  "test:math": "jest --verbose test/math",
14
15
  "test:type": "jest --verbose test/type",
15
16
  "test:validator": "jest --verbose test/validator",
@@ -8,6 +8,7 @@ export default bytesToSize;
8
8
  * @param {number} bytes 字节大小
9
9
  * @param {Object} [options] 配置项
10
10
  * @param {string} [options.spaceMark=' '] 间隔字符
11
+ * @param {number} [options.precision=2] 精度
11
12
  * @returns {string} 存储单位值
12
13
  * @example
13
14
  *
@@ -23,4 +24,5 @@ export default bytesToSize;
23
24
  */
24
25
  declare function bytesToSize(bytes: number, options?: {
25
26
  spaceMark?: string | undefined;
27
+ precision?: number | undefined;
26
28
  } | undefined): string;
@@ -6,25 +6,25 @@ export default formatMoney;
6
6
  * @alias module:Processor.formatMoney
7
7
  * @since 1.1.0
8
8
  * @param {string | number} num 需转换金额 (最大:9007199254740991 最小: -9007199254740991)
9
- * @param {Object} [options] - 金额格式化配置
10
- * @param {string | number} [options.precision=2] - 保留位数 (最高:10位)
11
- * @param {string} [options.symbol] - 货币符号
12
- * @param {string} [options.thousand=","] - 千分位符号
13
- * @param {string} [options.decimal="."] - 小数位符号
9
+ * @param {Object} [options] 金额格式化配置
10
+ * @param {number} [options.precision=2] 保留位数 (最高:10位)
11
+ * @param {string} [options.symbol] 货币符号
12
+ * @param {string} [options.thousand=","] 千分位符号
13
+ * @param {string} [options.decimal="."] 小数位符号
14
14
  * @returns {string} 格式化的金额
15
15
  * @example
16
16
  *
17
17
  * // 整数
18
- * formatMoney('1000'); // 1,000.00
18
+ * formatMoney(1000); // 1,000.00
19
19
  *
20
20
  * // 小数(默认保留2位小数)
21
- * formatMoney('3000.03'); // 3,000.03
21
+ * formatMoney(3000.03); // 3,000.03
22
22
  *
23
23
  * // 保留4位小数
24
- * formatMoney('3000.0300', { precision: 4 }); // 3,000.0300
24
+ * formatMoney(3000.03, { precision: 4 }); // 3,000.0300
25
25
  *
26
26
  * // 保留10位小数
27
- * formatMoney('1500.2', { precision: 10 }); // 1,500.2000000000
27
+ * formatMoney(1500.2, { precision: 10 }); // 1,500.2000000000
28
28
  *
29
29
  * // 自定义单位符号
30
30
  * formatMoney(1000.00, { symbol: '$' }); // $1,000.00
@@ -35,9 +35,11 @@ export default formatMoney;
35
35
  * // 自定义小数位分割符(默认'.')
36
36
  * formatMoney(1000.00, { decimal: '&' }); // 1,000&00
37
37
  *
38
+ * // 字符串数字
39
+ * formatMoney('3000.03', { precision: 4 }); // 3,000.0300
38
40
  */
39
41
  declare function formatMoney(num: string | number, options?: {
40
- precision?: string | number | undefined;
42
+ precision?: number | undefined;
41
43
  symbol?: string | undefined;
42
44
  thousand?: string | undefined;
43
45
  decimal?: string | undefined;
@@ -8,7 +8,7 @@ export default listToTree;
8
8
  * @template {Record<string,any>} [T=Record<string,any>]
9
9
  * @template {*} [R=T&Record<string,any>]
10
10
  * @param {T[]} list 列表数据
11
- * @param {object} options 配置项
11
+ * @param {object} [options] 配置项
12
12
  * @param {string} [options.keyField='id'] 当前数据的键值字段名称
13
13
  * @param {string} [options.parentField='pid'] 当前数据的父级字段名称
14
14
  * @param {string} [options.childrenField='children'] 子级字段名称
@@ -40,4 +40,4 @@ declare function listToTree<T extends Record<string, any> = Record<string, any>,
40
40
  childrenField?: string | undefined;
41
41
  emptyChildrenValue?: "none" | "null" | "array" | undefined;
42
42
  nodeAssign?: "spread" | "self" | undefined;
43
- }): R[];
43
+ } | undefined): R[];