12 lines
304 B
TypeScript
12 lines
304 B
TypeScript
export type Prng = () => number;
|
|
|
|
export const UINT_MAX = 0xffffffff;
|
|
|
|
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;
|
|
};
|
|
}
|