securityos/node_modules/pure-rand/lib/esm/distribution/UnsafeUniformArrayIntDistri...

9 lines
646 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
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));
}