sindresorhus / random-int

Generate a random integer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

random-int

Generate a random integer

Install

$ npm install random-int

Usage

import randomInteger from 'random-int';

randomInteger(5);
//=> 3

randomInteger(10, 100);
//=> 54

API

randomInteger(maximum?)

Returns an integer from 0 to maximum.

randomInteger(minimum, maximum)

Returns an integer from minimum to maximum.

minimum

Type: number
Default: 0

Minimum integer to return.

maximum

Type: number
Default: 1

Maximum integer to return.

Related

About

Generate a random integer

License:MIT License


Languages

Language:JavaScript 87.7%Language:TypeScript 12.3%