Skip to content

Commit

Permalink
docs: expose documentation for randomizers (#3221)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Nov 3, 2024
1 parent cb97682 commit c0a7e23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/apidocs/processing/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ export function processProjectUtilities(project: Project): RawApiDocsPage {
deprecated: undefined,
description: 'A list of all the utilities available in Faker.js.',
examples: [],
methods: processProjectFunctions(project, 'mergeLocales'),
methods: processProjectFunctions(
project,
'mergeLocales',
'generateMersenne32Randomizer',
'generateMersenne53Randomizer'
),
};
}

Expand Down
22 changes: 22 additions & 0 deletions src/utils/mersenne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import type { Randomizer } from '../randomizer';
/**
* Generates a MersenneTwister19937 randomizer with 32 bits of precision.
* This is the default randomizer used by faker prior to v9.0.
*
* @example
* import { de, en, generateMersenne32Randomizer, Faker } from '@faker-js/faker';
*
* const randomizer = generateMersenne32Randomizer();
* randomizer.seed(42);
* // Share the same randomizer between multiple instances
* const customFaker1 = new Faker({ locale: de, randomizer });
* const customFaker2 = new Faker({ locale: en, randomizer });
*
* @since 8.2.0
*/
export function generateMersenne32Randomizer(): Randomizer {
const twister = new MersenneTwister19937();
Expand All @@ -27,6 +38,17 @@ export function generateMersenne32Randomizer(): Randomizer {
/**
* Generates a MersenneTwister19937 randomizer with 53 bits of precision.
* This is the default randomizer used by faker starting with v9.0.
*
* @example
* import { de, en, generateMersenne53Randomizer, Faker } from '@faker-js/faker';
*
* const randomizer = generateMersenne53Randomizer();
* randomizer.seed(42);
* // Share the same randomizer between multiple instances
* const customFaker1 = new Faker({ locale: de, randomizer });
* const customFaker2 = new Faker({ locale: en, randomizer });
*
* @since 9.0.0
*/
export function generateMersenne53Randomizer(): Randomizer {
const twister = new MersenneTwister19937();
Expand Down

0 comments on commit c0a7e23

Please sign in to comment.