How to use the first function from chance
Find comprehensive JavaScript chance.first code examples handpicked from public code repositorys.
111 112 113 114 115 116 117 118 119 120
* name('prefix', {gender: 'male', middle: 'full'}); */ APIRandom.name = function () { var opts = helpers.mix(arguments); var g = opts.gender ? {gender: opts.gender} : {}; if (opts.first) return chance.first(g); if (opts.last) return chance.last(g); var m = {}, p = {}, prefix = '', name; if (opts.middle) m = opts.middle === 'full' ? {middle: true} : {middle_initial: true};
12
33
3
34 35 36 37 38 39 40 41 42 43
const bday = Chance.birthday(); // basic demographics const person = { names: [{ givenName: Chance.first({ gender, }), familyName: Chance.last({ gender,
8
16
5
+ 9 other calls in file
18 19 20 21 22 23 24 25 26 27
return db.run(tableQuery) }) .then(() => { const lastNames = ['Doggo', 'Pupster', 'Smith', 'Wolf'] const puppies = longArray(100).map(() => { const first = chance.first() const last = lastNames[Math.floor(Math.random() * 4)] const ssn = chance.ssn() const callsign = chance.radio() const age = Math.floor(chance.age() / 7)
0
1
1
+ 5 other calls in file
129 130 131 132 133 134 135 136 137 138
function generateList(limit = 100){ var arr = new Array(limit) for(var i = 0; i < arr.length; i++){ var first = chance.first(), last = chance.last() arr[i] = { id: i + 1, name: `${first} ${last}`, first, surname: last } } return arr
407
0
5
+ 5 other calls in file
25 26 27 28 29 30 31 32 33 34
return results; } function randUser () { return User.build({ firstName: chance.first(), lastName: chance.last(), isAdmin: false, email: emails.pop(), gender: chance.gender(),
3
12
6
+ 3 other calls in file
140 141 142 143 144 145 146 147 148 149
break; case 'email': s += chance.email().toCsv(CSV.delimiter); break; case 'first': s += chance.first().toCsv(CSV.delimiter); break; case 'float': s += chance.floating(); break;
2
8
0
54 55 56 57 58 59 60 61 62
} }, student: (options = {}) => ({ id: random.integer({ min: 10000000, max: 999999999 }).toString(), name: random.first(), email: random.email(), ...options }),
4
3
0
36 37 38 39 40 41 42 43 44 45
it('The user can fetch his profile with getMyProfile', () => { cy.gql({token, query: getMyProfile}).should(spok({id, ...matchProfile})) }) it('The user can edit their profile with editMyProfile', () => { const newName = chance.first() cy.gql({ token, query: editMyProfile,
0
3
0
11 12 13 14 15 16 17 18 19 20
exports.integer = function (s, e) { return ch.integer({min: s, max: e}) } exports.random = function(options) { return ch.pick(options) } exports.pick = exports.random exports.firstName = function () { return ch.first() } exports.lastName = function () { return ch.last() } exports.gender = function () { return ch.gender() } exports.company = function () { return ch.capitalize(ch.word({syllables: 3})) } exports.email = function () { return ch.email() }
0
2
1
+ 3 other calls in file
GitHub: kaitohara/stackstore
54 55 56 57 58 59 60 61 62 63 64 65
}); } function randArtist() { return { name: chance.first() + ' ' + chance.last() }; } function randReview() {
1
1
0
165 166 167 168 169 170 171 172 173 174
})); }, function (cb) { async.forEach(_.range(1, userCount + 1), function (nr, cb) { models.User.create({ "firstName": chance.first(), "lastName": chance.last(), "email": "user" + nr + "@domain.com", "email_lowered": "user" + nr + "@domain.com", "passwordHash": defaultPasswordHash,
0
1
0
+ 3 other calls in file
GitHub: eduardo3g/pethost
5 6 7 8 9 10 11 12 13 14 15 16
const a_random_user = async role => { const cognito = new AWS.CognitoIdentityServiceProvider(); const clientId = process.env.WEB_COGNITO_USER_POOL_CLIENT_ID; const firstName = chance.first({ nationality: 'en' }); const lastName = chance.first({ nationality: 'en' }); const suffix = chance.string({ length: 4, pool: 'abcdefghijklmnopqrstuvwxyz',
0
1
0
15 16 17 18 19 20 21 22 23 24
const gender = chance.gender().toLowerCase(); const person = { type: spec.label, prefix: chance.prefix({gender: gender }), first: chance.first({gender: gender}), last: chance.last(), age: chance.age(), birthday: chance.birthday({string: true, american: true}), gender: gender,
0
1
0
10 11 12 13 14 15 16 17 18 19 20
const anAuthenticatedUser = async () => { const client = new CognitoIdentityProviderClient({region: 'us-east-1'}); const userpoolId = process.env.cognito_user_pool_id; const clientId = process.env.cognito_server_client_id; const firstName = chance.first({nationality: 'en'}); const lastName = chance.last({nationality: 'en'}); const suffix = chance.string({length: 4, pool: 'abcdefghijklmnopqrstuvwxyz'}); const username = `test-${firstName}-${lastName}-${suffix}`; const password = randomPassword();
0
0
0
7 8 9 10 11 12 13 14 15 16
const cognito = new AWS.CognitoIdentityServiceProvider() const userpoolId = process.env.cognito_user_pool_id const clientId = process.env.cognito_server_client_id const firstName = chance.first({ nationality: "en" }) const lastName = chance.last({ nationality: "en" }) const suffix = chance.string({length: 8, pool: "abcdefghijklmnopqrstuvwxyz"}) const username = `test-${firstName}-${lastName}-${suffix}` const password = random_password()
0
0
0
23 24 25 26 27 28 29 30 31 32 33 34
return chance.email(options) } // first export function first (options) { return chance.first(options) } // floating export function floating (options) {
0
0
0
15 16 17 18 19 20 21 22 23 24 25
const workerPort = 3000; // create a JSON info object with some application information const info = { launchDate: new Date().toLocaleString("en-US", { timeZone: "America/Chicago" }), serverName: chance.first() + " the " + chance.animal(), appName: package.name, serverVersion: package.version };
0
0
0
GitHub: gtdoubledouble/NodeChat
77 78 79 80 81 82 83 84 85 86
// validate data if(request.body.gender && request.body.country && request.body.regid) { // store data in mongoDB; assign a username var newID = uuid.v4() var newName = chance.first() + chance.integer({min:1,max:1000}); var newUser = new User({ user_id: newID, username: newName, regid: request.body.regid,
0
0
0
+ 2 other calls in file
29 30 31 32 33 34 35 36 37 38 39 40
} function playRoute(routeFile) { const route = fs.readFileSync(routeFile, 'utf8'); const coords = route.split(/\r?\n/); const orderId = chance.first(); let counter = 0; const timer = setInterval(() => { const line = coords[counter];
0
0
0
chance.word is the most popular function in chance (344 examples)