@daysnap/utils 0.0.71 → 0.0.73

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.
@@ -21,7 +21,7 @@ export function createWithLoading(showLoading, defaultOptions) {
21
21
  }
22
22
  const toast = options ? showLoading(options) : null;
23
23
  try {
24
- return yield fn(params);
24
+ return yield fn(...params);
25
25
  // eslint-disable-next-line no-useless-catch
26
26
  }
27
27
  catch (error) {
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * 格式化金额,默认元
3
3
  */
4
- export declare function formatAmount(s: string | number, radix?: number): string;
4
+ export declare function formatAmount(s: string | number, radix?: number, digits?: number): string;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * 格式化金额,默认元
3
3
  */
4
- export function formatAmount(s, radix = 1) {
4
+ export function formatAmount(s, radix = 1, digits = 2) {
5
5
  const money = parseFloat(s === null || s === void 0 ? void 0 : s.toString());
6
6
  if (money) {
7
7
  // eslint-disable-next-line no-param-reassign
8
- s = `${(money / radix).toFixed(2)}`;
8
+ s = `${(money / radix).toFixed(digits)}`;
9
9
  const l = s.split('.')[0].split('').reverse();
10
10
  const r = s.split('.')[1];
11
11
  let t = '';
@@ -24,7 +24,7 @@ function createWithLoading(showLoading, defaultOptions) {
24
24
  }
25
25
  const toast = options ? showLoading(options) : null;
26
26
  try {
27
- return yield fn(params);
27
+ return yield fn(...params);
28
28
  // eslint-disable-next-line no-useless-catch
29
29
  }
30
30
  catch (error) {
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * 格式化金额,默认元
3
3
  */
4
- export declare function formatAmount(s: string | number, radix?: number): string;
4
+ export declare function formatAmount(s: string | number, radix?: number, digits?: number): string;
@@ -4,11 +4,11 @@ exports.formatAmount = void 0;
4
4
  /**
5
5
  * 格式化金额,默认元
6
6
  */
7
- function formatAmount(s, radix = 1) {
7
+ function formatAmount(s, radix = 1, digits = 2) {
8
8
  const money = parseFloat(s === null || s === void 0 ? void 0 : s.toString());
9
9
  if (money) {
10
10
  // eslint-disable-next-line no-param-reassign
11
- s = `${(money / radix).toFixed(2)}`;
11
+ s = `${(money / radix).toFixed(digits)}`;
12
12
  const l = s.split('.')[0].split('').reverse();
13
13
  const r = s.split('.')[1];
14
14
  let t = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "通用的工具库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",