Skip to content

mock-end/random-char

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

random-char

Return a random character.

MIT License

build:? coverage:?

Install

$ npm install --save random-char 

Usage

For more use-cases see the tests

var randomChar = require('random-char');

// API
// - randomChar([poolName]);
// - randomChar([options]);

randomChar();
// => 'k'

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

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&()*_+-={}[]'

Optionally specify a pool:

randomChar('alpha'); // or
randomChar({alpha: true});
// => 'm'

randomChar('upper'); // or
randomChar({upper: true});
// => 'Z'

randomChar('lower'); // or
randomChar({lower: true});
// => 'j'

randomChar('number'); // or
randomChar({number: true});
// => '7'

randomChar('symbols'); // or
randomChar({symbols: true});
// => '%'

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

randomChar('abcde'); // or
randomChar({pool: 'abcde'});
// => 'c'

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

Releases

No releases published

Packages

No packages published