消除我特牛
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1.2 KiB

character

// 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.

chance.character();
=> 'v'

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

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

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

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

Optionally specify alpha for an alphabetic character.

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

Optionally specify numeric for a numeric character.

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

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

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

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