@oeos-components/utils 0.0.7 → 0.0.8
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 +15 -12
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +15 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -663,19 +663,19 @@ function formatBytes(bytes, options = {}) {
|
|
|
663
663
|
}
|
|
664
664
|
return `${prefix}${res}${suffix}`;
|
|
665
665
|
}
|
|
666
|
-
function formatBytesConvert(oBytes, {
|
|
666
|
+
function formatBytesConvert(oBytes, { thounsands = false, digit = 0 } = {}) {
|
|
667
|
+
let bytes = oBytes;
|
|
667
668
|
if (isStringNumber(oBytes) || isNumber(oBytes) || getType(oBytes) !== "string") {
|
|
668
|
-
return oBytes;
|
|
669
|
+
return parseDigitThounsands(oBytes);
|
|
669
670
|
}
|
|
670
671
|
if (!oBytes) {
|
|
671
|
-
return oBytes;
|
|
672
|
+
return parseDigitThounsands(oBytes);
|
|
672
673
|
}
|
|
673
674
|
const regex = /^\d{1,3}(,\d{3})*(\.\d+)?[a-zA-Z ]*$/;
|
|
674
|
-
let bytes = oBytes;
|
|
675
675
|
if (regex.test(oBytes)) {
|
|
676
676
|
bytes = oBytes.replace(/,/g, "");
|
|
677
677
|
if (isStringNumber(bytes) || isNumber(bytes) || getType(bytes) !== "string") {
|
|
678
|
-
return bytes;
|
|
678
|
+
return parseDigitThounsands(bytes);
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
const bytesRegex = /^(\d+(?:\.\d+)?)\s*([BKMGTPEZY]?B|Byte)$/i;
|
|
@@ -704,14 +704,17 @@ function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 }
|
|
|
704
704
|
);
|
|
705
705
|
return;
|
|
706
706
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
707
|
+
function parseDigitThounsands(val) {
|
|
708
|
+
let finalRes = val;
|
|
709
|
+
if (digit) {
|
|
710
|
+
finalRes = Number(finalRes).toFixed(digit);
|
|
711
|
+
}
|
|
712
|
+
if (thounsands) {
|
|
713
|
+
finalRes = formatThousands(finalRes);
|
|
714
|
+
}
|
|
715
|
+
return finalRes;
|
|
713
716
|
}
|
|
714
|
-
return
|
|
717
|
+
return parseDigitThounsands(size * units[unit]);
|
|
715
718
|
}
|
|
716
719
|
function throttle(fn, delay = 1e3) {
|
|
717
720
|
let last = 0;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
|
-
import {
|
|
2
|
+
import { MessageOptions } from 'element-plus';
|
|
3
3
|
import { Ref } from '@vue/reactivity';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -61,7 +61,7 @@ declare const isNumber: (val: any) => val is number;
|
|
|
61
61
|
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
62
62
|
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
63
63
|
type ToastType = MessageType | ShortType;
|
|
64
|
-
type ToastOptions = Partial<
|
|
64
|
+
type ToastOptions = Partial<MessageOptions> & {
|
|
65
65
|
closeAll?: boolean;
|
|
66
66
|
};
|
|
67
67
|
declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
@@ -285,7 +285,7 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
285
285
|
thousands?: boolean;
|
|
286
286
|
prefix?: string;
|
|
287
287
|
suffix?: string;
|
|
288
|
-
}
|
|
288
|
+
}): any;
|
|
289
289
|
/**
|
|
290
290
|
* 字节转数字
|
|
291
291
|
* @param oBytes
|
|
@@ -296,9 +296,9 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
296
296
|
* formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
|
|
297
297
|
* formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
|
|
298
298
|
*/
|
|
299
|
-
declare function formatBytesConvert(oBytes: any, {
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
declare function formatBytesConvert(oBytes: any, { thounsands, digit }?: {
|
|
300
|
+
thounsands?: boolean | undefined;
|
|
301
|
+
digit?: number | undefined;
|
|
302
302
|
}): any;
|
|
303
303
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
304
304
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
|
-
import {
|
|
2
|
+
import { MessageOptions } from 'element-plus';
|
|
3
3
|
import { Ref } from '@vue/reactivity';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -61,7 +61,7 @@ declare const isNumber: (val: any) => val is number;
|
|
|
61
61
|
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
62
62
|
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
63
63
|
type ToastType = MessageType | ShortType;
|
|
64
|
-
type ToastOptions = Partial<
|
|
64
|
+
type ToastOptions = Partial<MessageOptions> & {
|
|
65
65
|
closeAll?: boolean;
|
|
66
66
|
};
|
|
67
67
|
declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
@@ -285,7 +285,7 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
285
285
|
thousands?: boolean;
|
|
286
286
|
prefix?: string;
|
|
287
287
|
suffix?: string;
|
|
288
|
-
}
|
|
288
|
+
}): any;
|
|
289
289
|
/**
|
|
290
290
|
* 字节转数字
|
|
291
291
|
* @param oBytes
|
|
@@ -296,9 +296,9 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
296
296
|
* formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
|
|
297
297
|
* formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
|
|
298
298
|
*/
|
|
299
|
-
declare function formatBytesConvert(oBytes: any, {
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
declare function formatBytesConvert(oBytes: any, { thounsands, digit }?: {
|
|
300
|
+
thounsands?: boolean | undefined;
|
|
301
|
+
digit?: number | undefined;
|
|
302
302
|
}): any;
|
|
303
303
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
304
304
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
|
-
import {
|
|
2
|
+
import { MessageOptions } from 'element-plus';
|
|
3
3
|
import { Ref } from '@vue/reactivity';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -61,7 +61,7 @@ declare const isNumber: (val: any) => val is number;
|
|
|
61
61
|
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
62
62
|
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
63
63
|
type ToastType = MessageType | ShortType;
|
|
64
|
-
type ToastOptions = Partial<
|
|
64
|
+
type ToastOptions = Partial<MessageOptions> & {
|
|
65
65
|
closeAll?: boolean;
|
|
66
66
|
};
|
|
67
67
|
declare function $toast(message: string | ToastOptions, type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
@@ -285,7 +285,7 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
285
285
|
thousands?: boolean;
|
|
286
286
|
prefix?: string;
|
|
287
287
|
suffix?: string;
|
|
288
|
-
}
|
|
288
|
+
}): any;
|
|
289
289
|
/**
|
|
290
290
|
* 字节转数字
|
|
291
291
|
* @param oBytes
|
|
@@ -296,9 +296,9 @@ declare function formatBytes(bytes: any, options?: {
|
|
|
296
296
|
* formatBytesConvert('1,234 GB', {thousand: true}) 1,324,997,410,816
|
|
297
297
|
* formatBytesConvert('1,234 GB', {toFixed: 2}) 1324997410816.00
|
|
298
298
|
*/
|
|
299
|
-
declare function formatBytesConvert(oBytes: any, {
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
declare function formatBytesConvert(oBytes: any, { thounsands, digit }?: {
|
|
300
|
+
thounsands?: boolean | undefined;
|
|
301
|
+
digit?: number | undefined;
|
|
302
302
|
}): any;
|
|
303
303
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
304
304
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -660,19 +660,19 @@ function formatBytes(bytes, options = {}) {
|
|
|
660
660
|
}
|
|
661
661
|
return `${prefix}${res}${suffix}`;
|
|
662
662
|
}
|
|
663
|
-
function formatBytesConvert(oBytes, {
|
|
663
|
+
function formatBytesConvert(oBytes, { thounsands = false, digit = 0 } = {}) {
|
|
664
|
+
let bytes = oBytes;
|
|
664
665
|
if (isStringNumber(oBytes) || isNumber(oBytes) || getType(oBytes) !== "string") {
|
|
665
|
-
return oBytes;
|
|
666
|
+
return parseDigitThounsands(oBytes);
|
|
666
667
|
}
|
|
667
668
|
if (!oBytes) {
|
|
668
|
-
return oBytes;
|
|
669
|
+
return parseDigitThounsands(oBytes);
|
|
669
670
|
}
|
|
670
671
|
const regex = /^\d{1,3}(,\d{3})*(\.\d+)?[a-zA-Z ]*$/;
|
|
671
|
-
let bytes = oBytes;
|
|
672
672
|
if (regex.test(oBytes)) {
|
|
673
673
|
bytes = oBytes.replace(/,/g, "");
|
|
674
674
|
if (isStringNumber(bytes) || isNumber(bytes) || getType(bytes) !== "string") {
|
|
675
|
-
return bytes;
|
|
675
|
+
return parseDigitThounsands(bytes);
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
678
|
const bytesRegex = /^(\d+(?:\.\d+)?)\s*([BKMGTPEZY]?B|Byte)$/i;
|
|
@@ -701,14 +701,17 @@ function formatBytesConvert(oBytes, { thounsand = false, toFixed: toFixed2 = 0 }
|
|
|
701
701
|
);
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
704
|
+
function parseDigitThounsands(val) {
|
|
705
|
+
let finalRes = val;
|
|
706
|
+
if (digit) {
|
|
707
|
+
finalRes = Number(finalRes).toFixed(digit);
|
|
708
|
+
}
|
|
709
|
+
if (thounsands) {
|
|
710
|
+
finalRes = formatThousands(finalRes);
|
|
711
|
+
}
|
|
712
|
+
return finalRes;
|
|
710
713
|
}
|
|
711
|
-
return
|
|
714
|
+
return parseDigitThounsands(size * units[unit]);
|
|
712
715
|
}
|
|
713
716
|
function throttle(fn, delay = 1e3) {
|
|
714
717
|
let last = 0;
|