Skip to content

Commit

Permalink
Make asHumanHz robust to non-numbers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
smarr committed May 4, 2024
1 parent 8997275 commit 949a62d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/data-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down

0 comments on commit 949a62d

Please sign in to comment.