From: Jérôme Benoit Date: Mon, 9 May 2022 07:01:43 +0000 (+0200) Subject: Properly handle NaN in Math.min usage X-Git-Tag: v1.1.60~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f126aa15c2efd27cc174011b8eb4e5bfdf27b73c;p=e-mobility-charging-stations-simulator.git Properly handle NaN in Math.min usage Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 9d7cf620..7a1fde29 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -9,8 +9,9 @@ export class OCPPServiceUtils { ): number { options.limitationEnabled = options?.limitationEnabled ?? true; options.unitMultiplier = options?.unitMultiplier ?? 1; + const numberValue = isNaN(parseInt(value)) ? Infinity : parseInt(value); return options?.limitationEnabled - ? Math.min(parseInt(value) * options.unitMultiplier, limit) - : parseInt(value) * options.unitMultiplier; + ? Math.min(numberValue * options.unitMultiplier, limit) + : numberValue * options.unitMultiplier; } }