Skip to content

Commit 3cd5090

Browse files
committed
refactor: move convertToNumber into utils
1 parent 21ccb63 commit 3cd5090

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/components/MetricChart/getDefaultDataFormatter.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {formatBytes} from '../../utils/bytesParsers';
22
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
33
import {roundToPrecision} from '../../utils/dataFormatters/dataFormatters';
44
import {formatToMs} from '../../utils/timeParsers';
5-
import {isNumeric} from '../../utils/utils';
5+
import {convertToNumber} from '../../utils/utils';
66

77
import type {ChartDataType, ChartValue} from './types';
88

@@ -43,12 +43,3 @@ function formatChartValueToPercent(value: ChartValue) {
4343
}
4444
return Math.round(convertToNumber(value) * 100) + '%';
4545
}
46-
47-
// Numeric values expected, not numeric value should be displayd as 0
48-
function convertToNumber(value: unknown): number {
49-
if (isNumeric(value)) {
50-
return Number(value);
51-
}
52-
53-
return 0;
54-
}

src/utils/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,12 @@ export function toExponential(value: number, precision?: number) {
9797
}
9898

9999
export const UNBREAKABLE_GAP = '\xa0';
100+
101+
// Numeric values expected, not numeric value should be displayd as 0
102+
export function convertToNumber(value: unknown): number {
103+
if (isNumeric(value)) {
104+
return Number(value);
105+
}
106+
107+
return 0;
108+
}

0 commit comments

Comments
 (0)