@naturalcycles/js-lib 15.26.0 → 15.28.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/error/error.model.d.ts +1 -1
- package/dist/unit/size.util.js +18 -14
- package/package.json +1 -1
- package/src/error/error.model.ts +1 -1
- package/src/unit/size.util.ts +12 -10
|
@@ -55,7 +55,7 @@ export interface ErrorData {
|
|
|
55
55
|
*
|
|
56
56
|
* Sentry takes string[], but for convenience we allow to pass a singe string.
|
|
57
57
|
*/
|
|
58
|
-
fingerprint?: string
|
|
58
|
+
fingerprint?: string;
|
|
59
59
|
/**
|
|
60
60
|
* Set when throwing an error from your backend code, to indicate desired http status code.
|
|
61
61
|
* e.g throw new AppError('oj', { backendResponseStatusCode: 401 })
|
package/dist/unit/size.util.js
CHANGED
|
@@ -11,16 +11,20 @@ export function _kb(b) {
|
|
|
11
11
|
* Byte size to Human byte size string
|
|
12
12
|
*/
|
|
13
13
|
export function _hb(b = 0) {
|
|
14
|
-
if (b <
|
|
14
|
+
if (b < 100)
|
|
15
15
|
return `${Math.round(b)} byte(s)`;
|
|
16
|
-
if (b <
|
|
17
|
-
return `${(b / 1024).
|
|
18
|
-
if (b < 1024 **
|
|
19
|
-
return `${(b / 1024
|
|
20
|
-
if (b < 1024 **
|
|
21
|
-
return `${(b / 1024 **
|
|
22
|
-
if (b < 1024 **
|
|
23
|
-
return `${(b / 1024 **
|
|
16
|
+
if (b < 1000)
|
|
17
|
+
return `${(b / 1024).toFixed(2)} Kb`;
|
|
18
|
+
if (b < 0.9 * 1024 ** 2)
|
|
19
|
+
return `${Math.round(b / 1024)} Kb`;
|
|
20
|
+
if (b < 0.9 * 1024 ** 3)
|
|
21
|
+
return `${Math.round(b / 1024 ** 2)} Mb`;
|
|
22
|
+
if (b < 0.09 * 1024 ** 4)
|
|
23
|
+
return `${(b / 1024 ** 3).toFixed(2)} Gb`;
|
|
24
|
+
if (b < 0.9 * 1024 ** 4)
|
|
25
|
+
return `${Math.round(b / 1024 ** 3)} Gb`;
|
|
26
|
+
if (b < 0.9 * 1024 ** 5)
|
|
27
|
+
return `${(b / 1024 ** 4).toFixed(2)} Tb`;
|
|
24
28
|
return `${Math.round(b / 1024 ** 4)} Tb`;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
@@ -30,14 +34,14 @@ export function _hb(b = 0) {
|
|
|
30
34
|
*/
|
|
31
35
|
export function _hc(c = 0) {
|
|
32
36
|
if (c < 10 ** 4)
|
|
33
|
-
return String(c);
|
|
37
|
+
return String(Math.round(c));
|
|
34
38
|
if (c < 10 ** 6)
|
|
35
|
-
return (c / 10 ** 3)
|
|
39
|
+
return Math.round(c / 10 ** 3) + ' K';
|
|
36
40
|
if (c < 10 ** 9)
|
|
37
|
-
return (c / 10 ** 6)
|
|
41
|
+
return Math.round(c / 10 ** 6) + ' M'; // million
|
|
38
42
|
if (c < 10 ** 12)
|
|
39
|
-
return (c / 10 ** 9)
|
|
43
|
+
return Math.round(c / 10 ** 9) + ' B'; // billion
|
|
40
44
|
if (c < 10 ** 15)
|
|
41
|
-
return (c / 10 ** 12)
|
|
45
|
+
return Math.round(c / 10 ** 12) + ' T'; // trillion
|
|
42
46
|
return Math.round(c / 10 ** 12) + ' T';
|
|
43
47
|
}
|
package/package.json
CHANGED
package/src/error/error.model.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface ErrorData {
|
|
|
63
63
|
*
|
|
64
64
|
* Sentry takes string[], but for convenience we allow to pass a singe string.
|
|
65
65
|
*/
|
|
66
|
-
fingerprint?: string
|
|
66
|
+
fingerprint?: string
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Set when throwing an error from your backend code, to indicate desired http status code.
|
package/src/unit/size.util.ts
CHANGED
|
@@ -14,11 +14,13 @@ export function _kb(b: number): number {
|
|
|
14
14
|
* Byte size to Human byte size string
|
|
15
15
|
*/
|
|
16
16
|
export function _hb(b = 0): string {
|
|
17
|
-
if (b <
|
|
18
|
-
if (b <
|
|
19
|
-
if (b < 1024 **
|
|
20
|
-
if (b < 1024 **
|
|
21
|
-
if (b < 1024 **
|
|
17
|
+
if (b < 100) return `${Math.round(b)} byte(s)`
|
|
18
|
+
if (b < 1000) return `${(b / 1024).toFixed(2)} Kb`
|
|
19
|
+
if (b < 0.9 * 1024 ** 2) return `${Math.round(b / 1024)} Kb`
|
|
20
|
+
if (b < 0.9 * 1024 ** 3) return `${Math.round(b / 1024 ** 2)} Mb`
|
|
21
|
+
if (b < 0.09 * 1024 ** 4) return `${(b / 1024 ** 3).toFixed(2)} Gb`
|
|
22
|
+
if (b < 0.9 * 1024 ** 4) return `${Math.round(b / 1024 ** 3)} Gb`
|
|
23
|
+
if (b < 0.9 * 1024 ** 5) return `${(b / 1024 ** 4).toFixed(2)} Tb`
|
|
22
24
|
return `${Math.round(b / 1024 ** 4)} Tb`
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -28,10 +30,10 @@ export function _hb(b = 0): string {
|
|
|
28
30
|
* them more readable.
|
|
29
31
|
*/
|
|
30
32
|
export function _hc(c = 0): string {
|
|
31
|
-
if (c < 10 ** 4) return String(c)
|
|
32
|
-
if (c < 10 ** 6) return (c / 10 ** 3)
|
|
33
|
-
if (c < 10 ** 9) return (c / 10 ** 6)
|
|
34
|
-
if (c < 10 ** 12) return (c / 10 ** 9)
|
|
35
|
-
if (c < 10 ** 15) return (c / 10 ** 12)
|
|
33
|
+
if (c < 10 ** 4) return String(Math.round(c))
|
|
34
|
+
if (c < 10 ** 6) return Math.round(c / 10 ** 3) + ' K'
|
|
35
|
+
if (c < 10 ** 9) return Math.round(c / 10 ** 6) + ' M' // million
|
|
36
|
+
if (c < 10 ** 12) return Math.round(c / 10 ** 9) + ' B' // billion
|
|
37
|
+
if (c < 10 ** 15) return Math.round(c / 10 ** 12) + ' T' // trillion
|
|
36
38
|
return Math.round(c / 10 ** 12) + ' T'
|
|
37
39
|
}
|