global undefined
daurnimator opened this issue · 2 comments
daurnimator commented
You define the global
variable as this
.
Line 29 in 616a950
This doesn't work in many contexts (particularly if inside of a "use strict"
); and infact makes your use of global
uninferable by JS tooling.
pgbross commented
Can one not just initialise seedrandom
with a seed to avoid it calling its own internal autoseed()
?
e.g.
const width = 256;
const pool = [];
function tostring(a) {
return String.fromCharCode.apply(0, a);
}
function myAutoseed() {
try {
const out = new Uint8Array(width);
(global.crypto || global.msCrypto).getRandomValues(out);
return tostring(out);
} catch (e) {
const browser = global.navigator;
const plugins = browser && browser.plugins;
return [+new Date(), global, plugins, global.screen, tostring(pool)];
}
}
function main(){
// ...
const rng = seedrandom(myAutoseed());
// ...
}