• Converts a string to title case by capitalizing the first letter of each word. Optionally, all first letters of each word can be capitalized. It wraps capitalize and capitalizeAll.

    See

    Default Value

    capitalizeAllFirstLetters = true

    Example

    toTitle("bread and butter")
    // => { ok: true, value: 'Bread And Butter' }

    toTitle("bread and butter", false)
    // => { ok: true, value: 'Bread and butter' }

    Example

    Handling non-string input:

    toTitle(42)
    // => { ok: false, error: Error('[strings.toTitle] Expected string value as input') }

    Parameters

    • str: string

      The string to convert to title case.

    • capitalizeAllFirstLetters: boolean = true

      Whether to capitalize all first letters of each word. Default is true.

    Returns Result<string, Error>

    A Result object with either the title cased string on success, or an Error object if the provided input is not a string.

Generated using TypeDoc v0.24.7