@geronimus/random-int

0.1.3 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @geronimus/random-int

      Weekly Downloads

      0

      Version

      0.1.3

      License

      BSD-2-Clause

      Unpacked Size

      3.9 kB

      Total Files

      4

      Last publish

      Collaborators

      • geronimus