@kopexa/shared-utils 13.0.3 → 14.0.0
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -0
- package/dist/index.mjs +9 -0
- package/dist/numbers.d.mts +2 -1
- package/dist/numbers.d.ts +2 -1
- package/dist/numbers.js +12 -2
- package/dist/numbers.mjs +10 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject } from './assertion.mjs';
|
|
2
2
|
export { cn } from './clsx.mjs';
|
|
3
3
|
export { callAllHandlers, getUniqueID } from './functions.mjs';
|
|
4
|
-
export { clamp } from './numbers.mjs';
|
|
4
|
+
export { clamp, formatBytes } from './numbers.mjs';
|
|
5
5
|
export { compact, mapPropsVariants, objectToDeps } from './object.mjs';
|
|
6
6
|
export { chain } from './ra.mjs';
|
|
7
7
|
export { MAC_SYMBOLS, formatShortcutKey, isMac, parseShortcutKeys } from './system.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject } from './assertion.js';
|
|
2
2
|
export { cn } from './clsx.js';
|
|
3
3
|
export { callAllHandlers, getUniqueID } from './functions.js';
|
|
4
|
-
export { clamp } from './numbers.js';
|
|
4
|
+
export { clamp, formatBytes } from './numbers.js';
|
|
5
5
|
export { compact, mapPropsVariants, objectToDeps } from './object.js';
|
|
6
6
|
export { chain } from './ra.js';
|
|
7
7
|
export { MAC_SYMBOLS, formatShortcutKey, isMac, parseShortcutKeys } from './system.js';
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
cn: () => cn,
|
|
29
29
|
compact: () => compact,
|
|
30
30
|
dataAttr: () => dataAttr,
|
|
31
|
+
formatBytes: () => formatBytes,
|
|
31
32
|
formatShortcutKey: () => formatShortcutKey,
|
|
32
33
|
getInitials: () => getInitials,
|
|
33
34
|
getUniqueID: () => getUniqueID,
|
|
@@ -91,6 +92,14 @@ function callAllHandlers(...fns) {
|
|
|
91
92
|
function clamp(value, min, max) {
|
|
92
93
|
return Math.min(Math.max(value, min), max);
|
|
93
94
|
}
|
|
95
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
96
|
+
if (bytes === 0) return "0 Bytes";
|
|
97
|
+
const k = 1024;
|
|
98
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
99
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
100
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
101
|
+
return Number.parseFloat((bytes / k ** i).toFixed(dm)) + sizes[i];
|
|
102
|
+
};
|
|
94
103
|
|
|
95
104
|
// src/object.ts
|
|
96
105
|
function compact(object) {
|
|
@@ -200,6 +209,7 @@ var getInitials = (text) => {
|
|
|
200
209
|
cn,
|
|
201
210
|
compact,
|
|
202
211
|
dataAttr,
|
|
212
|
+
formatBytes,
|
|
203
213
|
formatShortcutKey,
|
|
204
214
|
getInitials,
|
|
205
215
|
getUniqueID,
|
package/dist/index.mjs
CHANGED
|
@@ -45,6 +45,14 @@ function callAllHandlers(...fns) {
|
|
|
45
45
|
function clamp(value, min, max) {
|
|
46
46
|
return Math.min(Math.max(value, min), max);
|
|
47
47
|
}
|
|
48
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
49
|
+
if (bytes === 0) return "0 Bytes";
|
|
50
|
+
const k = 1024;
|
|
51
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
52
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
53
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
54
|
+
return Number.parseFloat((bytes / k ** i).toFixed(dm)) + sizes[i];
|
|
55
|
+
};
|
|
48
56
|
|
|
49
57
|
// src/object.ts
|
|
50
58
|
function compact(object) {
|
|
@@ -153,6 +161,7 @@ export {
|
|
|
153
161
|
cn,
|
|
154
162
|
compact,
|
|
155
163
|
dataAttr,
|
|
164
|
+
formatBytes,
|
|
156
165
|
formatShortcutKey,
|
|
157
166
|
getInitials,
|
|
158
167
|
getUniqueID,
|
package/dist/numbers.d.mts
CHANGED
package/dist/numbers.d.ts
CHANGED
package/dist/numbers.js
CHANGED
|
@@ -20,13 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/numbers.ts
|
|
21
21
|
var numbers_exports = {};
|
|
22
22
|
__export(numbers_exports, {
|
|
23
|
-
clamp: () => clamp
|
|
23
|
+
clamp: () => clamp,
|
|
24
|
+
formatBytes: () => formatBytes
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(numbers_exports);
|
|
26
27
|
function clamp(value, min, max) {
|
|
27
28
|
return Math.min(Math.max(value, min), max);
|
|
28
29
|
}
|
|
30
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
31
|
+
if (bytes === 0) return "0 Bytes";
|
|
32
|
+
const k = 1024;
|
|
33
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
34
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
35
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
36
|
+
return Number.parseFloat((bytes / k ** i).toFixed(dm)) + sizes[i];
|
|
37
|
+
};
|
|
29
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
39
|
0 && (module.exports = {
|
|
31
|
-
clamp
|
|
40
|
+
clamp,
|
|
41
|
+
formatBytes
|
|
32
42
|
});
|
package/dist/numbers.mjs
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
function clamp(value, min, max) {
|
|
3
3
|
return Math.min(Math.max(value, min), max);
|
|
4
4
|
}
|
|
5
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
6
|
+
if (bytes === 0) return "0 Bytes";
|
|
7
|
+
const k = 1024;
|
|
8
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
9
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
10
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
11
|
+
return Number.parseFloat((bytes / k ** i).toFixed(dm)) + sizes[i];
|
|
12
|
+
};
|
|
5
13
|
export {
|
|
6
|
-
clamp
|
|
14
|
+
clamp,
|
|
15
|
+
formatBytes
|
|
7
16
|
};
|