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 - npm Package Compare versions

Comparing version
3.0.0
to
3.1.0
+2
-0
index.d.ts
/**
Generate a random integer.
If `minimum` is greater than `maximum`, the values are swapped to return an integer from the lower value to the higher value.
@param minimum - Minimum integer to return. Default: `0`.

@@ -5,0 +7,0 @@ @param maximum - Maximum integer to return. Default: `1`.

+4
-1

@@ -11,5 +11,8 @@ export default function randomInteger(minimum, maximum) {

const actualMinimum = Math.min(minimum, maximum);
const actualMaximum = Math.max(minimum, maximum);
return Math.floor(
(Math.random() * (maximum - minimum + 1)) + minimum
(Math.random() * (actualMaximum - actualMinimum + 1)) + actualMinimum
);
}
{
"name": "random-int",
"version": "3.0.0",
"version": "3.1.0",
"description": "Generate a random integer",

@@ -15,2 +15,4 @@ "license": "MIT",

"exports": "./index.js",
"types": "./index.d.ts",
"sideEffects": false,
"engines": {

@@ -20,3 +22,4 @@ "node": ">=12"

"scripts": {
"test": "xo && ava && tsd"
"//test": "xo && ava && tsd",
"test": "ava"
},

@@ -42,3 +45,3 @@ "files": [

"in-range": "^3.0.0",
"stable-fn": "^3.0.0",
"stable-function": "^4.0.0",
"tsd": "^0.14.0",

@@ -45,0 +48,0 @@ "xo": "^0.38.2"

@@ -7,5 +7,5 @@ # random-int

```sh
npm install random-int
```
$ npm install random-int
```

@@ -34,2 +34,4 @@ ## Usage

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

@@ -53,6 +55,6 @@

- [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array
- [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
- [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
- [random-object-key](https://github.com/sindresorhus/random-object-key) - Get a random key from an object
- [random-object-value](https://github.com/sindresorhus/random-object-value) - Get a random value from an object
- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
- [unique-random-array](https://github.com/sindresorhus/unique-random-array) - Get consecutively unique elements from an array
- [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string