String
camelCase

Convert a string to Camel case (opens in a new tab).

Syntax

import { camelCase } from '@opentf/std';
 
camelCase(str: string): string;

Examples

camelCase() // It throws an error;
 
camelCase('a') // 'a'
 
camelCase('A') // 'a'
 
camelCase('aB') // 'aB'
 
camelCase('AB') // 'aB'
 
camelCase('abc') // 'abc'
 
camelCase('i phone') // 'iPhone'
 
camelCase('i-phone') // 'iPhone'
 
camelCase('i_phone') // 'iPhone'
 
camelCase('i.phone') // 'iPhone'
 
camelCase('The Quick Brown Fox') // 'theQuickBrownFox'
 
camelCase('TheQuickBrownFox') // 'theQuickBrownFox'
 
camelCase('The quick.brown_fox-jumps over the lazy-dog.') // 'theQuickBrownFoxJumpsOverTheLazyDog'
 
camelCase('--foo.bar') // 'fooBar'
 
camelCase('Foo Bar') // 'fooBar'
 
camelCase('__FOO_BAR__') // 'fooBar'
 
camelCase('foo,bar') // 'fooBar'
 
camelCase('1apple') // '1apple'
 
camelCase('1 apple') // '1Apple'

Try