UNPKG
random-bool
Version:
latest (1.0.2)
1.0.2
1.0.1
1.0.0
0.0.0
Return a random boolean value (true or false).
github.com/mock-end/random-bool
mock-end/random-bool
random-bool
/
index.js
13 lines
(8 loc)
•
225 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
'use strict'
;
var
nil =
require
(
'is-nil'
);
module
.
exports
=
function
(
options
) {
if
(
nil
(options) ||
nil
(options.
likelihood
)) {
return
Math
.
random
() >=
0.5
; }
return
Math
.
random
() *
100
< options.
likelihood
; };