libflitter/utility/Helpers

Some misc helpers to fetch env variables, infer string types, check json, etc.

Methods

(static) env(name, default_value) → {string|null|boolean|number}

Grabs an environment variable by name and tries to infer its type.

Parameters:
Name Type Description
name string
default_value
Returns:
Type
string | null | boolean | number

(static) infer(val) → {boolean|null|*|number|undefined}

Attempt to infer the variable type of a string's data.

Parameters:
Name Type Description
val string
Returns:
Type
boolean | null | * | number | undefined

(static) is_json(string) → {boolean}

Checks if a string is valid JSON.

Parameters:
Name Type Description
string
Returns:
  • true if the string is valid JSON
Type
boolean