How to use the natural function from chance
Find comprehensive JavaScript chance.natural code examples handpicked from public code repositorys.
70 71 72 73 74 75 76 77 78 79
APIRandom.num = function () { 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();
12
33
3
+ 23 other calls in file
92 93 94 95 96 97 98 99 100 101
* Return a natural number. range: 0 to 9007199254740991 * @param {number} min * @param {number} max */ natural(min = 0, max = 9007199254740991) { return chance.natural({ min, max }); }, /** * Return a random sentence populated by semi-pronounceable random (nonsense) words.
5
0
1
+ 3 other calls in file
180 181 182 183 184 185 186 187 188 189
s += chance.name().toCsv(CSV.delimiter); break; case 'natural': n = hdr[k].arg; if (n != "" && (n * 1) >= 0) { s += chance.natural({ max: n }); } else { s += chance.natural();
2
8
0
GitHub: kaitohara/stackstore
43 44 45 46 47 48 49 50 51 52 53 54
var numExAlbums = Math.ceil(numExSongs / songsPerAlbum); function randTitle() { return chance.sentence({ words: chance.natural({ min: 1, max: 6 }) }).slice(0, -1).replace(/\s\w/g, function(match) {
1
1
0
GitHub: ARRiera96/AutherDADA1
19 20 21 22 23 24 25 26 27 28 29
return results; } function randPhoto () { var g = chance.pick(['men', 'women']); var n = chance.natural({ min: 0, max: 96 }); return 'http://api.randomuser.me/portraits/' + g + '/' + n + '.jpg'
1
0
0
+ 8 other calls in file
GitHub: gauthiier/cth2016
31 32 33 34 35 36 37 38 39 40
* Picks a random element from an array * @param {Array} array * @return {Object} choice */ function choice(array) { var index = chance.natural({'min': 0, 'max': array.length - 1}); return array[index]; } /**
1
0
7
GitHub: azcraze/woe-love
14 15 16 17 18 19 20 21 22 23 24 25
} }, delay); } function luck(minPain, maxPain) { return chance.natural({ min: minPain, max: maxPain }); } const victim = 'mad'; const weapon = 'little crying girl sword';
0
1
0
21 22 23 24 25 26 27 28 29
]) for (var i = 0; i < 10; i++) { var city = { id: chance.natural({max: 100}), name: chance.city() + ', ' + chance.state(), streets: [] }
0
1
18
8 9 10 11 12 13 14 15 16 17
symbols: true, length: 8, numeric: true, }); const hour = chance.hour(); const number = chance.natural({ min: 1, max: 15 }); const shortid = require("shortid"); const email = chance.email({ domain: "example.com" }); const address = chance.address({ short_suffix: true }); const city = chance.city();
0
0
0
27 28 29 30 31 32 33 34 35 36
if (!username && (!domain || FREE_EMAIL_DOMAINS.includes(domain))) { badEmail = oneInTwenty() suffix = pickOne([ pickOne(badWords.suffix), chance.natural({ min: 1968, max: 2008 }) ]) } if (username) {
0
0
1
chance.word is the most popular function in chance (344 examples)