-
-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infra: update file structure for util/internal (#3141)
- Loading branch information
1 parent
424b120
commit 9537dfd
Showing
17 changed files
with
68 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { MersenneTwister19937 } from '../internal/mersenne'; | ||
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. | ||
*/ | ||
export function generateMersenne32Randomizer(): Randomizer { | ||
const twister = new MersenneTwister19937(); | ||
|
||
twister.initGenrand(Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)); | ||
|
||
return { | ||
next(): number { | ||
return twister.genrandReal2(); | ||
}, | ||
seed(seed: number | number[]): void { | ||
if (typeof seed === 'number') { | ||
twister.initGenrand(seed); | ||
} else if (Array.isArray(seed)) { | ||
twister.initByArray(seed, seed.length); | ||
} | ||
}, | ||
}; | ||
} | ||
|
||
/** | ||
* Generates a MersenneTwister19937 randomizer with 53 bits of precision. | ||
* This is the default randomizer used by faker starting with v9.0. | ||
*/ | ||
export function generateMersenne53Randomizer(): Randomizer { | ||
const twister = new MersenneTwister19937(); | ||
|
||
twister.initGenrand(Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)); | ||
|
||
return { | ||
next(): number { | ||
return twister.genrandRes53(); | ||
}, | ||
seed(seed: number | number[]): void { | ||
if (typeof seed === 'number') { | ||
twister.initGenrand(seed); | ||
} else if (Array.isArray(seed)) { | ||
twister.initByArray(seed, seed.length); | ||
} | ||
}, | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
test/locale-proxy.spec.ts → test/internal/locale-proxy.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters