Skip to content

Commit

Permalink
rename nextReal back to next
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmayer committed Jan 30, 2023
1 parent 9437841 commit c272e9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/internal/mersenne/mersenne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import Twister from './twister';
export interface Mersenne {
/**
* Generates a random float between `[0, 1)`.
* This method is called `next` so that it could be used as a [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol)
*/
nextReal(): number;
next(): number;

/**
* Sets the seed to use.
Expand All @@ -30,7 +31,7 @@ export default function mersenne(): Mersenne {
twister.initGenrand(Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER));

return {
nextReal(): number {
next(): number {
return twister.genrandReal2();
},
seed(seed: number | number[]): void {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class NumberModule {
const mersenne: Mersenne =
// @ts-expect-error: access private member field
this.faker._mersenne;
const real = mersenne.nextReal();
const real = mersenne.next();
return Math.floor(real * (effectiveMax + 1 - effectiveMin) + effectiveMin);
}

Expand Down Expand Up @@ -157,7 +157,7 @@ export class NumberModule {
} else {
// @ts-expect-error: access private member field
const mersenne: Mersenne = this.faker._mersenne;
const real = mersenne.nextReal();
const real = mersenne.next();
return real * (max - min) + min;
}
}
Expand Down

0 comments on commit c272e9f

Please sign in to comment.