node-rander
- a module to generate random string.
- support custom dictionary.
install
npm install rander
Usage
var rander = ;
dice(max)
throw a dice and return a number not beyond the max argument.
rander; // will return a number in 0 ~ 9
between(min, max)
randomly return a number in the given range.
rander; // will return a number in 1~10
pickup(len, dictionary)
randomly make a fixed length string using the given dictionary.
rander; // or rander; // the default length is 1;
string(len)
- using pickup to return an alphanumber string in the fixed length.
- the dictionary: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz
rander;
number(len)
- using pickup to return an number string in the fixed length.
- the dictionary: 0123456789
rander; // default length is 8
element(array)
randomly return an element in array.
var arr = 'a' 'b' 'c'; rander; // will return a string 'a', 'b', or 'c' // or rander;
key(object)
randomly return a key in the object
var obj = a: 'v1' b: 'v2' c: 'v3'; rander; // will return a string 'a', 'b', or 'c'
value(object)
randomly return a value int the object
var obj = a: 'v1' b: 'v2' c: 'v3'; randervalueobj; // will return a string 'v1', 'v2', or 'v3' // or rander;