mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 11:45:26 +03:00
944 B
944 B
startCase
Converts a string to start case.
Start case is a naming convention where the first letter of each word in an identifier is written in uppercase and the rest of the letters are in lowercase, with the words separated by spaces, such as Start Case
.
Signature
function startCase(str: string): string;
Parameters
str
(string
): The string to convert to start case.
Returns
(string
) The string converted to start case.
Examples
import { startCase } from 'es-toolkit/string';
startCase('--foo-bar--'); // returns 'Foo Bar'
startCase('fooBar'); // returns 'Foo Bar'
startCase('__FOO_BAR__'); // returns 'FOO BAR'
startCase('XMLHttpRequest'); // returns 'XML Http Request'
startCase('_abc_123_def'); // returns 'Abc 123 Def'
startCase('__abc__123__def__'); // returns 'Abc 123 Def'
startCase('_-_-_-_'); // returns ''
startCase('12abc 12ABC'); // returns '12 Abc 12 ABC'