From 194e1a8896067b929315a603acad2e750dfa1526 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Wed, 24 Mar 2021 16:10:13 +0200 Subject: 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. --- test/support/function-helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/support/function-helpers.js') diff --git a/test/support/function-helpers.js b/test/support/function-helpers.js index 326da61a..5411ac71 100644 --- a/test/support/function-helpers.js +++ b/test/support/function-helpers.js @@ -9,7 +9,7 @@ var functionHelpers = {}; module.exports = functionHelpers; -var IGNORED_MODULES = ['locales', 'locale', 'localeFallback', 'definitions', 'fake', 'helpers']; +var IGNORED_MODULES = ['locales', 'locale', 'localeFallback', 'definitions', 'fake', 'helpers', 'mersenne']; var IGNORED_METHODS = { system: ['directoryPath', 'filePath'] // these are TODOs }; -- cgit v1.2.3