random-natural

1.0.3 • Public • Published

random-natural

Return a natural number.

MIT License

build:? coverage:?

Install

$ npm install --save random-natural

Usage

For more use-cases see the tests

var randomNatural = require('random-natural');
 
// API
// - randomNatural([options])
 
// options
// - min
// - max

By default it will return an integer between 0 and 9007199254740992:

randomNatural();
// => 9527

Can optionally provide min and max:

randomNatural({ max: 5 });
// => 3
 
randomNatural({ min: 10, max: 100 });
// => 66

Note:

These min and max are inclusive, so they are included in the range.

This means randomNatural({ min: 1, max: 3 }) would return either 1, 2, or 3.

// Specific case
1 <= random number <= 3
 
// General case
min <= random number <= max

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    35,326
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    35,326
  • 1.0.2
    7
  • 1.0.1
    7
  • 1.0.0
    7
  • 0.0.0
    7

Package Sidebar

Install

npm i random-natural

Weekly Downloads

28,069

Version

1.0.3

License

MIT

Last publish

Collaborators

  • bubkoo