summaryrefslogtreecommitdiff
path: root/src/node_modules/chance/docs/basics/character.md
blob: 6c90ed6cd7e7c971d5a5c39dbfd48956d85d61fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# character

```js
// usages
chance.character()
chance.character({ pool: 'abcde' })
chance.character({ alpha: true })
chance.character({ numeric: true })
chance.character({ casing: 'lower' })
chance.character({ symbols: true })
```

Return a random character.

```js
chance.character();
=> 'v'
```

By default it will return a string with random character from the following
pool.

```js
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()'
```

Optionally specify a pool and the character will be generated with characters
only from that pool.

```js
chance.character({ pool: 'abcde' });
=> 'c'
```

Optionally specify alpha for an alphabetic character.

```js
chance.character({ alpha: true });
=> 'N'
```

Optionally specify numeric for a numeric character.

```js
chance.character({ numeric: true });
=> '8'
```

Default includes both upper and lower case. It's possible to specify one or the
other.

```js
chance.character({ casing: 'lower' });
=> 'j'
```

*Note, wanted to call this key just ```case``` but unfortunately that's a
reserved word in JavaScript for use in a switch statement*

Optionally return only symbols

```js
chance.character({ symbols: true });
=> '%'
```