Function strEnsureStartsWith

  • Ensures that a string starts with a specified substring. If the string already starts with the specified substring, it is returned as is. Otherwise, the substring is appended to the end of the string.

    Parameters

    • string: string

      The string to be processed.

    • startsWith: string

      The substring that the string should end with.

    Returns string

    Example

    strEnsureStartsWith('json', '.');
    //=> '.json'
    strEnsureStartsWith('.json', '.');
    //=> '.json'

Generated using TypeDoc