odin-js-fundamentals-part-4/node_modules/pure-rand/lib/esm/distribution/UnsafeUniformArrayIntDistri...

9 lines
646 B
JavaScript
Raw Normal View History

2024-01-05 19:30:21 +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));
}