From: Jérôme Benoit Date: Fri, 10 Feb 2023 11:52:44 +0000 (+0100) Subject: refactor(simulator): remove unneeded intermediate variable in helper X-Git-Tag: v1.1.93~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=602d810aef1eebef219b274fc5bfdd42c3ec819d;p=e-mobility-charging-stations-simulator.git refactor(simulator): remove unneeded intermediate variable in helper Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index ab2a8a5f..1f17fe87 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -128,8 +128,7 @@ export default class Utils { if (max - min === Infinity) { throw new RangeError('Invalid interval'); } - const randomPositiveFloat = crypto.randomBytes(4).readUInt32LE() / 0xffffffff; - return randomPositiveFloat * (max - min) + min; + return (crypto.randomBytes(4).readUInt32LE() / 0xffffffff) * (max - min) + min; } public static getRandomInteger(max = Constants.MAX_RANDOM_INTEGER, min = 0): number {