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
.excludeSpecial
<boolean> | <Boolean> Whether "special characters" should be excluded or not. Defaults tofalse
, if not provided ornull
.- Returns: <string> A random string.
- Throws: <TypeError> Argument
len
must be an integer. - Throws: <TypeError> Argument
excludeSpecial
must be a boolean. - 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 optionally some additional special characters (~!@#$%^&()_+-={}[];',.
).
Deprecated: Use randomString()
instead.
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
len
<number> | <Number> The number of emojis in the returned string or array. Defaults to1
, if not provided ornull
.useArray
<boolean> | <Boolean> Whether this function should return a string of concatenated emojis or an array of emojis. Defaults tofalse
, if not provided ornull
.- Returns: <string> One or more random emojis.
- Throws: <TypeError> Argument
len
must be an integer. - Throws: <TypeError> Argument
useArray
must be a boolean. - Throws: <RangeError> Argument
len
must not beNaN
. - Throws: <RangeError> Argument
len
must be finite. - Throws: <RangeError> Argument
len
must not be negative.
Get one or more random emojis. Some emojis might not display correctly on certain platforms, especially those that don't implement Emoji 12.0 standard.