From b4defa324a330217f0139f1240bcf53c0b1f996a Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 2 Jun 2022 23:13:07 +0200 Subject: v1.0.0 --- src/helpers.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/helpers.ts') diff --git a/src/helpers.ts b/src/helpers.ts index 9bb1eac..a867b1e 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -11,3 +11,8 @@ export function random(p: number): boolean { if (p < 0 || p > 1) throw Error("Wrong probability - " + p) return Math.random() < p; } +export function randomInteger(min: number, max: number) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} -- cgit v1.3.1