toCamelCase

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

Usage Scenarios

  • Variable Naming: In programming, convert strings to camelCase for variable names.
  • Data Standardization: Standardize string formats in data processing.

Example

import { toCamelCase } from 'funtool/string'

toCamelCase('hello_world'); // ✅ 'helloWorld'
toCamelCase('hello-world'); // ✅ 'helloWorld'
toCamelCase('api_version'); // ✅ 'apiVersion'
toCamelCase('API_version'); // ✅ 'apiVersion'
toCamelCase('my-xml-parser'); // ✅ 'myXmlParser'

Signature

function toCamelCase(str: string): string

Parameters

  • str ( string ): The input string.

Returns

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