@geronimus/random-int
v0.1.3
Published
Generates a pseudo-random integer between the two bounds you specify. (Both inclusive.)
Downloads
2
Readme
randomInt( lowerBound, upperBound )
Generates a pseudo-random integer value between the bounds that you specify. (Both inclusive.)
If either number has a decimal part, it will be truncated.
Both bounds must be between Number.MIN_SAFE_INTEGER
and Number.MAX_SAFE_INTEGER
.
upperBound
must be greater than lowerBound
.
Examples
const randomInt = require( "@geronimus/random-int" );
const randomByteValue = randomInt( 0, 255 );
Parameters
lowerBound
number
The smallest possible random value that can be produced.
upperBound
number
The largest possible random value that can be produced.
Notes
This function uses Math.random()
as a pseudo-random number generator.
Therefore, DO NOT use it for any purpose that must be cryptographically secure.