File size: 497 Bytes
fc0f7bd
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { AccuracyOptions } from "./AccuracyMetrics";

export class FormatMetrics {
    public static formatNumbers = (value: number, key: string, isRatio: boolean = false): string => {
    if (value === null || value === undefined) {
        return NaN.toString();
    }
    const styleObject = {maximumSignificantDigits: 3};
    if (AccuracyOptions[key].isPercentage && !isRatio) {
        (styleObject as any).style = "percent";
    }
    return value.toLocaleString(undefined, styleObject);
}
}