Options
All
  • Public
  • Public/Protected
  • All
Menu

Utility class containing a bunch of helper methods for commonly used string interactions and other methods as
shortcuts

Hierarchy

  • StringUtil

Index

Methods

Static capitalizeFirstLetter

  • capitalizeFirstLetter(str: string): string
  • Capitalizes the first letter of a string and leaves the rest as is.

    static

    Parameters

    • str: string

      The string to modify.

    Returns string

    The provided string with the first character capitalized.

Static capitalizeFirstLetterAndLowercaseTheRest

  • capitalizeFirstLetterAndLowercaseTheRest(str: string): string
  • Capitalizes the first letter of a string and changes the rest to lowercase.

    static

    Parameters

    • str: string

      The string to modify.

    Returns string

    The provided string with the first character capitalized and the rest in lowercase.

Static convertToBoolean

  • convertToBoolean(str?: string): boolean
  • Converts a supplied string to a boolean value.

    static

    Parameters

    • str: string = ""

      The string to convert.

    Returns boolean

    True if the string was a true value, otherwise false.

Static convertToCamelCase

  • convertToCamelCase(str: string): string
  • Converts a supplied string to a string using camel casing.

    static

    Parameters

    • str: string

      The string to convert.

    Returns string

    The provided string converted to camel casing.

Static convertToDate

  • convertToDate(str: string): Date
  • Converts a string to a Date.

    static

    Parameters

    • str: string

      The string to convert.

    Returns Date

    A Date value if the string is convertable, otherwise null.

Static convertToLowerCaseNoSpaces

  • convertToLowerCaseNoSpaces(str: string): string
  • Converts a supplied string to a string in all lowercase and with any whitespace removed. If a non-string
    value is provided, an empty string is returned.

    static

    Parameters

    • str: string

      The string to convert.

    Returns string

    The provided string converted to lowercase and with whitespaces completely removed.

Static convertToNumber

  • convertToNumber(str: string): number
  • Converts a string to a number value.

    static

    Parameters

    • str: string

      The string to convert.

    Returns number

    A number value if the string is convertable, otherwise null.

Static convertToSnakeCase

  • convertToSnakeCase(str: string): string
  • Converts a supplied string to a string using snake casing.

    static

    Parameters

    • str: string

      The string to convert.

    Returns string

    The provided string converted to snake casing.

Static doubleQuotes

  • doubleQuotes(str: string): string
  • Wraps a provided string in double quotes.

    static

    Parameters

    • str: string

      The string to wrap in double quotes.

    Returns string

    The provided string wrapped in double quotes.

Static isEmpty

  • isEmpty(str: string): boolean
  • Checks if a provided string is empty or not.

    static

    Parameters

    • str: string

      The string to check.

    Returns boolean

    True if the string is empty, otherwise returns true.

Static isEqual

  • isEqual(str1: string, str2: string): boolean
  • Checks if two provided strings are equal or not.

    static

    Parameters

    • str1: string

      The first string to check.

    • str2: string

      The second string to check.

    Returns boolean

    True if the strings are equal, otherwise returns false.

Static isEqualToAny

  • isEqualToAny(str: string, stringsToCheck: string[]): boolean
  • Checks if a string is contained inside an array of strings.

    static

    Parameters

    • str: string

      The string to check for.

    • stringsToCheck: string[]

      The array of strings to check.

    Returns boolean

    True if the string is in the array, otherwise returns false.

Static isNotEqual

  • isNotEqual(str1: string, str2: string): boolean
  • Checks if two provided strings are not equal.

    static

    Parameters

    • str1: string

      The first string to check.

    • str2: string

      The second string to check.

    Returns boolean

    True if the strings aren't equal, otherwise returns true.

Static isNotEqualToAny

  • isNotEqualToAny(str: string, stringsToCheck: string[]): boolean
  • Checks if a string is not contained inside an array of strings.

    static

    Parameters

    • str: string

      The string to check for.

    • stringsToCheck: string[]

      The array of strings to check.

    Returns boolean

    True if the string is not in the array, otherwise returns false.

Static isSet

  • isSet(str: string): boolean
  • Checks if a provided string is set or not.

    static
    static

    Parameters

    • str: string

      The string to check.

    Returns boolean

    True if the string is set, otherwise returns false.

Static singleQuotes

  • singleQuotes(str: string): string
  • Wraps a provided string in single quotes.

    static

    Parameters

    • str: string

      The string to wrap in double quotes.

    Returns string

    The provided string wrapped in single quotes.

Constructors

constructor

Generated using TypeDoc