Download node_modules/fast-check/lib/random/generator/Random.js from Really-amin/Datasourceforcryptocurrency: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency/resolve/250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/random/generator/Random.js
- Command line
-
hf download hf://spaces/Really-amin/Datasourceforcryptocurrency@250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/random/generator/Random.js
-
curl -L -o Random.js https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency/resolve/250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/random/generator/Random.js
1.51 kB
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.Random = void 0; | |
| const pure_rand_1 = require("pure-rand"); | |
| class Random { | |
| constructor(sourceRng) { | |
| this.internalRng = sourceRng.clone(); | |
| } | |
| clone() { | |
| return new Random(this.internalRng); | |
| } | |
| next(bits) { | |
| return (0, pure_rand_1.unsafeUniformIntDistribution)(0, (1 << bits) - 1, this.internalRng); | |
| } | |
| nextBoolean() { | |
| return (0, pure_rand_1.unsafeUniformIntDistribution)(0, 1, this.internalRng) == 1; | |
| } | |
| nextInt(min, max) { | |
| return (0, pure_rand_1.unsafeUniformIntDistribution)(min == null ? Random.MIN_INT : min, max == null ? Random.MAX_INT : max, this.internalRng); | |
| } | |
| nextBigInt(min, max) { | |
| return (0, pure_rand_1.unsafeUniformBigIntDistribution)(min, max, this.internalRng); | |
| } | |
| nextArrayInt(min, max) { | |
| return (0, pure_rand_1.unsafeUniformArrayIntDistribution)(min, max, this.internalRng); | |
| } | |
| nextDouble() { | |
| const a = this.next(26); | |
| const b = this.next(27); | |
| return (a * Random.DBL_FACTOR + b) * Random.DBL_DIVISOR; | |
| } | |
| getState() { | |
| if ('getState' in this.internalRng && typeof this.internalRng.getState === 'function') { | |
| return this.internalRng.getState(); | |
| } | |
| return undefined; | |
| } | |
| } | |
| exports.Random = Random; | |
| Random.MIN_INT = 0x80000000 | 0; | |
| Random.MAX_INT = 0x7fffffff | 0; | |
| Random.DBL_FACTOR = Math.pow(2, 27); | |
| Random.DBL_DIVISOR = Math.pow(2, -53); | |