randomatic NPM version

Generate randomized strings of a specified length, fast. Only the length is necessary, but you can optionally generate patterns using any combination of numeric, alpha-numeric, alphabetical, special or custom characters.

Install

Install with npm

$ npm i randomatic --save

Install with bower

$ bower install randomatic --save

Usage

var randomize = require('randomatic');

API

randomize(pattern, length, options);

pattern

The pattern to use for randomizing

Patterns can contain any combination of the below characters, specified in any order.

Example:

To generate a 10-character randomized string using all available characters:

randomize('*', 10);
//=>

randomize('Aa0!', 10);
//=>

length

the length of the string to generate

Examples:

If length is left undefined, the length of the pattern in the first parameter will be used. For example:

These are just examples, see the tests for more use cases and examples.

options

chars

Type: String

Default: undefined

Define a custom string to be randomized.

Example:

Usage Examples

The order in which the characters are defined is insignificant.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb on December 10, 2015.