-
-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(mersenne): rewrite internal mersenne #1447
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #1447 +/- ##
==========================================
- Coverage 99.63% 99.63% -0.01%
==========================================
Files 2175 2175
Lines 237647 237613 -34
Branches 1021 1009 -12
==========================================
- Hits 236785 236751 -34
Misses 841 841
Partials 21 21
|
56c7a95
to
c97b0d2
Compare
d2e83bb
to
dd3689a
Compare
IMO we could remove the mersenneFn wrapper and integrate these functions in the faker class. |
I think that's the wrong way around. Currently, Faker is tightly coupled with the Mersenne generator. A way better approach would be to require a generator (probably denied from an interface) on construction, thus making the seed generation dependency injectable (follow the dependency inversion principle). This way I could build myself a Faker instance with the underlying generator I want. interface SeedGenerator {
next(): number;
}
class Faker {
// properties
constructor(options: {
// current faker options
generator: SeedGenerator; // could default to a mersenne implementation
}) {
// initialization
}
}
const instance = new Faker({
...defaultFakerOptions,
generator: { next: () => 50 },
]); In my eyes that's a much better approach since it allows for a higher level of abstraction and customization. |
e538ae2
to
eb5749f
Compare
Splitted from #1444
Changes: