mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 06:07:11 +02: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();
|
|
}
|
|
};
|