iching-broker-level1/node_modules/pure-rand/lib/esm/distribution/UnsafeUniformArrayIntDistribution.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

8 lines
646 B
JavaScript

import { addArrayIntToNew, addOneToPositiveArrayInt, substractArrayIntToNew, trimArrayIntInplace, } from './internals/ArrayInt.js';
import { unsafeUniformArrayIntDistributionInternal } from './internals/UnsafeUniformArrayIntDistributionInternal.js';
export function unsafeUniformArrayIntDistribution(from, to, rng) {
var rangeSize = trimArrayIntInplace(addOneToPositiveArrayInt(substractArrayIntToNew(to, from)));
var emptyArrayIntData = rangeSize.data.slice(0);
var g = unsafeUniformArrayIntDistributionInternal(emptyArrayIntData, rangeSize.data, rng);
return trimArrayIntInplace(addArrayIntToNew({ sign: 1, data: g }, from));
}