Skip to content

Latest commit

 

History

History
96 lines (86 loc) · 1.58 KB

randomBoolean.md

File metadata and controls

96 lines (86 loc) · 1.58 KB

piupiu.RandomBoolean: MockFactory<Boolean>

Return a random number / array of numbers.

Source

Since

0.1.0

Description

piupiu.RandomBoolean: MockFactory<Boolean>

Arguments

.getOne({ options?: {truthyThreshold?: number = 0.5})

(boolean): Returns a random boolean.

.getArray({ length?: number, options?: {truthyThreshold?: number = 0.5})

(boolean[]): Returns an Array of random booleans.

Example

piupiu.RandomBoolean.getOne(); 
// true | false
piupiu.RandomBoolean.getOne({
    options: {
        truthyThreshold: 1
    }
}); 
// true
piupiu.RandomBoolean.getOne({
    options: {
        truthyThreshold: 0
    }
}); 
// false
piupiu.RandomBoolean.getOne({
    options: {
        truthyThreshold: 0.5
    }
}); 
// true | false
piupiu.RandomBoolean.getOne({
    options: {
        max: 5
    }
}); 
// [false]
piupiu.RandomBoolean.getOne({
    options: {
        min:2,
        max: 5
    }
}); 
// [false, true]
piupiu.RandomBoolean.getArray(); 
// [false, true]
piupiu.RandomBoolean.getArray({
    length: 3
}); 
// [false, false, true]
piupiu.RandomBoolean.getArray({
    length: 2,
    options: {
        truthyThreshold: 1
    }
}); 
// [true, true]
piupiu.RandomBoolean.getArray({
    length: 4,
    options: {
        truthyThreshold: 0
    }
}); 
// [false, false, false, false]