From 5f9718372198f6c23583c3d33f8d0e3987fc3cd0 Mon Sep 17 00:00:00 2001
From: Stefan Marr <git@stefan-marr.de>
Date: Sat, 4 May 2024 11:21:08 +0100
Subject: [PATCH] Make asHumanHz robust to non-numbers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I am seeing a strange error in the logs, and can’t explain it otherwise, because there’s a test for asHumanHz(0).

Signed-off-by: Stefan Marr <git@stefan-marr.de>
---
 src/shared/data-format.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/data-format.ts b/src/shared/data-format.ts
index cf5eb9df..0cf98bff 100644
--- a/src/shared/data-format.ts
+++ b/src/shared/data-format.ts
@@ -53,7 +53,7 @@ export function asHumanMem(val: number, digits = 0): string {
  * As frequency value rounded to an appropriate unit.
  */
 export function asHumanHz(val: number, digits = 0): string {
-  if (isNaN(val)) {
+  if (isNaN(val) || typeof val !== 'number') {
     return '';
   }