boo1ean / mersenne-twister

Mersenne Twister pseudorandom number generator
119 stars 23 forks source link

Run in nodejs OR browser #6

Open jeremykentbgross opened 1 year ago

jeremykentbgross commented 1 year ago

Changing the following would allow the same file to be loaded in either nodejs or the browser:

From:

/* These real versions are due to Isaku Wada, 2002/01/09 added */

module.exports = MersenneTwister;

To:

/* These real versions are due to Isaku Wada, 2002/01/09 added */

//Note process should exist only in nodejs, while window exists only in the browser
if(typeof process !== 'undefined' && typeof window === 'undefined')
{
    module.exports = MersenneTwister;
}

If it is not too inconvenient, please apply this change to the repo and update the npm version/package.