@@ -24,9 +24,28 @@ export function capitalizeFirstForClassName(str: string) {
2424 return parts . join ( "" ) ;
2525}
2626
27+ function toSnakeCase ( key ) {
28+ return key . replace ( / ( [ A - Z ] ) / g, "_1ドル" ) . toLowerCase ( ) ;
29+ }
30+ 31+ export function convertCamelToSnakeCase ( obj ) {
32+ const newObj = { } ;
33+ Object . keys ( obj ) . forEach ( ( key ) => {
34+ const newKey = toSnakeCase ( key ) ;
35+ const value = obj [ key ] ;
36+ if ( value && typeof value === 'object' && ! Array . isArray ( value ) ) {
37+ newObj [ newKey ] = convertCamelToSnakeCase ( value ) ;
38+ } else {
39+ newObj [ newKey ] = value ;
40+ }
41+ } ) ;
42+ return newObj ;
43+ }
44+ 2745export function camelCaseToDashCase ( str : string ) {
2846 return str . replace ( / [ A - Z ] / g, m => "-" + m . toLowerCase ( ) ) ;
2947}
48+ 3049export function snakeCaseToCamelCase ( str : string ) {
3150 return str . toLowerCase ( ) . replace ( / ( [ _ ] [ a - z ] ) / g, group =>
3251 group
@@ -35,7 +54,6 @@ export function snakeCaseToCamelCase(str: string) {
3554 ) ;
3655}
3756
38- 3957export function convertVarToCamel ( obj : any ) {
4058 if ( isDict ( obj ) ) {
4159 const n = { } ;
@@ -54,7 +72,6 @@ export function convertVarToCamel(obj: any) {
5472 return obj ;
5573}
5674
57- 5875export enum caseType {
5976 LOWER ,
6077 UPPER ,
0 commit comments