Comparing version 2.0.0 to 2.0.1
/** | ||
Generate a random integer. | ||
@param minimumValue - Minimum integer to return. Default: `0`. | ||
@param maximumValue - Maximum integer to return. Default: `1`. | ||
@returns An integer from `minimumValue` to `maximumValue`. | ||
@param minimum - Minimum integer to return. Default: `0`. | ||
@param maximum - Maximum integer to return. Default: `1`. | ||
@returns An integer from `minimum` to `maximum`. | ||
@@ -19,5 +19,4 @@ @example | ||
*/ | ||
declare function randomInt(maximumValue?: number): number; | ||
declare function randomInt(minimumValue: number, maximumValue: number): number; | ||
declare function randomInt(minimum?: number, maximum?: number): number; | ||
export = randomInt; |
12
index.js
'use strict'; | ||
module.exports = (minimumValue, maximumValue) => { | ||
if (maximumValue === undefined) { | ||
maximumValue = minimumValue; | ||
minimumValue = 0; | ||
module.exports = (minimum, maximum) => { | ||
if (maximum === undefined) { | ||
maximum = minimum; | ||
minimum = 0; | ||
} | ||
if (typeof minimumValue !== 'number' || typeof maximumValue !== 'number') { | ||
if (typeof minimum !== 'number' || typeof maximum !== 'number') { | ||
throw new TypeError('Expected all arguments to be numbers'); | ||
@@ -14,4 +14,4 @@ } | ||
return Math.floor( | ||
(Math.random() * (maximumValue - minimumValue + 1)) + minimumValue | ||
(Math.random() * (maximum - minimum + 1)) + minimum | ||
); | ||
}; |
{ | ||
"name": "random-int", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Generate a random integer", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -28,13 +28,13 @@ # random-int [![Build Status](https://travis-ci.org/sindresorhus/random-int.svg?branch=master)](https://travis-ci.org/sindresorhus/random-int) | ||
### randomInt([maximumValue]) | ||
### randomInt([maximum]) | ||
Returns an integer from `0` to `maximumValue`. | ||
Returns an integer from `0` to `maximum`. | ||
### randomInt(minimumValue, maximumValue) | ||
### randomInt(minimum, maximum) | ||
Returns an integer from `minimumValue` to `maximumValue`. | ||
Returns an integer from `minimum` to `maximum`. | ||
#### minimumValue | ||
#### minimum | ||
Type: `number` | ||
Type: `number`<br> | ||
Default: `0` | ||
@@ -44,5 +44,5 @@ | ||
#### maximumValue | ||
#### maximum | ||
Type: `number` | ||
Type: `number`<br> | ||
Default: `1` | ||
@@ -49,0 +49,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4011
29