random-strr

1.0.0 • Public • Published

random-strr

Return a random string.

MIT License

build:? coverage:?

Install

$ npm install --save random-strr 

Usage

var randomString = require('random-strr');
  
// API
// - randomString([options]);
  
// options
// - pool
// - length
// - min
// - max

By default it will return a string with random length of 5-20 characters and will contain any of the following characters.

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

Can optionally specify a length and the string will be exactly that length:

randomString({ length: 5 });
// => 'YN%fG'

Can optionally specify min, max, or both to limit the range.

randomString({ min: 8 });
// => huepevesik
 
randomString({ max: 10 });
// => biwuwkef
 
randomString({ min: 10, max: 40 });
// => omoemowawahteze

Can optionally specify a pool and the string will be generated with characters only from that pool.

randomString({ pool: 'abcde' });
// => 'cccdeeabedebb'

Of course these options can be combined.

randomString({ length: 5, pool: 'abcde' });
=> 'cbbdc'

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

Package Sidebar

Install

npm i random-strr

Weekly Downloads

26

Version

1.0.0

License

MIT

Last publish

Collaborators

  • bubkoo