odin-js-fundamentals-part-4/node_modules/pure-rand/lib/esm/generator/RandomGenerator.js

23 lines
543 B
JavaScript
Raw Normal View History

2024-01-05 19:30:21 +00:00
export function unsafeGenerateN(rng, num) {
var out = [];
for (var idx = 0; idx != num; ++idx) {
out.push(rng.unsafeNext());
}
return out;
}
export function generateN(rng, num) {
var nextRng = rng.clone();
var out = unsafeGenerateN(nextRng, num);
return [out, nextRng];
}
export function unsafeSkipN(rng, num) {
for (var idx = 0; idx != num; ++idx) {
rng.unsafeNext();
}
}
export function skipN(rng, num) {
var nextRng = rng.clone();
unsafeSkipN(nextRng, num);
return nextRng;
}