@oeos-components/utils 0.0.5 → 0.0.7

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/dist/index.cjs CHANGED
@@ -15,21 +15,27 @@ const isStringNumber = (val) => {
15
15
  };
16
16
  const isNumber = (val) => typeof val === "number";
17
17
  function $toast(message, type = "success", otherParams = {}) {
18
- const map = {
18
+ const typeMap = {
19
19
  s: "success",
20
20
  i: "info",
21
21
  e: "error",
22
22
  w: "warning"
23
23
  };
24
- if (getType(message) === "object") {
25
- if (message.clodeAll) {
24
+ function isShortType(t) {
25
+ return ["s", "i", "e", "w"].includes(t);
26
+ }
27
+ function isToastOptions(obj) {
28
+ return typeof obj === "object" && obj !== null;
29
+ }
30
+ if (isToastOptions(message)) {
31
+ if (message.closeAll) {
26
32
  elementPlus.ElMessage.closeAll();
27
33
  }
28
34
  elementPlus.ElMessage(message);
29
35
  return;
30
36
  }
31
- if (getType(type) === "object") {
32
- if (type.clodeAll) {
37
+ if (isToastOptions(type)) {
38
+ if (type.closeAll) {
33
39
  elementPlus.ElMessage.closeAll();
34
40
  }
35
41
  elementPlus.ElMessage({
@@ -42,9 +48,10 @@ function $toast(message, type = "success", otherParams = {}) {
42
48
  if (otherParams.closeAll) {
43
49
  elementPlus.ElMessage.closeAll();
44
50
  }
51
+ const resolvedType = isShortType(type) ? typeMap[type] : type;
45
52
  elementPlus.ElMessage({
46
53
  message,
47
- type: map[type] || type,
54
+ type: resolvedType,
48
55
  ...otherParams
49
56
  });
50
57
  }
@@ -152,32 +159,38 @@ function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF
152
159
  });
153
160
  });
154
161
  }
155
- function isEmpty(data) {
162
+ function isEmpty(data, strict = false) {
156
163
  if (reactivity.isRef(data)) {
157
164
  data = reactivity.unref(data);
158
165
  }
166
+ if (strict) {
167
+ if (data === false || data === 0 || data === BigInt(0)) {
168
+ return false;
169
+ }
170
+ }
171
+ if (data == null) return true;
159
172
  if (data instanceof Date) {
160
173
  return isNaN(data.getTime());
161
174
  }
162
175
  switch (typeof data) {
163
- case "undefined":
164
- return true;
165
176
  case "string":
166
- if (data.trim().length === 0) return true;
167
- break;
177
+ return data.trim().length === 0;
168
178
  case "boolean":
169
- if (!data) return true;
170
- break;
179
+ return !data;
171
180
  case "number":
172
- if (0 === data) return true;
173
- break;
174
- case "object":
175
- if (null === data) return true;
176
- if (void 0 !== data.length && data.length === 0) return true;
177
- for (var k in data) {
178
- return false;
179
- }
180
- return true;
181
+ return 0 === data || isNaN(data);
182
+ // ❗ `NaN`或者0 被认为是空
183
+ case "symbol":
184
+ return false;
185
+ case "bigint":
186
+ return data === BigInt(0);
187
+ }
188
+ if (data instanceof Map || data instanceof Set) return data.size === 0;
189
+ if (Array.isArray(data) || typeof data.length === "number" && Object.prototype.toString.call(data) === "[object Object]") {
190
+ return data.length === 0;
191
+ }
192
+ if (typeof data === "object") {
193
+ return Object.keys(data).length === 0;
181
194
  }
182
195
  return false;
183
196
  }
@@ -631,23 +644,24 @@ function toFixed(value, options = {}) {
631
644
  }
632
645
  return `${prefix}${res}${finalUnit}${suffix}`;
633
646
  }
634
- function formatBytes(bytes, { toFixed: toFixed2 = 2, thousands = true } = {}) {
647
+ function formatBytes(bytes, options = {}) {
648
+ let { digit = 2, thousands = true, prefix = "", suffix = "" } = options;
635
649
  if (isStringNumber(bytes) || isNumber(bytes)) {
636
650
  bytes = Number(bytes);
637
651
  } else {
638
652
  return bytes;
639
653
  }
640
654
  if (bytes <= 0) {
641
- return bytes.toFixed(toFixed2) + " B";
655
+ return bytes.toFixed(digit) + " B";
642
656
  }
643
657
  const k = 1024;
644
658
  const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
645
659
  const i = Math.floor(Math.log(bytes) / Math.log(k));
646
- let res = (bytes / Math.pow(k, i)).toFixed(toFixed2) + " " + sizes[i];
660
+ let res = (bytes / Math.pow(k, i)).toFixed(digit) + " " + sizes[i];
647
661
  if (thousands) {
648
662
  res = formatThousands(res);
649
663
  }
650
- return res;
664
+ return `${prefix}${res}${suffix}`;
651
665
  }
652
666
  function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 } = {}) {
653
667
  if (isStringNumber(oBytes) || isNumber(oBytes) || getType(oBytes) !== "string") {
@@ -692,7 +706,7 @@ function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 }
692
706
  }
693
707
  let finalRes = size * units[unit];
694
708
  if (toFixed2) {
695
- finalRes = parseFloat(finalRes.toFixed(toFixed2));
709
+ finalRes = Number(finalRes).toFixed(toFixed2);
696
710
  }
697
711
  if (thounsand) {
698
712
  finalRes = formatThousands(finalRes);
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as element_plus from 'element-plus';
2
+ import { ElMessageOptions } from 'element-plus';
2
3
  import { Ref } from '@vue/reactivity';
3
4
 
4
5
  /**
@@ -39,8 +40,9 @@ declare const isStringNumber: (val: string) => boolean;
39
40
  declare const isNumber: (val: any) => val is number;
40
41
  /**
41
42
  * @example1
42
- proxy.$toast('保存成功')
43
+ proxy.$toast('保存成功') // s:success; i: info; w: warning; e: error;
43
44
  proxy.$toast('保存失败', 'e')
45
+ proxy.$toast('永不关闭', {duration: 0})
44
46
  proxy.$toast({
45
47
  message: 'andy',
46
48
  type: 'warning',
@@ -56,7 +58,13 @@ declare const isNumber: (val: any) => val is number;
56
58
  duration: 5000,
57
59
  })
58
60
  */
59
- declare function $toast(message: any, type?: string | object, otherParams?: object): void;
61
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
62
+ type ShortType = 's' | 'i' | 'e' | 'w';
63
+ type ToastType = MessageType | ShortType;
64
+ type ToastOptions = Partial<ElMessageOptions> & {
65
+ closeAll?: boolean;
66
+ };
67
+ declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
60
68
  declare namespace $toast {
61
69
  var success: (message: any, otherParams?: {}) => void;
62
70
  var info: (message: any, otherParams?: {}) => void;
@@ -76,6 +84,16 @@ declare function getStorage(data: any, isSession?: boolean): string | null;
76
84
  * clearStorage({ exclude: ['loginId', 'token'] })
77
85
  */
78
86
  declare function clearStorage(str?: string | [] | object): void;
87
+ /**
88
+ * element-plus的form表单使用promise进行封装
89
+ * @param ref
90
+ * @param param1
91
+ * @returns Promise
92
+ * await proxy.validForm(formRef);
93
+ * await proxy.validForm(formRef, {message: '自定义错误'});
94
+ * await proxy.validForm(formRef, {showMessage: false});
95
+ * await proxy.validForm(formRef, {detail: true});
96
+ */
79
97
  declare function validForm(ref: any, { message, detail, showMessage }?: {
80
98
  message?: string | undefined;
81
99
  detail?: boolean | undefined;
@@ -83,9 +101,9 @@ declare function validForm(ref: any, { message, detail, showMessage }?: {
83
101
  }): Promise<unknown>;
84
102
  /**
85
103
  * 判断变量是否空值
86
- * undefined, null, '', ' ', false, 0, [], {} 均返回true,否则返回false
104
+ * undefined, null, '', ' ', false, 0, [], {}, NaN, new Set(), new Map(), BigInt(0), new Date('无效日期') 均返回true,否则返回false
87
105
  */
88
- declare function isEmpty(data: any): boolean;
106
+ declare function isEmpty(data: any, strict?: boolean): boolean;
89
107
  declare function notEmpty(v: any): boolean;
90
108
  /**
91
109
  * 将两个对象合并, 以第二个对象为准, 如果两个对象, 一个属性有值, 一个没值, 合并后有值; 如果两个属性都有值, 以第二个属性为准
@@ -258,12 +276,26 @@ declare function toFixed(value: any, options?: {
258
276
  /**
259
277
  * 只有对正整数或者字符串正整数才进行单位的转换,
260
278
  * 否则返回原始数据
279
+ * @example
280
+ * proxy.formatBytes(536870912) // 512MB
261
281
  * proxy.formatBytes(536870912) // 512MB
262
282
  */
263
- declare function formatBytes(bytes: any, { toFixed, thousands }?: {
264
- toFixed?: number | undefined;
265
- thousands?: boolean | undefined;
266
- }): any;
283
+ declare function formatBytes(bytes: any, options?: {
284
+ digit?: number;
285
+ thousands?: boolean;
286
+ prefix?: string;
287
+ suffix?: string;
288
+ } | number): any;
289
+ /**
290
+ * 字节转数字
291
+ * @param oBytes
292
+ * @param param1
293
+ * @returns number
294
+ * formatBytesConvert('0.5GB') 536870912
295
+ * formatBytesConvert('1,234 GB') 1324997410816
296
+ * formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
297
+ * formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
298
+ */
267
299
  declare function formatBytesConvert(oBytes: any, { thounsand, toFixed }?: {
268
300
  thounsand?: boolean | undefined;
269
301
  toFixed?: number | undefined;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as element_plus from 'element-plus';
2
+ import { ElMessageOptions } from 'element-plus';
2
3
  import { Ref } from '@vue/reactivity';
3
4
 
4
5
  /**
@@ -39,8 +40,9 @@ declare const isStringNumber: (val: string) => boolean;
39
40
  declare const isNumber: (val: any) => val is number;
40
41
  /**
41
42
  * @example1
42
- proxy.$toast('保存成功')
43
+ proxy.$toast('保存成功') // s:success; i: info; w: warning; e: error;
43
44
  proxy.$toast('保存失败', 'e')
45
+ proxy.$toast('永不关闭', {duration: 0})
44
46
  proxy.$toast({
45
47
  message: 'andy',
46
48
  type: 'warning',
@@ -56,7 +58,13 @@ declare const isNumber: (val: any) => val is number;
56
58
  duration: 5000,
57
59
  })
58
60
  */
59
- declare function $toast(message: any, type?: string | object, otherParams?: object): void;
61
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
62
+ type ShortType = 's' | 'i' | 'e' | 'w';
63
+ type ToastType = MessageType | ShortType;
64
+ type ToastOptions = Partial<ElMessageOptions> & {
65
+ closeAll?: boolean;
66
+ };
67
+ declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
60
68
  declare namespace $toast {
61
69
  var success: (message: any, otherParams?: {}) => void;
62
70
  var info: (message: any, otherParams?: {}) => void;
@@ -76,6 +84,16 @@ declare function getStorage(data: any, isSession?: boolean): string | null;
76
84
  * clearStorage({ exclude: ['loginId', 'token'] })
77
85
  */
78
86
  declare function clearStorage(str?: string | [] | object): void;
87
+ /**
88
+ * element-plus的form表单使用promise进行封装
89
+ * @param ref
90
+ * @param param1
91
+ * @returns Promise
92
+ * await proxy.validForm(formRef);
93
+ * await proxy.validForm(formRef, {message: '自定义错误'});
94
+ * await proxy.validForm(formRef, {showMessage: false});
95
+ * await proxy.validForm(formRef, {detail: true});
96
+ */
79
97
  declare function validForm(ref: any, { message, detail, showMessage }?: {
80
98
  message?: string | undefined;
81
99
  detail?: boolean | undefined;
@@ -83,9 +101,9 @@ declare function validForm(ref: any, { message, detail, showMessage }?: {
83
101
  }): Promise<unknown>;
84
102
  /**
85
103
  * 判断变量是否空值
86
- * undefined, null, '', ' ', false, 0, [], {} 均返回true,否则返回false
104
+ * undefined, null, '', ' ', false, 0, [], {}, NaN, new Set(), new Map(), BigInt(0), new Date('无效日期') 均返回true,否则返回false
87
105
  */
88
- declare function isEmpty(data: any): boolean;
106
+ declare function isEmpty(data: any, strict?: boolean): boolean;
89
107
  declare function notEmpty(v: any): boolean;
90
108
  /**
91
109
  * 将两个对象合并, 以第二个对象为准, 如果两个对象, 一个属性有值, 一个没值, 合并后有值; 如果两个属性都有值, 以第二个属性为准
@@ -258,12 +276,26 @@ declare function toFixed(value: any, options?: {
258
276
  /**
259
277
  * 只有对正整数或者字符串正整数才进行单位的转换,
260
278
  * 否则返回原始数据
279
+ * @example
280
+ * proxy.formatBytes(536870912) // 512MB
261
281
  * proxy.formatBytes(536870912) // 512MB
262
282
  */
263
- declare function formatBytes(bytes: any, { toFixed, thousands }?: {
264
- toFixed?: number | undefined;
265
- thousands?: boolean | undefined;
266
- }): any;
283
+ declare function formatBytes(bytes: any, options?: {
284
+ digit?: number;
285
+ thousands?: boolean;
286
+ prefix?: string;
287
+ suffix?: string;
288
+ } | number): any;
289
+ /**
290
+ * 字节转数字
291
+ * @param oBytes
292
+ * @param param1
293
+ * @returns number
294
+ * formatBytesConvert('0.5GB') 536870912
295
+ * formatBytesConvert('1,234 GB') 1324997410816
296
+ * formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
297
+ * formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
298
+ */
267
299
  declare function formatBytesConvert(oBytes: any, { thounsand, toFixed }?: {
268
300
  thounsand?: boolean | undefined;
269
301
  toFixed?: number | undefined;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as element_plus from 'element-plus';
2
+ import { ElMessageOptions } from 'element-plus';
2
3
  import { Ref } from '@vue/reactivity';
3
4
 
4
5
  /**
@@ -39,8 +40,9 @@ declare const isStringNumber: (val: string) => boolean;
39
40
  declare const isNumber: (val: any) => val is number;
40
41
  /**
41
42
  * @example1
42
- proxy.$toast('保存成功')
43
+ proxy.$toast('保存成功') // s:success; i: info; w: warning; e: error;
43
44
  proxy.$toast('保存失败', 'e')
45
+ proxy.$toast('永不关闭', {duration: 0})
44
46
  proxy.$toast({
45
47
  message: 'andy',
46
48
  type: 'warning',
@@ -56,7 +58,13 @@ declare const isNumber: (val: any) => val is number;
56
58
  duration: 5000,
57
59
  })
58
60
  */
59
- declare function $toast(message: any, type?: string | object, otherParams?: object): void;
61
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
62
+ type ShortType = 's' | 'i' | 'e' | 'w';
63
+ type ToastType = MessageType | ShortType;
64
+ type ToastOptions = Partial<ElMessageOptions> & {
65
+ closeAll?: boolean;
66
+ };
67
+ declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
60
68
  declare namespace $toast {
61
69
  var success: (message: any, otherParams?: {}) => void;
62
70
  var info: (message: any, otherParams?: {}) => void;
@@ -76,6 +84,16 @@ declare function getStorage(data: any, isSession?: boolean): string | null;
76
84
  * clearStorage({ exclude: ['loginId', 'token'] })
77
85
  */
78
86
  declare function clearStorage(str?: string | [] | object): void;
87
+ /**
88
+ * element-plus的form表单使用promise进行封装
89
+ * @param ref
90
+ * @param param1
91
+ * @returns Promise
92
+ * await proxy.validForm(formRef);
93
+ * await proxy.validForm(formRef, {message: '自定义错误'});
94
+ * await proxy.validForm(formRef, {showMessage: false});
95
+ * await proxy.validForm(formRef, {detail: true});
96
+ */
79
97
  declare function validForm(ref: any, { message, detail, showMessage }?: {
80
98
  message?: string | undefined;
81
99
  detail?: boolean | undefined;
@@ -83,9 +101,9 @@ declare function validForm(ref: any, { message, detail, showMessage }?: {
83
101
  }): Promise<unknown>;
84
102
  /**
85
103
  * 判断变量是否空值
86
- * undefined, null, '', ' ', false, 0, [], {} 均返回true,否则返回false
104
+ * undefined, null, '', ' ', false, 0, [], {}, NaN, new Set(), new Map(), BigInt(0), new Date('无效日期') 均返回true,否则返回false
87
105
  */
88
- declare function isEmpty(data: any): boolean;
106
+ declare function isEmpty(data: any, strict?: boolean): boolean;
89
107
  declare function notEmpty(v: any): boolean;
90
108
  /**
91
109
  * 将两个对象合并, 以第二个对象为准, 如果两个对象, 一个属性有值, 一个没值, 合并后有值; 如果两个属性都有值, 以第二个属性为准
@@ -258,12 +276,26 @@ declare function toFixed(value: any, options?: {
258
276
  /**
259
277
  * 只有对正整数或者字符串正整数才进行单位的转换,
260
278
  * 否则返回原始数据
279
+ * @example
280
+ * proxy.formatBytes(536870912) // 512MB
261
281
  * proxy.formatBytes(536870912) // 512MB
262
282
  */
263
- declare function formatBytes(bytes: any, { toFixed, thousands }?: {
264
- toFixed?: number | undefined;
265
- thousands?: boolean | undefined;
266
- }): any;
283
+ declare function formatBytes(bytes: any, options?: {
284
+ digit?: number;
285
+ thousands?: boolean;
286
+ prefix?: string;
287
+ suffix?: string;
288
+ } | number): any;
289
+ /**
290
+ * 字节转数字
291
+ * @param oBytes
292
+ * @param param1
293
+ * @returns number
294
+ * formatBytesConvert('0.5GB') 536870912
295
+ * formatBytesConvert('1,234 GB') 1324997410816
296
+ * formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
297
+ * formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
298
+ */
267
299
  declare function formatBytesConvert(oBytes: any, { thounsand, toFixed }?: {
268
300
  thounsand?: boolean | undefined;
269
301
  toFixed?: number | undefined;
package/dist/index.mjs CHANGED
@@ -12,21 +12,27 @@ const isStringNumber = (val) => {
12
12
  };
13
13
  const isNumber = (val) => typeof val === "number";
14
14
  function $toast(message, type = "success", otherParams = {}) {
15
- const map = {
15
+ const typeMap = {
16
16
  s: "success",
17
17
  i: "info",
18
18
  e: "error",
19
19
  w: "warning"
20
20
  };
21
- if (getType(message) === "object") {
22
- if (message.clodeAll) {
21
+ function isShortType(t) {
22
+ return ["s", "i", "e", "w"].includes(t);
23
+ }
24
+ function isToastOptions(obj) {
25
+ return typeof obj === "object" && obj !== null;
26
+ }
27
+ if (isToastOptions(message)) {
28
+ if (message.closeAll) {
23
29
  ElMessage.closeAll();
24
30
  }
25
31
  ElMessage(message);
26
32
  return;
27
33
  }
28
- if (getType(type) === "object") {
29
- if (type.clodeAll) {
34
+ if (isToastOptions(type)) {
35
+ if (type.closeAll) {
30
36
  ElMessage.closeAll();
31
37
  }
32
38
  ElMessage({
@@ -39,9 +45,10 @@ function $toast(message, type = "success", otherParams = {}) {
39
45
  if (otherParams.closeAll) {
40
46
  ElMessage.closeAll();
41
47
  }
48
+ const resolvedType = isShortType(type) ? typeMap[type] : type;
42
49
  ElMessage({
43
50
  message,
44
- type: map[type] || type,
51
+ type: resolvedType,
45
52
  ...otherParams
46
53
  });
47
54
  }
@@ -149,32 +156,38 @@ function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF
149
156
  });
150
157
  });
151
158
  }
152
- function isEmpty(data) {
159
+ function isEmpty(data, strict = false) {
153
160
  if (isRef(data)) {
154
161
  data = unref(data);
155
162
  }
163
+ if (strict) {
164
+ if (data === false || data === 0 || data === BigInt(0)) {
165
+ return false;
166
+ }
167
+ }
168
+ if (data == null) return true;
156
169
  if (data instanceof Date) {
157
170
  return isNaN(data.getTime());
158
171
  }
159
172
  switch (typeof data) {
160
- case "undefined":
161
- return true;
162
173
  case "string":
163
- if (data.trim().length === 0) return true;
164
- break;
174
+ return data.trim().length === 0;
165
175
  case "boolean":
166
- if (!data) return true;
167
- break;
176
+ return !data;
168
177
  case "number":
169
- if (0 === data) return true;
170
- break;
171
- case "object":
172
- if (null === data) return true;
173
- if (void 0 !== data.length && data.length === 0) return true;
174
- for (var k in data) {
175
- return false;
176
- }
177
- return true;
178
+ return 0 === data || isNaN(data);
179
+ // ❗ `NaN`或者0 被认为是空
180
+ case "symbol":
181
+ return false;
182
+ case "bigint":
183
+ return data === BigInt(0);
184
+ }
185
+ if (data instanceof Map || data instanceof Set) return data.size === 0;
186
+ if (Array.isArray(data) || typeof data.length === "number" && Object.prototype.toString.call(data) === "[object Object]") {
187
+ return data.length === 0;
188
+ }
189
+ if (typeof data === "object") {
190
+ return Object.keys(data).length === 0;
178
191
  }
179
192
  return false;
180
193
  }
@@ -628,23 +641,24 @@ function toFixed(value, options = {}) {
628
641
  }
629
642
  return `${prefix}${res}${finalUnit}${suffix}`;
630
643
  }
631
- function formatBytes(bytes, { toFixed: toFixed2 = 2, thousands = true } = {}) {
644
+ function formatBytes(bytes, options = {}) {
645
+ let { digit = 2, thousands = true, prefix = "", suffix = "" } = options;
632
646
  if (isStringNumber(bytes) || isNumber(bytes)) {
633
647
  bytes = Number(bytes);
634
648
  } else {
635
649
  return bytes;
636
650
  }
637
651
  if (bytes <= 0) {
638
- return bytes.toFixed(toFixed2) + " B";
652
+ return bytes.toFixed(digit) + " B";
639
653
  }
640
654
  const k = 1024;
641
655
  const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
642
656
  const i = Math.floor(Math.log(bytes) / Math.log(k));
643
- let res = (bytes / Math.pow(k, i)).toFixed(toFixed2) + " " + sizes[i];
657
+ let res = (bytes / Math.pow(k, i)).toFixed(digit) + " " + sizes[i];
644
658
  if (thousands) {
645
659
  res = formatThousands(res);
646
660
  }
647
- return res;
661
+ return `${prefix}${res}${suffix}`;
648
662
  }
649
663
  function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 } = {}) {
650
664
  if (isStringNumber(oBytes) || isNumber(oBytes) || getType(oBytes) !== "string") {
@@ -689,7 +703,7 @@ function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 }
689
703
  }
690
704
  let finalRes = size * units[unit];
691
705
  if (toFixed2) {
692
- finalRes = parseFloat(finalRes.toFixed(toFixed2));
706
+ finalRes = Number(finalRes).toFixed(toFixed2);
693
707
  }
694
708
  if (thounsand) {
695
709
  finalRes = formatThousands(finalRes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oeos-components/utils",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "utils of oeos-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",