Package Exports
- randomatic
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (randomatic) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
randomatic 
Generate randomized strings of a specified length from patterns of numeric, alpha-numeric, alphabetical, special or custom characters.
Quickstart
npm
npm i randomatic --save
bower
bower install randomatic --save
Documentation
var randomatic = require('randomatic');
Params
The following parameters can be passed (randomize(Pattern, Length, Options)
)
pattern
Type: String
(required)
Default: undefined
a
: Lowercase alpha characters (abcdefghijklmnopqrstuvwxyz'
)A
: Uppercase alpha characters (ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)0
: Numeric characters (0123456789'
)!
: Special characters (~!@#$%^&()_+-={}[];\',.
)*
: All characters (all of the above combined)?
: Custom characters (pass a string of custom characters to the options)
Patterns can contain any combination of the above characters, in any order. For example, randomize('Aa0!', 10)
will generate a 10-character randomized string with all of the specified patterns.
length
Type: Number
(optional)
Default: undefined
Specify the number of characters/digits to generate in the output.
Examples:
randomize('A', 5)
will generate a 5-character, uppercase, alphabetical, randomized string, e.g.KDJWJ
.randomize('0', 2)
will generate a 2-digit random numberrandomize('0', 3)
will generate a 3-digit random numberrandomize('0', 12)
will generate a 12-digit random numberrandomize('A0', 16)
will generate a 16-character, alpha-numeric randomized string
If length
is left undefined, the length of the pattern in the first parameter will be used. For example:
randomize('00')
will generate a 2-digit random numberrandomize('000')
will generate a 3-digit random numberrandomize('0000')
will generate a 4-digit random number...randomize('AAAAA')
will generate a 5-character, uppercase alphabetical random string...
...and so on.
options
Type: Object
(optional)
Default: undefined
Currently the only option is chars
, which allows you to define a custom string to be randomized. For example:
randomize('?', 20, {chars: 'jonschlinkert'})
will generate a 20-character randomized string from the letters contained injonschlinkert
.randomize('?', {chars: 'jonschlinkert'})
will generate a 13-character randomized string from the letters contained injonschlinkert
.
Usage Examples
randomize('A', 4)
(whitespace insenstive) would result in randomized 4-digit uppercase letters, like,ZAKH
,UJSL
... and so on.randomize('AAAA')
is equivelant torandomize('A', 4)
randomize('AAA0')
andrandomize('AA00')
andrandomize('A0A0')
are equivelant torandomize('A0', 4)
randomize('aa')
: results in double-digit, randomized, lower-case letters (abcdefghijklmnopqrstuvwxyz
)randomize('AAA')
: results in triple-digit, randomized, upper-case letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ
)randomize('0', 6)
: results in six-digit, randomized nubmers (0123456789
)randomize('!', 5)
: results in single-digit randomized, valid non-letter characters (~!@#$%^&()_+-={}[];\',.
)randomize('A!a0', 9)
: results in nine-digit, randomized characters (any of the above)
The order in which the characters are provided has no impact on the outcome.
Contributing
Find a bug? Have a feature request? Please create an Issue.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality,
and run docs
in the command line to build the docs with Verb.
Pull requests are also encouraged, and if you find this project useful please consider "starring" it to show your support! Thanks!
Authors
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on May 01, 2014.