aboutsummaryrefslogtreecommitdiff
path: root/examples/node/generators.js
diff options
context:
space:
mode:
authorCharles Lowell <[email protected]>2021-03-24 16:10:13 +0200
committerCharles Lowell <[email protected]>2021-03-24 16:10:13 +0200
commit194e1a8896067b929315a603acad2e750dfa1526 (patch)
treecacb3c642898c6df0cea627f6d1341f470d23355 /examples/node/generators.js
parent38d8187c3501d5efe3d5644167d4a8174cde6037 (diff)
downloadfaker-194e1a8896067b929315a603acad2e750dfa1526.tar.xz
faker-194e1a8896067b929315a603acad2e750dfa1526.zip
Give each faker instance its own random number generator
Currently, every Faker instance shares the same random number generator instance which means that to seed one faker instance is to seed them all. This can result in duplicate data being generated all over the place. This just extracts the public API of the mersenne twister found in `vendor/mersenne.js` and creates a single instance of it per faker. This implementation is a tad sub-optimal since calling `seed()` on a faker instance will result in two redundant calls to `mersenne.init_genrand()`: one in `random.js` and the other in `datatype.js`. It would probably be more DRY to create the mersenne instance once in faker and then pass it into to the `Random` and `Datatype` instances, however, this takes the strategy of the smallest possible API change.
Diffstat (limited to 'examples/node/generators.js')
0 files changed, 0 insertions, 0 deletions