You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

random-int

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-int

Generate a random integer

latest
Source
npmnpm
Version
3.1.0
Version published
Weekly downloads
265K
-36.55%
Maintainers
1
Weekly downloads
 
Created
Source

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.

If minimum is greater than maximum, the values are swapped to return an integer from the lower value to the higher value.

minimum

Type: number
Default: 0

Minimum integer to return.

maximum

Type: number
Default: 1

Maximum integer to return.

  • random-float - Generate a random float
  • random-item - Get a random item from an array
  • random-object-key - Get a random key from an object
  • random-object-value - Get a random value from an object
  • unique-random - Generate random numbers that are consecutively unique
  • unique-random-array - Get consecutively unique elements from an array
  • crypto-random-string - Generate a cryptographically strong random string

Keywords

random

FAQs

Package last updated on 15 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts