How to use the floating function from chance
Find comprehensive JavaScript chance.floating code examples handpicked from public code repositorys.
GitHub: noobaa/noobaa-core
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458
// but seems like it would make sense to the stun server // to see the indications coming from the same tid session. this.indication = stun.new_packet(stun.METHODS.INDICATION, null, this.packet); } this.udp.send_outbound(this.indication, this.remote.port, this.remote.address, _.noop); var delay = stun.INDICATION_INTERVAL * chance.floating(stun.INDICATION_JITTER); setTimeout(this.run_udp_indication_loop, delay); }; function make_candidate_key(transport, family, address, port) {
68
227
0
71 72 73 74 75 76 77 78 79 80
var opts = helpers.mix(arguments); var mm = opts.min !== undefined ? {min: Number(opts.min)} : {}; var fix = opts.fixed !== undefined ? {fixed: Number(opts.fixed)} : {}; if (opts.max !== undefined) mm.max = Number(opts.max); if (opts.natural) return chance.natural(mm); if (opts.float) return chance.floating(helpers.mix(mm, fix)); if (opts.dice) return chance.integer({min: 1, max: Number(opts.dice)}); if (opts.age) { if (opts.age === true) return chance.age(); return chance.age({type: opts.age});
12
33
3
+ 23 other calls in file
143 144 145 146 147 148 149 150 151 152
ont_id, // pon_type: 'gpon', // capability: 'bridging_routing', // allow_custom_profiles: false, // catv: false, temperature: chance.floating({ min: -100, max: 100, fixed: 3 }), tx_power: parseFloat((tx_power || '').toLowerCase().replace('dbm', '').trim().replace(/ /gi, ''), 10), olt_rx_power: parseFloat((olt_rx_power || '').toLowerCase().replace('dbm', '').trim().replace(/ /gi, ''), 10), catv_rx_power: 0, onu_type: item.type,
0
1
1
74 75 76 77 78 79 80 81 82 83
* @param {number} min * @param {number} max * @param {number} fixed */ float(min = -90071992547409, max = 90071992547409, fixed = 2) { return chance.floating({ min, max, fixed }); }, /** * Return a random integer. range: -9007199254740991 to 9007199254740991
5
0
1
+ 3 other calls in file
143 144 145 146 147 148 149 150 151 152
break; case 'first': s += chance.first().toCsv(CSV.delimiter); break; case 'float': s += chance.floating(); break; case 'gender': s += chance.gender(); break;
2
8
0
3 4 5 6 7 8 9 10 11 12
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}) } /* get an integer s <= val <= e - note inclusive */ exports.integer = function (s, e) { return ch.integer({min: s, max: e}) } exports.random = function(options) {
0
2
1
+ 3 other calls in file
GitHub: kaitohara/stackstore
96 97 98 99 100 101 102 103 104 105
function randSong(n) { var review = reviews.slice(n * reviewsPerAlbum, (n + 1) * reviewsPerAlbum); var url = chance.pick(songUrls); return { title: randTitle(), price: chance.floating({ fixed: 2, max: 1000, min: 0 }),
1
1
0
+ 2 other calls in file
12 13 14 15 16 17 18 19 20 21
for( var i = 0; i < count; i++ ) { spec.list.push( { type: spec.label, name: chance.word(), value: chance.floating() }); } return staticListRouter.create(spec);
0
1
0
29 30 31 32 33 34 35 36 37 38
} for (var j = 0; j < 50; j++) { city.streets.push({ name: chance.street({short_suffix: true}), length: chance.floating({min: 0, max: 30300, fixed: 4}), color: null }) } city.streets.sort(function(a,b) {
0
1
18
GitHub: BAM-Shopper/BAM-Shopper
79 80 81 82 83 84 85 86 87 88
let movie = movies.pop() return Product.build({ title: movie.title, description: movie.description, imageUrl: movie.imageUrl, price: chance.floating({min: 5, max: 20, fixed: 2}), inventory: chance.integer({min: 0, max: 50}), isAvailible: true }) }
0
1
1
+ 3 other calls in file
24 25 26 27 28 29 30 31 32 33
}); it('should return sum of time spent in each department', () => { const department1 = chance.word(); const department2 = chance.word(); const totalTimeSpentInDepartment1 = chance.floating({min: 0, max: 100000}); const totalTimeSpentInDepartment2 = chance.floating({min: 0, max: 100000}); const workflowStepLedger = { [department1]: { [TIME_SPENT_IN_DEPARTMENT]: totalTimeSpentInDepartment1
0
0
1
+ 13 other calls in file
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336
it('should return the correctly calculated value when at ticket.products contains at least one item', () => { const thisValueIsIgnoredAndThatIsGood = chance.string(); ticketAttributes.products = [ { measureAround: chance.floating({min: 1, fixed: 2}), labelsAround: chance.floating({min: 1, fixed: 2}), }, { measureAround: thisValueIsIgnoredAndThatIsGood,
0
0
0
+ 7 other calls in file
267 268 269 270 271 272 273 274 275
}; ticket = { destination: { department: chance.pickone(departmentsToPickFrom) }, frameSize: chance.floating({min: 1, fixed: 2}), departmentToJobComment: {} }; });
0
0
0
+ 5 other calls in file
28 29 30 31 32 33 34 35 36 37 38 39
return chance.first(options) } // floating export function floating (options) { return chance.floating(options) } // last export function last (options) {
0
0
0
135 136 137 138 139 140 141 142 143 144
ufid: chance.string({ length: 8, pool: '1234567890' }), completion_percent: chance.floating({min: 0, max: 100}), // TODO how is it calculated, when personal_info: { name: { // TODO Why do we have the first and last names in multiple places?
0
0
4
+ 3 other calls in file
chance.word is the most popular function in chance (344 examples)