How to use the bool function from chance
Find comprehensive JavaScript chance.bool code examples handpicked from public code repositorys.
783 784 785 786 787 788 789 790 791 792
it("should select an option (true, false)", function() { dropdowns.forEach(function(dropdown) { if (isEditMode && (dropdown.column.generated || dropdown.column.immutable)) return; var value = getRecordInput(dropdown.column.name, chance.bool()); chaisePage.recordEditPage.selectDropdownValue(dropdown.dropdownInput, value).then(function(option) { expect(chaisePage.recordEditPage.getDropdownText(dropdown.dropdownInput).getText()).toBe(value + "", colError(dropdown.column.name, "Couldn't select a value.")); }).catch(function (error) {
6
10
14
GitHub: sylvainv/pg-manati
148 149 150 151 152 153 154 155 156 157
function (cb) { test.app.post('/data/misc_data') .set('Content-Type', 'application/json') .send(data = { 'money_data': chance.dollar({max:999}), 'bool_data': chance.bool(), 'mood_data': chance.pickset(['sad', 'ok', 'happy'], 1)[0], 'bit_data': '101' }) .expect(200, [data])
2
5
4
128 129 130 131 132 133 134 135 136 137
if (oSpec.hasOwnProperty(key) && oSpec[key].mand) mandRscKeys.push(key); } for (key in oSpec) { if (oSpec.hasOwnProperty(key) && !oSpec[key].mand && chance.bool()) mandRscKeys.push(key); } mandRscKeys.forEach(function (ridStr) {
1
5
6
+ 5 other calls in file
17 18 19 20 21 22 23 24 25 26
}) => { const f_p_s = `${board}/${slot}/${port}` const randomStatus = () => { return chance.bool({ likelihood: 80 }) ? 'working' : chance.bool({ likelihood: 50 }) ? 'LOS' : 'DyingGasp' } const randomDbaMode = () => {
0
1
1
+ 9 other calls in file
45 46 47 48 49 50 51 52 53 54
* The default likelihood of success (returning true) is 50%. Can optionally specify the likelihood in percent. * chance.bool({likelihood: 30}): In this case only a 30% likelihood of true, and a 70% likelihood of false. * @param {number} likelihood */ bool(likelihood = 50) { return chance.bool({likelihood}); }, /** * By default it will return a string with random character from the specified pool.
5
0
1
+ 7 other calls in file
65 66 67 68 69 70 71 72 73 74
}).toCsv(CSV.delimiter); break; } break; case 'bool': s += chance.bool(); break; case 'city': s += chance.city().toCsv(CSV.delimiter); break;
2
8
0
124 125 126 127 128 129 130 131 132 133
}; Controller.prototype._devAttrRandomChanges = function (eventType) { var dev = this._pickDevice(); var pickAttrs = [ 'ip', 'version' ]; var numPicks = chance.bool() ? 2 : 1; var picked; var devChanges = { dev: dev, data: {}
1
5
6
GitHub: gauthiier/cth2016
42 43 44 45 46 47 48 49 50 51
* @param {Array} array * @return {Object} choice * @return {String} empty string */ function maybe(array) { if( chance.bool() ) { return choice(array); } else { return ''; }
1
0
7
GitHub: ejfox/coachartie_discord
604 605 606 607 608 609 610 611 612 613
tweetEvaluation = tweetEvaluation.content // let tweetEvaluation = 50 // If the score is high enough, tweet it if (+tweetEvaluation >= 70 && chance.bool()) { console.log('🤖 I think this exchange is cool enough to tweet. Let me ask...') // set the time to collect reactions const collectionTimeMs = 60000
0
2
0
+ 2 other calls in file
152 153 154 155 156 157 158 159 160 161 162
function generateRelationships(users) { const relationships = []; for (const user1 of users) { for (const user2 of users) { if (user1 != user2 && chance.bool({ likelihood: 50 })) { relationships.push({ PK: user1.PK, SK: user2.PK, __typename: "FOLLOW",
0
2
0
0 1 2 3 4 5 6 7 8
var ch = require('chance').Chance() exports.index = function () { return index++ } exports.guid = function () { return ch.guid().toLowerCase() } exports.bool = function () { return ch.bool() } /* get a float s <= val <= e - not inclusive */ exports.floating = function (s, e) { return ch.floating({min: s, max: e}) }
0
2
1
+ 3 other calls in file
5 6 7 8 9 10 11 12 13 14
module.exports = async({ jobCount = 5, noteCount = 60, resumeCount = 10 } = {}) => { const jobsArray = [...Array(jobCount)].map(() => ({ title: chance.profession(), author: chance.phone(), company: chance.company(), active: chance.bool(), jobDescriptionText: chance.word(), jobUrl: chance.word(), salary: chance.word(), location: chance.zip(),
2
0
0
50 51 52 53 54 55 56 57 58 59
return headsOrTails(likelihood) } } function headsOrTails(likelihood = 50) { return chance.bool({ likelihood }) } // 5% function oneInTwenty(x, y) {
0
0
1
151 152 153 154 155 156 157 158 159 160
has_ssn: true, // TODO SSN: chance.string({ length: 9, pool: '1234567890' }), previous_application: chance.bool(), previous_attendance: chance.bool(), application_started: true, // TODO When would this ever be false? application_complete: false, // TODO application_submitted: false, // TODO
0
0
4
+ 31 other calls in file
chance.word is the most popular function in chance (344 examples)