random-bool
v1.0.2
Published
Return a random boolean value (true or false).
Downloads
645
Maintainers
Readme
random-bool
Return a random boolean value (
true
orfalse
).
Install
$ npm install --save random-bool
Usage
For more use-cases see the tests.
var randomBool = require('random-bool');
// API
// - randomBool([options])
// options
// - likelihood
The default likelihood of success (returning true
) is 50%
:
randomBool();
// => true
Can optionally specify the likelihood in percent:
randomBool({ likelihood: 30 });
// => false
In this case only a 30%
likelihood of true
, and a 70%
likelihood of false
.
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-index - Return a random array-like index.
- 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-char - Return a random char.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.