mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
16 lines
415 B
TypeScript
16 lines
415 B
TypeScript
// Helper to convert CPU K8S units to numbers
|
|
|
|
const thousand = 1000;
|
|
const million = thousand * thousand;
|
|
const shortBillion = thousand * million;
|
|
|
|
export function cpuUnitsToNumber(cpu: string) {
|
|
const cpuNum = parseInt(cpu);
|
|
|
|
if (cpu.includes("m")) return cpuNum / thousand;
|
|
if (cpu.includes("u")) return cpuNum / million;
|
|
if (cpu.includes("n")) return cpuNum / shortBillion;
|
|
|
|
return parseFloat(cpu);
|
|
}
|