|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
768 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const deburr = require('./deburr.js');
|
|---|
| 6 | const words = require('../../string/words.js');
|
|---|
| 7 | const normalizeForCase = require('../_internal/normalizeForCase.js');
|
|---|
| 8 |
|
|---|
| 9 | function startCase(str) {
|
|---|
| 10 | const words$1 = words.words(normalizeForCase.normalizeForCase(deburr.deburr(str)).trim());
|
|---|
| 11 | let result = '';
|
|---|
| 12 | for (let i = 0; i < words$1.length; i++) {
|
|---|
| 13 | const word = words$1[i];
|
|---|
| 14 | if (result) {
|
|---|
| 15 | result += ' ';
|
|---|
| 16 | }
|
|---|
| 17 | if (word === word.toUpperCase()) {
|
|---|
| 18 | result += word;
|
|---|
| 19 | }
|
|---|
| 20 | else {
|
|---|
| 21 | result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 | return result;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | exports.startCase = startCase;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.