random-index
v1.0.4
Published
Return a random array-like index.
Downloads
48,767
Maintainers
Readme
random-index
Return a random array-like index.
Install
$ npm install --save random-index
Usage
For more use-cases see the tests
var randomIndex = require('random-index');
// API:
// - randomIndex([options]);
// options
// - min
// - max
randomIndex();
// => 3561
randomIndex({ max: 1 });
// => 1
randomIndex({ min:10, max: 100 });
// => 64
Note: these min
and max
are inclusive, so they are included in the range.
This means randomIndex({max: 2})
would return either 0
, 1
, or 2
.
Related
- random-integral - Return a random integer.
- random-natural - Return a random natural number.
- random-decimal - Return a random decimal.
- random-floating - Return a random floating point number.
- random-binary - Return a random binary number.
- random-octal - Return a random octal number.
- random-hexadecimal - Return a random hexadecimal number.
- random-unicode - Return a random unicode.
- random-bool - Return a random boolean (true/false).
- random-char - Return a random char.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.