Skip to content

Latest commit

 

History

History
71 lines (49 loc) · 3.59 KB

API_DOCS.md

File metadata and controls

71 lines (49 loc) · 3.59 KB

API Documentations

randomNumber([max])

Get a random number, where:

  • 0 <= number < max, if max is positive
  • 0, if max is 0
  • max < number <= 0, if max is negative

randomInteger([max])

  • max <number> | <Number> The maximum value of the returned integer. Defaults to 2 if not provided or null.
  • Returns: <number> A random integer.
  • Throws: <TypeError> Argument max must be a number.
  • Throws: <RangeError> Argument max must not be NaN.
  • Throws: <RangeError> Argument max must be finite.

Get a random integer, where:

  • 0 <= number < max, if max is positive
  • 0, if max is 0
  • max < number <= 0, if max is negative

randomBoolean()

  • Returns: <boolean> Either true or false, each with about 50% chance.

Get a random boolean.

randomString([len])

Get a random string consisting alphanumeric characters, and some additional special characters (~!@#$%^&()_+-={}[];',.).

randomHash([len])

  • len <number> | <Number> The length of the returned string. Defaults to 1 if not provided or null.
  • Returns: <string> A random string consisting alphanumeric characters.
  • Throws: <TypeError> Argument len must be an integer.
  • Throws: <RangeError> Argument len must not be NaN.
  • 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".

randomEmoji()

Added in: v0.1.3

Get a random emoji. Some emojis might not display correctly on certain platforms, especially those that don't implement Emoji 12.0 standard.