@zjlab-fe/util 0.2.10 → 0.2.11

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
@@ -3,6 +3,16 @@
3
3
  ### 格式化展示数字
4
4
 
5
5
  ```javascript
6
+ type formatNumberReturnType<T> = T extends {
7
+ locale?: string;
8
+ precision?: number;
9
+ showByte?: boolean;
10
+ splitUnit: true;
11
+ } ? {
12
+ num: string;
13
+ unit: string;
14
+ } : string;
15
+
6
16
  /**
7
17
  * 格式化展示数字,例如:格式化展示文件大小/存储空间大小,或者格式化展示统计个数/次数/条数(纯数字格式化展示)
8
18
  * 格式化规则如下:
@@ -15,15 +25,15 @@
15
25
  * @param options.showByte {boolean} 可选,是否是展示字节单位,默认是false
16
26
  * @param options.splitUnit {boolean} 可选,是否分离出单位,默认是false,如果为true,则返回{ num: string; unit: string }
17
27
  */
18
- export declare function formatNumber(total: number, options?: {
28
+ export declare function formatNumber<T extends {
19
29
  locale?: string;
20
30
  precision?: number;
21
31
  showByte?: boolean;
22
32
  splitUnit?: boolean;
23
- }): string | {
24
- num: string;
25
- unit: string;
26
- };
33
+ }>(total: number, options?: T): formatNumberReturnType<T>;
34
+
35
+
36
+
27
37
  ```
28
38
 
29
39
  ### 下载文件
@@ -1,3 +1,12 @@
1
+ type formatNumberReturnType<T> = T extends {
2
+ locale?: string;
3
+ precision?: number;
4
+ showByte?: boolean;
5
+ splitUnit: true;
6
+ } ? {
7
+ num: string;
8
+ unit: string;
9
+ } : string;
1
10
  /**
2
11
  * 格式化展示数字,例如:格式化展示文件大小/存储空间大小,或者格式化展示统计个数/次数/条数(纯数字格式化展示)
3
12
  * 格式化规则如下:
@@ -10,15 +19,12 @@
10
19
  * @param options.showByte {boolean} 可选,是否是展示字节单位,默认是false
11
20
  * @param options.splitUnit {boolean} 可选,是否分离出单位,默认是false,如果为true,则返回{ num: string; unit: string }
12
21
  */
13
- export declare function formatNumber(total: number, options?: {
22
+ export declare function formatNumber<T extends {
14
23
  locale?: string;
15
24
  precision?: number;
16
25
  showByte?: boolean;
17
26
  splitUnit?: boolean;
18
- }): string | {
19
- num: string;
20
- unit: string;
21
- };
27
+ }>(total: number, options?: T): formatNumberReturnType<T>;
22
28
  /**
23
29
  * 下载文件
24
30
  * @param url {string} 文件url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zjlab-fe/util",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",