1.1.0 • Published 10 months ago

random-number-from-ranges v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Random Number From Ranges

Generate a random number from an array of number ranges

Installation

To add this library to your project run the following command:

$ npm install random-from-ranges

Or if you prefer using Yarn:

$ yarn add random-from-ranges

Usage

// Produces 1, 2, 3, 20, 21, 22, or 23
const myNum = randomFromRanges([[1, 3], [20, 23]])

Ranges must be positive, where the first number is less than the second number of the range, e.g. [3, 1] is invalid while [1, 3] is valid.

Ranges must not overlap, e.g. [[1, 3], [2, 6]] is invalid while [[1, 3], [5, 6]] is valid.

License

MIT License © Andrea SonnY

1.1.0

10 months ago

1.0.0

10 months ago