From ba33374c6539db6533dd7ac4deb86c240e900063 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 27 Aug 2018 18:57:39 -0400 Subject: [PATCH] Set default limit value --- lib/random/random.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index 99356dc..f75c243 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -12,22 +12,18 @@ class random { */ static init (seed = new Date().getTime()) { random.twister = new MersenneTwister() - random.twister.seed(random.seed) + random.twister.seed(seed) } /** * Returns an integer in [0, limit) (uniform distribution) * @param {number} limit */ - static number (limit) { + static number (limit = 0xffffffff) { if (!random.twister) { throw new Error('random.init must be called first.') } - if (limit === null || limit === undefined) { - limit = 0xffffffff - } - let x = (0x100000000 / limit) >>> 0 let y = (x * limit) >>> 0 let r