• Converts a string to PascalCase.

    Remarks

    This function converts a string to PascalCase, which is a naming convention where the first letter of each word is capitalized and there are no spaces or other separators between the words.

    If the input is not a string, this function returns a Result object containing an error.

    Example

    Converting a string with spaces to PascalCase:

    toPascalCase('hello world')
    // => { ok: true, value: 'HelloWorld' }

    Example

    Converting a string with hyphens to PascalCase:

    toPascalCase('foo-bar-baz');
    // => { ok: true, value: 'FooBarBaz' }

    Example

    Handling non-string input:

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

    Parameters

    • str: string

      The string to convert.

    Returns Result<string, Error>

    A Result object containing either the converted string or an Error object if the provided input is not a string.

Generated using TypeDoc v0.24.7