Exports for random module

This commit is contained in:
Christoph Diehl 2018-03-17 23:02:23 +01:00
parent 0367d34592
commit a85e0219ae
No known key found for this signature in database
GPG key ID: 799CE5B68FEF404A
2 changed files with 10 additions and 1 deletions

View file

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

View file

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