@mothepro/fancy-p2p
Version:
A quick and efficient way to form p2p groups in the browser
13 lines • 570 B
JavaScript
/**
* Yields a random integer using Multiply with carry PRNG within [-2 ** 31, 2 ** 31).
* https://en.wikipedia.org/wiki/Multiply-with-carry_pseudorandom_number_generator
*/
export default function* (seed) {
let multiplier = 987654321;
while (true) {
multiplier = (36969 * (multiplier & 65535 /* SHORT */) + (multiplier >> 16)) & 4294967295 /* INT */;
seed = (18000 * (seed & 65535 /* SHORT */) + (seed >> 16)) & 4294967295 /* INT */;
yield ((multiplier << 16) + seed) & 4294967295 /* INT */;
}
}
//# sourceMappingURL=random.js.map