From: Jérôme Benoit Date: Mon, 7 Nov 2022 11:18:51 +0000 (+0100) Subject: Optimize convertToInt() helper X-Git-Tag: v1.1.87~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3df786f9814812ee9a586da3d8f69d11d25d3033;p=e-mobility-charging-stations-simulator.git Optimize convertToInt() helper Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index d3b9872d..8dda95a6 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -70,14 +70,12 @@ export default class Utils { if (Number.isSafeInteger(value)) { return value as number; } - // Check - if (Utils.isString(value)) { - // Create Object - changedValue = parseInt(value as string); - } if (typeof value === 'number') { changedValue = Math.trunc(value); } + if (Utils.isString(value)) { + changedValue = parseInt(value as string); + } return changedValue; } @@ -86,9 +84,7 @@ export default class Utils { if (!value) { return 0; } - // Check if (Utils.isString(value)) { - // Create Object changedValue = parseFloat(value as string); } return changedValue;