max
<number> | <Number> The maximum value of the returned number. Defaults to1
if not provided ornull
.- Returns: <number> A random number.
- Throws: <TypeError> Argument
max
must be a number. - Throws: <RangeError> Argument
max
must not beNaN
. - Throws: <RangeError> Argument
max
must be finite.
Get a random number, where:
0 <= number < max
, ifmax
is positive0
, if max is0
max < number <= 0
, ifmax
is negative
max
<number> | <Number> The maximum value of the returned integer. Defaults to2
if not provided ornull
.- Returns: <number> A random integer.
- Throws: <TypeError> Argument
max
must be a number. - Throws: <RangeError> Argument
max
must not beNaN
. - Throws: <RangeError> Argument
max
must be finite.
Get a random integer, where:
0 <= number < max
, ifmax
is positive0
, if max is0
max < number <= 0
, ifmax
is negative
- Returns: <boolean> Either
true
orfalse
, each with about 50% chance.
Get a random boolean.
len
<number> | <Number> The length of the returned string. Defaults to1
if not provided ornull
.- Returns: <string> A random string.
- Throws: <TypeError> Argument
len
must be an integer. - Throws: <RangeError> Argument
len
must not beNaN
. - Throws: <RangeError> Argument
len
must be finite. - Throws: <RangeError> Argument
len
must not be negative.
Get a random string consisting alphanumeric characters, and some additional special characters (~!@#$%^&()_+-={}[];',.
).
len
<number> | <Number> The length of the returned string. Defaults to1
if not provided ornull
.- Returns: <string> A random string consisting alphanumeric characters.
- Throws: <TypeError> Argument
len
must be an integer. - Throws: <RangeError> Argument
len
must not beNaN
. - Throws: <RangeError> Argument
len
must be finite. - Throws: <RangeError> Argument
len
must not be negative.
Get a random string consisting alphanumeric characters.
Note: this is not a hashing function despite its name containing the word "hash".
Added in: v0.1.3
- Returns: <string> A random emoji.
Get a random emoji. Some emojis might not display correctly on certain platforms, especially those that don't implement Emoji 12.0 standard.