11 lines
267 B
TypeScript
11 lines
267 B
TypeScript
|
export type Prng = () => number;
|
||
|
|
||
|
export function mulberry32(state: number) {
|
||
|
return function () {
|
||
|
let t = (state += 0x6d2b79f5);
|
||
|
t = Math.imul(t ^ (t >>> 15), t | 1);
|
||
|
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
||
|
return (t ^ (t >>> 14)) >>> 0;
|
||
|
};
|
||
|
}
|