From: Jérôme Benoit Date: Sat, 24 Feb 2024 13:05:07 +0000 (+0100) Subject: refactor: cleanup integer conversion helper X-Git-Tag: v1.2.38~48 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f5ee14038709c759f86a9f98f90719c9f7f750be;p=e-mobility-charging-stations-simulator.git refactor: cleanup integer conversion helper Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 12c206ff..abfac5e4 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -102,13 +102,13 @@ export const convertToInt = (value: unknown): number => { if (value == null) { return 0 } - let changedValue: number = value as number if (Number.isSafeInteger(value)) { return value as number } if (typeof value === 'number') { return Math.trunc(value) } + let changedValue: number = value as number if (isString(value)) { changedValue = parseInt(value) } diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 5638efe2..451c4155 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -17,13 +17,13 @@ export const convertToInt = (value: unknown): number => { if (value == null) { return 0 } - let changedValue: number = value as number if (Number.isSafeInteger(value)) { return value as number } if (typeof value === 'number') { return Math.trunc(value) } + let changedValue: number = value as number if (typeof value === 'string') { changedValue = parseInt(value) }