(truthiness = 0)
| 177 | |
| 178 | // increased truthiness range: {0, 1}, or negative for decreased truthiness |
| 179 | export function randomBoolean(truthiness = 0): boolean { |
| 180 | // .5 becomes true, hence divided to provide range {0, 1} |
| 181 | return !!Math.round(Math.random() + truthiness / 2); |
| 182 | } |
| 183 | |
| 184 | export function booleanOrRandomValue(validness = 0.7, nestingLvl = 1) { |
| 185 | return randomBoolean(validness) ? randomBoolean() : randomValue(nestingLvl); |
no outgoing calls