How to use the character function from chance

Find comprehensive JavaScript chance.character code examples handpicked from public code repositorys.

53
54
55
56
57
58
59
60
61
62
/**
 * By default it will return a string with random character from the specified pool.
 * @param {string} pool
 */
char(pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_') {
  return chance.character({ pool });
},

/**
 * Return a random string. By default it will return a string with random length of 5-20 characters
fork icon5
star icon0
watch icon1

+ 3 other calls in file

98
99
100
101
102
103
104
105
106
107
async.series([
  function (cb) {
    test.app.post('/data/string_data')
      .set('Content-Type', 'application/json')
      .send(data = {
        'char_short': chance.character(),
        'char_long': chance.word({length: 5}),
        'string_short': chance.character(),
        'string_long': chance.word({length: 5}),
        'string': chance.paragraph({sentences: 5}),
fork icon2
star icon5
watch icon4

+ 3 other calls in file

74
75
76
77
78
79
80
81
82
    break;
case 'ccnumber':
    s += chance.cc().toCsv(CSV.delimiter);
    break;
case 'char': // one character
    s += chance.character();
    break;
case 'date':
    n = hdr[k].arg;
fork icon2
star icon8
watch icon0

+ 3 other calls in file