Skip to content

Function: randomInt() ​

ts
function randomInt(source, n): number;

Defined in: src/random.ts:95

A fair integer in [0, n). Rejection sampling, never next() % n: the modulo leans towards the low faces whenever n does not divide 2^32, and a d6 or a d10 does not.

Parameters ​

source ​

RandomSource

n ​

number

Returns ​

number

MIT © John Morris