Use native Math.random since it's fixed
This commit is contained in:
parent
2b4abdb142
commit
2f16696fbc
18
walnut.js
18
walnut.js
|
@ -4,24 +4,6 @@ var cluster = require('cluster');
|
||||||
|
|
||||||
var crypto;
|
var crypto;
|
||||||
var stacks = {};
|
var stacks = {};
|
||||||
function realRandom() {
|
|
||||||
return parseFloat(('0.' + (parseInt(crypto.randomBytes(8).toString('hex'), 16))).replace(/(^0)|(0$)/g, ''));
|
|
||||||
}
|
|
||||||
Math.random = function () {
|
|
||||||
var err = new Error("Math.random() was used");
|
|
||||||
|
|
||||||
if (!stacks[err.stack.toString()]) {
|
|
||||||
stacks[err.stack.toString()] = true;
|
|
||||||
console.warn(err.stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!crypto) {
|
|
||||||
crypto = require('crypto');
|
|
||||||
}
|
|
||||||
|
|
||||||
Math.random = realRandom;
|
|
||||||
return realRandom();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
require('./boot/master');
|
require('./boot/master');
|
||||||
|
|
Loading…
Reference in New Issue