From b5e5892dcdc7cc3c68431fb15384dfea0979dec6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 14 Oct 2022 13:56:16 +0200 Subject: [PATCH] Default maximum random number generation to safe values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index a1b8a8a9..f297f228 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -103,7 +103,7 @@ export default class Utils { return result; } - public static getRandomFloat(max: number, min = 0, negative = false): number { + public static getRandomFloat(max = Number.MAX_VALUE, min = 0, negative = false): number { if (max < min || min < 0 || max < 0) { throw new RangeError('Invalid interval'); } @@ -112,7 +112,7 @@ export default class Utils { return sign * (randomPositiveFloat * (max - min) + min); } - public static getRandomInteger(max: number, min = 0): number { + public static getRandomInteger(max = Number.MAX_SAFE_INTEGER, min = 0): number { if (max < 0) { throw new RangeError('Invalid interval'); } @@ -137,7 +137,7 @@ export default class Utils { return Math.trunc(numberValue * truncPower) / truncPower; } - public static getRandomFloatRounded(max: number, min = 0, scale = 2): number { + public static getRandomFloatRounded(max = Number.MAX_VALUE, min = 0, scale = 2): number { if (min) { return Utils.roundTo(Utils.getRandomFloat(max, min), scale); } -- 2.34.1