Options
All
  • Public
  • Public/Protected
  • All
Menu

Export utils class.

export
class

Utils

Hierarchy

  • Utils

Index

Methods

convertToJSON

  • convertToJSON(object: Object): string
  • Convert js plain object into JSON string

    Parameters

    • object: Object

      object to be converted

    Returns string

    stringy version of js object

Private editDistance

  • editDistance(needle: string, haystack: string): number
  • Find the common edit distance between two strings.

    Parameters

    • needle: string

      string which will be matched

    • haystack: string

      string to be matched against

    Returns number

    common edit distance between strings

fillArray

  • fillArray(object: Object, length: number): Object[]
  • Returns an array of a certain length with same object

    Parameters

    • object: Object

      js plain object

    • length: number

      length of returned array

    Returns Object[]

    } filled array

formatLine

  • formatLine(initialIndentation: string, tabs: number, message: string): string
  • Formats the line for spec.

    Parameters

    • initialIndentation: string

      holds the initial indentation

    • tabs: number

      holds how many tabs should prepend to the line

    • message: string

      holds the actual content of the line

    Returns string

    • returns the formatted line

indexOfIgnoreCase

  • indexOfIgnoreCase(haystack: string[], needle: string): number
  • IndexOf implementation with ignore case

    Parameters

    • haystack: string[]

      array of strings

    • needle: string

      query string

    Returns number

    key of the query inside the array

pluraliseWordArray

  • pluraliseWordArray(word: string): string
  • Pluralise a word that contains [] at the end

    Parameters

    • word: string

      string object

    Returns string

    • Example: input: User[]; output: Users

pluralize

  • pluralize(word: string): string

similarity

  • similarity(needle: string, haystack: string): number
  • Finds the similarity between two strings

    Parameters

    • needle: string
    • haystack: string

    Returns number

    percentage of similarity as float

singular

  • singular(word: string): string
  • Convert plural word into singular

    Parameters

    • word: string

      word to be singularized

    Returns string

    • singularized word

toColumnName

  • toColumnName(word: string): string
  • Convert word to comply with the column name schema.

    Parameters

    • word: string

    Returns string

    eg: user_id

toTableName

  • toTableName(word: string): string
  • Convert word to it's table name

    Parameters

    • word: string

      = eg: User

    Returns string

    eg: users

toTitleCase

  • toTitleCase(word: string): string
  • Convert data type name to 'Object' naming

    Parameters

    • word: string

      eg: users

    Returns string

    eg: User

Generated using TypeDoc