MCPcopy Create free account
hub / github.com/activejs/activejs / randomBoolean

Function randomBoolean

packages/core/src/tests/utils.ts:179–182  ·  view source on GitHub ↗
(truthiness = 0)

Source from the content-addressed store, hash-verified

177
178// increased truthiness range: {0, 1}, or negative for decreased truthiness
179export 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
184export function booleanOrRandomValue(validness = 0.7, nestingLvl = 1) {
185 return randomBoolean(validness) ? randomBoolean() : randomValue(nestingLvl);

Callers 15

dispatchRandomValuesFunction · 0.90
units.spec.tsFile · 0.90
action.spec.tsFile · 0.90
extras.spec.tsFile · 0.90
dict-unit.spec.tsFile · 0.90
list-unit.spec.tsFile · 0.90
makeSelectionFunction · 0.90
num-unit.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by 2

dispatchRandomValuesFunction · 0.72
makeSelectionFunction · 0.72