toPascalCase

Converts the str to PascalCase, where the first letter of each word is capitalized.

Usage Scenarios

  • Class Naming: In programming, convert strings to PascalCase for class names.
  • Data Standardization: Standardize string formats in data processing.

Example

import { toPascalCase } from 'funtool/string'

toPascalCase('hello_world'); // ✅ 'HelloWorld'
toPascalCase('api_version'); // ✅ 'ApiVersion'
toPascalCase('API_version'); // ✅ 'APIVersion'

Signature

function toPascalCase(str: string): string

Parameters

  • str ( string ): The input string.

Returns

  • ( string ): A new string in PascalCase format.