es-toolkit 1.10.1-dev.242 → 1.10.1-dev.243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-MJA7DAOJ.mjs → chunk-QXTNZR7B.mjs} +1 -1
- package/dist/chunk-QXTNZR7B.mjs.map +1 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/index.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/string/startCase.js.map +1 -1
- package/dist/string/startCase.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-MJA7DAOJ.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/startCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n"],"mappings":";;;;;AAeO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|