mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
22 lines
423 B
TypeScript
22 lines
423 B
TypeScript
|
export const parsePrometheusFloat = (str: string): number => {
|
||
|
switch (str) {
|
||
|
case "+Inf":
|
||
|
return Infinity;
|
||
|
case "-Inf":
|
||
|
return -Infinity;
|
||
|
default:
|
||
|
return parseFloat(str);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export const formatPrometheusFloat = (num: number): string => {
|
||
|
switch (num) {
|
||
|
case Infinity:
|
||
|
return "+Inf";
|
||
|
case -Infinity:
|
||
|
return "-Inf";
|
||
|
default:
|
||
|
return num.toString();
|
||
|
}
|
||
|
};
|