* feat: add pi hole summary integration * feat: add pi hole summary widget * fix: type issues with integrations and integrationIds * feat: add middleware for integrations and improve cache redis channel * feat: add error boundary for widgets * fix: broken lock file * fix: format format issues * fix: typecheck issue * fix: deepsource issues * fix: widget sandbox without error boundary * chore: address pull request feedback * chore: remove todo comment and created issue * fix: format issues * fix: deepsource issue
18 lines
488 B
TypeScript
18 lines
488 B
TypeScript
const ranges = [
|
|
{ divider: 1e18, suffix: "E" },
|
|
{ divider: 1e15, suffix: "P" },
|
|
{ divider: 1e12, suffix: "T" },
|
|
{ divider: 1e9, suffix: "G" },
|
|
{ divider: 1e6, suffix: "M" },
|
|
{ divider: 1e3, suffix: "k" },
|
|
];
|
|
|
|
export const formatNumber = (value: number, decimalPlaces: number) => {
|
|
for (const range of ranges) {
|
|
if (value < range.divider) continue;
|
|
|
|
return (value / range.divider).toFixed(decimalPlaces) + range.suffix;
|
|
}
|
|
return value.toFixed(decimalPlaces);
|
|
};
|