new RandomBasic()
- Description:
Generate random numbers
- Source:
Methods
randomChar(charset) → {char}
- Description:
Generate a random character based on a given charset
- Source:
Parameters:
Name | Type | Description |
---|---|---|
charset |
string | charset to choose from |
Returns:
- random character
- Type
- char
randomDigits(num) → {string}
- Description:
Generate a number of random digits
- Source:
Parameters:
Name | Type | Description |
---|---|---|
num |
number | number of random digits to generate, defaults to empty string if not given |
Throws:
Exception when parameter is not a number
Returns:
- array of random digits
- Type
- string
randomInt(max) → {integer}
- Description:
Generate a random integer greater than 0 and less than a given maximum value.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
max |
integer | max value of the random number (positive integer) |
Throws:
Exception when the parameter is not an integer
Returns:
- the random number
- Type
- integer
randomNumbers(num) → {Array}
- Description:
Generate an array of numbers between 0 and 9 Array length = parameter
num
TODO in the Perl version this function was only used to fill a cache of random numbers ? so probably it's not needed anymore.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
num |
integer | number of random numbers to generate, defaults to 1 if not given |
Throws:
Exception when parameter is not a number
Returns:
- Type
- Array
toss() → {int}
- Description:
Toss: generate a random odd/even number
- Source:
Returns:
- a random value 0 or 1
- Type
- int