Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 4.88 KB

API_DOCS.md

File metadata and controls

83 lines (60 loc) · 4.88 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][, excludeSpecial])

  • len <number> | <Number> The length of the returned string. Defaults to 1 if not provided or null.
  • excludeSpecial <boolean> | <Boolean> Whether "special characters" should be excluded or not. Defaults to false, if not provided or null.
  • 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 be NaN.
  • 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 (~!@#$%^&()_+-={}[];',.).

randomHash([len])

Deprecated: Use randomString() instead.

  • 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([len][, useArray])

Added in: v0.1.3

  • len <number> | <Number> The number of emojis in the returned string or array. Defaults to 1, if not provided or null.
  • useArray <boolean> | <Boolean> Whether this function should return a string of concatenated emojis or an array of emojis. Defaults to false, if not provided or null.
  • 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 be NaN.
  • 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.