Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 1e97253

Browse files
authored
Minor improvements and fixes (#369)
1 parent 5ec625f commit 1e97253

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

src/pages/Stream/Views/Manage/Alerts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ type ColumnRuleProps = {
172172
};
173173

174174
const getInputComponent = (type: 'text' | 'number' | 'timestamp') => {
175-
return type === 'text' || 'timestamp' ? TextInput : NumberInput;
175+
return type === 'text' || type === 'timestamp' ? TextInput : NumberInput;
176176
};
177177

178178
const ColumnRule = (props: ColumnRuleProps) => {

src/utils/convertToReadableScale.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/utils/formatBytes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ export const formatBytes = (a: number, b: number = 1) => {
22
if (!+a) return '0 Bytes';
33
const c = b < 0 ? 0 : b,
44
d = Math.floor(Math.log(a) / Math.log(1024));
5-
return `${parseFloat((a / Math.pow(1024, d)).toFixed(c))} ${
6-
['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'][d]
7-
}`;
5+
return `${parseFloat((a / Math.pow(1024, d)).toFixed(c))} ${['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'][d]
6+
}`;
87
};
98

109
export const convertGibToBytes = (value: number) => {
@@ -13,23 +12,24 @@ export const convertGibToBytes = (value: number) => {
1312
return value * Math.pow(1024, 3);
1413
};
1514

16-
export function HumanizeNumber(val: number) {
15+
export const HumanizeNumber = (val: number) => {
1716
// Thousands, millions, billions etc..
18-
let s = ['', ' K', ' M', ' B', ' T'];
17+
const s = ['', ' K', ' M', ' B', ' T'];
1918

2019
// Dividing the value by 3.
21-
let sNum = Math.floor(('' + val).length / 3);
20+
const sNum = Math.floor(('' + val).length / 3);
2221

2322
// Calculating the precised value.
24-
let sVal = parseFloat((sNum != 0 ? val / Math.pow(1000, sNum) : val).toPrecision(4));
23+
const sVal = parseFloat((sNum != 0 ? val / Math.pow(1000, sNum) : val).toPrecision(4));
2524

2625
if (sVal % 1 != 0) {
2726
return sVal.toFixed(1) + s[sNum];
2827
}
2928

3029
// Appending the letter to precised val.
3130
return sVal + s[sNum];
32-
}
31+
};
32+
3333

3434
export const sanitizeEventsCount = (val: any) => {
3535
return typeof val === 'number' ? HumanizeNumber(val) : '0';

0 commit comments

Comments
 (0)