Skip to content

Commit

Permalink
🏷️ Expose internal state of generators (#694)
Browse files Browse the repository at this point in the history
Exposing the internal state of our generators is a requirement for some extra features on fast-check (see dubzzz/fast-check#4063).

This PR only adds the capability on the type definition of our `RandomGenerator`. Next PRs will connect it generator by generator.
  • Loading branch information
dubzzz committed Mar 20, 2024
1 parent 5d53dc0 commit 1f6c3a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/generator/RandomGenerator.ts
Expand Up @@ -15,6 +15,8 @@ export interface RandomGenerator {
unsafeNext(): number;
/** Jump current generator */
unsafeJump?(): void;
/** Access to the internal state of a RandomGenerator in a read-only fashion */
getState?(): readonly number[];
}

export function unsafeGenerateN(rng: RandomGenerator, num: number): number[] {
Expand Down

0 comments on commit 1f6c3a5

Please sign in to comment.