source: node_modules/es-toolkit/dist/compat/string/startCase.mjs@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 640 bytes
Line 
1import { deburr } from './deburr.mjs';
2import { words } from '../../string/words.mjs';
3import { normalizeForCase } from '../_internal/normalizeForCase.mjs';
4
5function startCase(str) {
6 const words$1 = words(normalizeForCase(deburr(str)).trim());
7 let result = '';
8 for (let i = 0; i < words$1.length; i++) {
9 const word = words$1[i];
10 if (result) {
11 result += ' ';
12 }
13 if (word === word.toUpperCase()) {
14 result += word;
15 }
16 else {
17 result += word[0].toUpperCase() + word.slice(1).toLowerCase();
18 }
19 }
20 return result;
21}
22
23export { startCase };
Note: See TracBrowser for help on using the repository browser.