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 +}