@dpuse/dpuse-shared 0.3.662 → 0.3.664
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.
|
@@ -46,30 +46,52 @@ function a(n, r = 2, i = r, a = e) {
|
|
|
46
46
|
}), t.set(o, s)), s.format(n);
|
|
47
47
|
}
|
|
48
48
|
function o(e, t = 1) {
|
|
49
|
-
return e == null ? "" : e < 1e3 ?
|
|
49
|
+
return e == null ? "" : e < 1e3 ? u(e) : e < 1e6 ? `${a(e / 1e3, t, 0)}K` : e < 1e9 ? `${a(e / 1e6, t, 0)}M` : e < 0xe8d4a51000 ? `${a(e / 1e9, t, 0)}B` : `${a(e / 0xe8d4a51000, t, 0)}T`;
|
|
50
50
|
}
|
|
51
51
|
function s(e, t = 1) {
|
|
52
|
-
return e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${
|
|
52
|
+
return e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${u(e)} bytes` : e < 1048576 ? `${a(e / 1024, t, 0)} KB` : e < 1073741824 ? `${a(e / 1048576, t, 0)} MB` : e < 1099511627776 ? `${a(e / 1073741824, t, 0)} GB` : `${a(e / 1099511627776, t, 0)} TB`;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
var c = [
|
|
55
|
+
[
|
|
56
|
+
"days",
|
|
57
|
+
864e5,
|
|
58
|
+
(e) => e === 1 ? "1 day" : `${u(e)} days`
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"hrs",
|
|
62
|
+
36e5,
|
|
63
|
+
(e) => e === 1 ? "1 hr" : `${u(e)} hrs`
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"mins",
|
|
67
|
+
6e4,
|
|
68
|
+
(e) => e === 1 ? "1 min" : `${u(e)} mins`
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"secs",
|
|
72
|
+
1e3,
|
|
73
|
+
(e) => e === 1 ? "1 sec" : `${u(e)} secs`
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"ms",
|
|
77
|
+
0,
|
|
78
|
+
(e) => `${u(e)} ms`
|
|
79
|
+
]
|
|
80
|
+
];
|
|
81
|
+
function l(e, t = "ms") {
|
|
55
82
|
if (e == null) return "";
|
|
56
|
-
|
|
57
|
-
if (e <
|
|
58
|
-
let t =
|
|
59
|
-
|
|
83
|
+
let n = c.findIndex(([e]) => e === t);
|
|
84
|
+
if (e < (c[n]?.[1] ?? 0)) {
|
|
85
|
+
let t = c.find(([, t]) => e >= t);
|
|
86
|
+
if (t == null) return `${u(e)} ms`;
|
|
87
|
+
let [, n, r] = t;
|
|
88
|
+
return r(n > 0 ? Math.floor(e / n) : e);
|
|
60
89
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
if (e < 864e5) {
|
|
66
|
-
let t = Math.floor(e / 36e5), n = Math.floor(e % 36e5 / 6e4), r = t === 1 ? "1 hr" : `${l(t)} hrs`;
|
|
67
|
-
return n === 0 ? r : `${r} ${n === 1 ? "1 min" : `${l(n)} mins`}`;
|
|
68
|
-
}
|
|
69
|
-
let t = Math.floor(e / 864e5), n = Math.floor(e % 864e5 / 36e5), r = t === 1 ? "1 day" : `${l(t)} days`;
|
|
70
|
-
return n === 0 ? r : `${r} ${n === 1 ? "1 hr" : `${l(n)} hrs`}`;
|
|
90
|
+
let r = [], i = e;
|
|
91
|
+
for (let [, e, t] of c.slice(0, n + 1)) e === 0 ? (i > 0 || r.length === 0) && r.push(t(i)) : i >= e && (r.push(t(Math.floor(i / e))), i %= e);
|
|
92
|
+
return r.join(" ");
|
|
71
93
|
}
|
|
72
|
-
function
|
|
94
|
+
function u(n, r = e) {
|
|
73
95
|
if (n == null) return "";
|
|
74
96
|
let i = `${r}decimal0.0`, a = t.get(i);
|
|
75
97
|
return a || (a = new Intl.NumberFormat(r, {
|
|
@@ -81,7 +103,7 @@ function l(n, r = e) {
|
|
|
81
103
|
useGrouping: !0
|
|
82
104
|
}), t.set(i, a)), a.format(n);
|
|
83
105
|
}
|
|
84
|
-
function
|
|
106
|
+
function d(e) {
|
|
85
107
|
switch (e) {
|
|
86
108
|
case "csv": return "text/csv";
|
|
87
109
|
case "tab":
|
|
@@ -92,4 +114,4 @@ function u(e) {
|
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
116
|
//#endregion
|
|
95
|
-
export { n as convertODataTypeIdToUsageTypeId, i as extractExtensionFromPath, r as extractNameFromPath, a as formatNumberAsDecimalNumber,
|
|
117
|
+
export { n as convertODataTypeIdToUsageTypeId, i as extractExtensionFromPath, r as extractNameFromPath, a as formatNumberAsDecimalNumber, l as formatNumberAsDuration, o as formatNumberAsSize, s as formatNumberAsStorageSize, u as formatNumberAsWholeNumber, d as lookupMimeTypeForExtension };
|
|
@@ -4,6 +4,7 @@ export declare function extractExtensionFromPath(itemPath: string): string | und
|
|
|
4
4
|
export declare function formatNumberAsDecimalNumber(number?: number, decimalPlaces?: number, minimumFractionDigits?: number, locale?: string): string;
|
|
5
5
|
export declare function formatNumberAsSize(number?: number, decimalPlaces?: number): string;
|
|
6
6
|
export declare function formatNumberAsStorageSize(number?: number, decimalPlaces?: number): string;
|
|
7
|
-
export
|
|
7
|
+
export type DurationLevel = 'days' | 'hrs' | 'mins' | 'secs' | 'ms';
|
|
8
|
+
export declare function formatNumberAsDuration(number?: number, stopAt?: DurationLevel): string;
|
|
8
9
|
export declare function formatNumberAsWholeNumber(number?: number, locale?: string): string;
|
|
9
10
|
export declare function lookupMimeTypeForExtension(extension?: string): string;
|
package/package.json
CHANGED