Skip to content

Commit

Permalink
Avoid using eval() to get global object.
Browse files Browse the repository at this point in the history
  • Loading branch information
louh authored and davidbau committed Sep 17, 2019
1 parent d5ebbe4 commit 5f2ec42
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions seedrandom.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

(function (pool, math) {
(function (global, pool, math) {
//
// The following constants are related to IEEE 754 limits.
//

// Detect the global object, even if operating in strict mode.
// http://stackoverflow.com/a/14387057/265298
var global = (0, eval)('this'),
width = 256, // each RC4 output is 0 <= x < 256
var width = 256, // each RC4 output is 0 <= x < 256
chunks = 6, // at least six RC4 outputs for each double
digits = 52, // there are 52 significant digits in a double
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
Expand Down Expand Up @@ -248,6 +245,9 @@ if ((typeof module) == 'object' && module.exports) {

// End anonymous scope, and pass initial values.
})(
// global: `self` in browsers (including strict mode and web workers),
// otherwise `this` in Node and other environments
(typeof self !== 'undefined') ? self : this,
[], // pool: entropy pool starts empty
Math // math: package containing random, pow, and seedrandom
);

0 comments on commit 5f2ec42

Please sign in to comment.