Class: Util

Util

Contains static methods to be used throughout klasa

new Util()

This class may not be initiated with new
Since:
  • 0.0.1
Source:
lib/util/util.js#L15

Methods


<static> applyToClass(base, structure [, skips])

Applies an interface to a class|
Parameters:
Name Type Argument Default Description
base Object The interface to apply to a structure
structure Object The structure to apply the interface to
skips Array.<string> <optional>
[] The methods to skip when applying this interface
Since:
  • 0.1.1
Source:
lib/util/util.js#L103

<static> clean(text)

Cleans sensitive info from strings
Parameters:
Name Type Description
text string The text to clean
Since:
  • 0.0.1
Source:
lib/util/util.js#L36
Returns:
Type
string

<static> codeBlock(lang, expression)

Makes a codeblock markup string
Parameters:
Name Type Description
lang string The codeblock language
expression string The expression to be wrapped in the codeblock
Since:
  • 0.0.1
Source:
lib/util/util.js#L26
Returns:
Type
string

<static> exec(command, options)

Promisified version of child_process.exec for use with await
Parameters:
Name Type Description
command string The command to run
options execOptions The options to pass to exec
Since:
  • 0.3.0
Source:
lib/util/util.js#L133
Returns:
Type
string

<static> newError(error, code)

Generates an error object used for argument reprompting
Parameters:
Name Type Description
error Error An error object
code number The status code to assign to the error
Since:
  • 0.0.1
Source:
lib/util/util.js#L72
Returns:
Type
Error

<static> regExpEsc(str)

Cleans a string from regex injection
Parameters:
Name Type Description
str string The string to clean
Since:
  • 0.0.1
Source:
lib/util/util.js#L92
Returns:
Type
string

<static> sleep(delay, args)

Promisified version of setTimeout for use with await
Parameters:
Name Type Description
delay number The amount of time in ms to delay
args any Any args to pass to the .then (mostly pointless in this form)
Since:
  • 0.3.0
Source:
lib/util/util.js#L143
Returns:
The args value passed in
Type
Promise.<any>

<static> toTitleCase(str)

Converts a string to Title Case
Parameters:
Name Type Description
str string The string to titlecaseify
Since:
  • 0.0.1
Source:
lib/util/util.js#L61
Returns:
Type
string