MCPcopy Create free account
hub / github.com/Snapchat/Valdi / toPascalCase

Function toPascalCase

npm_modules/cli/src/utils/stringUtils.ts:91–98  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

89}
90
91export function toPascalCase(str: string): string {
92 const words = str.trim().toLowerCase().split(wordSplitRegex);
93 return words.reduce((acc, curr) => {
94 const [firstChar, ...rest] = curr;
95 const pascalCaseWord = firstChar?.toUpperCase()?.concat(rest.join('')) ?? '';
96 return acc + pascalCaseWord;
97 }, '');
98}
99
100export function toSnakeCase(str: string): string {
101 const words = str.trim().toLowerCase().split(wordSplitRegex);

Callers 3

valdiNewModuleFunction · 0.90
initializeConfigFilesFunction · 0.90

Calls 5

splitMethod · 0.80
trimMethod · 0.45
reduceMethod · 0.45
concatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected