From a85e0219ae28915bb81e5cca1180188a6267f709 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Sat, 17 Mar 2018 23:02:23 +0100 Subject: [PATCH] Exports for random module --- lib/random/mersennetwister.js | 2 ++ lib/random/random.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/random/mersennetwister.js b/lib/random/mersennetwister.js index 56dd7df..ddf8e20 100644 --- a/lib/random/mersennetwister.js +++ b/lib/random/mersennetwister.js @@ -84,3 +84,5 @@ function MersenneTwister () { // eslint-disable-line no-unused-vars return ((this.int32() >>> 5) * 67108864.0 + (this.int32() >>> 6)) / 9007199254740992.0 } } + +module.exports = { MersenneTwister } \ No newline at end of file diff --git a/lib/random/random.js b/lib/random/random.js index 3811eef..247a3c4 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const MersenneTwister = require('./mersennetwister') + var random = { // eslint-disable-line no-unused-vars seed: null, twister: null, @@ -14,7 +16,7 @@ var random = { // eslint-disable-line no-unused-vars if (seed === null || seed === undefined) { this.seed = new Date().getTime() } - this.twister = new MersenneTwister() + this.twister = new MersenneTwister.MersenneTwister() this.twister.seed(this.seed) }, number: function (limit) { @@ -166,3 +168,8 @@ var random = { // eslint-disable-line no-unused-vars return this.number(Math.pow(2, len * 4)).toString(16) } } + +module.exports = { + random, + MersenneTwister +}