@datapos/datapos-shared 0.3.335 → 0.3.337
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.
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const c = "en-US", s = /* @__PURE__ */ new Map();
|
|
2
|
+
function f(e) {
|
|
3
|
+
switch (e) {
|
|
4
|
+
case "Edm.Binary":
|
|
5
|
+
return "unknown";
|
|
6
|
+
// Binary...
|
|
7
|
+
case "Edm.Boolean":
|
|
8
|
+
return "boolean";
|
|
9
|
+
case "Edm.Byte":
|
|
10
|
+
return "wholeNumber";
|
|
11
|
+
case "Edm.DateTime":
|
|
12
|
+
return "moment";
|
|
13
|
+
// DateTime...
|
|
14
|
+
case "Edm.DateTimeOffset":
|
|
15
|
+
return "moment";
|
|
16
|
+
// DateTimeOffset...
|
|
17
|
+
case "Edm.Decimal":
|
|
18
|
+
return "decimalNumber";
|
|
19
|
+
case "Edm.Double":
|
|
20
|
+
return "decimalNumber";
|
|
21
|
+
case "Edm.Guid":
|
|
22
|
+
return "string";
|
|
23
|
+
case "Edm.Int16":
|
|
24
|
+
return "wholeNumber";
|
|
25
|
+
case "Edm.Int32":
|
|
26
|
+
return "wholeNumber";
|
|
27
|
+
case "Edm.Int64":
|
|
28
|
+
return "wholeNumber";
|
|
29
|
+
case "Edm.SByte":
|
|
30
|
+
return "wholeNumber";
|
|
31
|
+
case "Edm.Single":
|
|
32
|
+
return "decimalNumber";
|
|
33
|
+
case "Edm.String":
|
|
34
|
+
return "string";
|
|
35
|
+
case "Edm.Time":
|
|
36
|
+
return "momentTime";
|
|
37
|
+
// Time...
|
|
38
|
+
default:
|
|
39
|
+
return "unknown";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function l(e) {
|
|
43
|
+
if (e) {
|
|
44
|
+
const t = e.lastIndexOf("/"), n = e.lastIndexOf(".", t === -1 ? e.length : t);
|
|
45
|
+
return n === -1 ? e : e.slice(0, Math.max(0, n));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function m(e) {
|
|
49
|
+
if (e) {
|
|
50
|
+
const t = e.lastIndexOf(".");
|
|
51
|
+
if (t !== -1) return e.slice(Math.max(0, t + 1));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function r(e, t = 2, n = t, i = c) {
|
|
55
|
+
if (e == null) return "";
|
|
56
|
+
const u = `${i}decimal${t}.${n}`;
|
|
57
|
+
let a = s.get(u);
|
|
58
|
+
return a || (a = new Intl.NumberFormat(i, {
|
|
59
|
+
localeMatcher: "best fit",
|
|
60
|
+
maximumFractionDigits: t,
|
|
61
|
+
minimumFractionDigits: n,
|
|
62
|
+
minimumIntegerDigits: 1,
|
|
63
|
+
style: "decimal",
|
|
64
|
+
useGrouping: !0
|
|
65
|
+
}), s.set(u, a)), a.format(e);
|
|
66
|
+
}
|
|
67
|
+
function d(e) {
|
|
68
|
+
return e == null ? "" : e < 1e3 ? o(e) : e < 1e6 ? `${r(e / 1e3, 2, 0)}K` : e < 1e9 ? `${r(e / 1e6, 2, 0)}M` : e < 1e12 ? `${r(e / 1e9, 2, 0)}B` : `${r(e / 1e12, 2, 0)}T`;
|
|
69
|
+
}
|
|
70
|
+
function x(e) {
|
|
71
|
+
return e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${o(e)} bytes` : e < 1048576 ? `${r(e / 1024, 2, 0)} KB` : e < 1073741824 ? `${r(e / 1048576, 2, 0)} MB` : e < 1099511627776 ? `${r(e / 1073741824, 2, 0)} GB` : `${r(e / 1099511627776, 2, 0)} TB`;
|
|
72
|
+
}
|
|
73
|
+
function p(e) {
|
|
74
|
+
return e == null ? "" : e < 1e3 ? `${o(e)} ms` : e === 1e3 ? `${o(e)} sec` : e < 6e4 ? `${r(e / 1e3, 2, 0)} secs` : e === 6e4 ? "1 min" : e < 36e5 ? `${r(e / 6e4, 2, 0)} mins` : e === 36e5 ? "1 hr" : e < 864e5 ? `${r(e / 36e5, 2, 0)} hrs` : e === 864e5 ? "1 day" : `${r(e / 864e5, 2, 0)} days`;
|
|
75
|
+
}
|
|
76
|
+
function o(e, t = c) {
|
|
77
|
+
if (e == null) return "";
|
|
78
|
+
const n = `${t}decimal0.0`;
|
|
79
|
+
let i = s.get(n);
|
|
80
|
+
return i || (i = new Intl.NumberFormat(t, {
|
|
81
|
+
localeMatcher: "best fit",
|
|
82
|
+
maximumFractionDigits: 0,
|
|
83
|
+
minimumFractionDigits: 0,
|
|
84
|
+
minimumIntegerDigits: 1,
|
|
85
|
+
style: "decimal",
|
|
86
|
+
useGrouping: !0
|
|
87
|
+
}), s.set(n, i)), i.format(e);
|
|
88
|
+
}
|
|
89
|
+
function E(e) {
|
|
90
|
+
switch (e) {
|
|
91
|
+
case "csv":
|
|
92
|
+
return "text/csv";
|
|
93
|
+
case "tab":
|
|
94
|
+
case "tsv":
|
|
95
|
+
return "text/tab-separated-values";
|
|
96
|
+
case "xls":
|
|
97
|
+
return "application/vnd.ms-excel";
|
|
98
|
+
case "xlsx":
|
|
99
|
+
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
100
|
+
default:
|
|
101
|
+
return "application/octet-stream";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
f as convertODataTypeIdToUsageTypeId,
|
|
106
|
+
m as extractExtensionFromPath,
|
|
107
|
+
l as extractNameFromPath,
|
|
108
|
+
r as formatNumberAsDecimalNumber,
|
|
109
|
+
p as formatNumberAsDuration,
|
|
110
|
+
d as formatNumberAsSize,
|
|
111
|
+
x as formatNumberAsStorageSize,
|
|
112
|
+
o as formatNumberAsWholeNumber,
|
|
113
|
+
E as lookupMimeTypeForExtension
|
|
114
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.337",
|
|
4
4
|
"description": "A library containing common constants, types and utilities used across all Data Positioning projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jonathan Terrell <terrell.jm@gmail.com>",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
".": {
|
|
21
21
|
"import": "./dist/datapos-shared.es.js",
|
|
22
22
|
"types": "./dist/types/src/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./utilities": {
|
|
25
|
+
"import": "./dist/utilities.js",
|
|
26
|
+
"types": "./dist/types/utilities.d.ts"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
"sideEffects": false,
|