iching-broker-level1/node_modules/pure-rand/lib/distribution/internals/UnsafeUniformIntDistributionInternal.js
Christopher Hase 323cea883d
All checks were successful
ci / build (push) Successful in 1m14s
unit tests part 3
2025-03-31 14:27:20 +02:00

12 lines
507 B
JavaScript

"use strict";
exports.__esModule = true;
exports.unsafeUniformIntDistributionInternal = void 0;
function unsafeUniformIntDistributionInternal(rangeSize, rng) {
var MaxAllowed = rangeSize > 2 ? ~~(0x100000000 / rangeSize) * rangeSize : 0x100000000;
var deltaV = rng.unsafeNext() + 0x80000000;
while (deltaV >= MaxAllowed) {
deltaV = rng.unsafeNext() + 0x80000000;
}
return deltaV % rangeSize;
}
exports.unsafeUniformIntDistributionInternal = unsafeUniformIntDistributionInternal;