revamp template

This commit is contained in:
fro1991
2025-02-01 16:44:51 +07:00
parent c432df568a
commit 276a289580
1212 changed files with 112762 additions and 0 deletions

22
src/utils/String.ts Normal file
View File

@ -0,0 +1,22 @@
export const camelToSnakeCase = (str: string) => {
return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
};
export const snakeToCamelCase = (str: string) => {
return str.replace(/(_\w)/g, (match) => match[1].toUpperCase());
};
export const toCamelCase = (str: string | undefined | null): string => {
if (!str) return '';
return str
.toLowerCase()
.replace(/(?:^|[^a-zA-Z0-9])([a-zA-Z0-9])/g, (match, group1) => group1.toUpperCase())
.replace(/[^a-zA-Z0-9]/g, '');
};
export const snakeToTitleCase = (str: string) => {
return String(str)
.split('_') // Split the string by underscores
.map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each word
.join(' '); // Join the words with spaces
};