Exports for random module
This commit is contained in:
parent
0367d34592
commit
a85e0219ae
2 changed files with 10 additions and 1 deletions
|
@ -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 }
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue