@@ -43,12 +43,11 @@ const deapostrophe = (s: string) => {
43
43
const up = String . prototype . toUpperCase ;
44
44
const low = String . prototype . toLowerCase ;
45
45
46
- const fill = ( s : string , fillWith ?: string , isDeapostrophe = false ) => {
47
- if ( fillWith != null ) {
48
- s = s . replace ( regexps . fill , function ( m , next ) {
49
- return next ? fillWith + next : '' ;
50
- } ) ;
51
- }
46
+ const fill = ( s : string , fillWith : string , isDeapostrophe = false ) => {
47
+ s = s . replace ( regexps . fill , function ( m , next ) {
48
+ return next ? fillWith + next : '' ;
49
+ } ) ;
50
+
52
51
if ( isDeapostrophe ) {
53
52
s = deapostrophe ( s ) ;
54
53
}
@@ -92,16 +91,13 @@ const lower = (s: string, fillWith: string, isDeapostrophe: boolean) => {
92
91
export const pascal = ( s : string ) => {
93
92
const isStartWithUnderscore = s ?. startsWith ( '_' ) ;
94
93
95
- const pascalString = fill (
96
- prep ( s , false , true ) . replace (
97
- regexps . pascal ,
98
- ( m : string , border : string , letter : string ) => {
99
- return up . call ( letter ) ;
100
- } ,
101
- ) ,
102
- '' ,
103
- true ,
104
- ) ;
94
+ if ( regexps . upper . test ( s ) ) {
95
+ s = low . call ( s ) ;
96
+ }
97
+
98
+ const pascalString = ( s . match ( / [ a - z A - Z 0 - 9 ] + / g) || [ ] )
99
+ . map ( ( w ) => w . charAt ( 0 ) . toUpperCase ( ) + w . slice ( 1 ) )
100
+ . join ( '' ) ;
105
101
106
102
return isStartWithUnderscore ? `_${ pascalString } ` : pascalString ;
107
103
} ;
@@ -122,7 +118,7 @@ export const kebab = (s: string) => {
122
118
123
119
export const upper = (
124
120
s : string ,
125
- fillWith ? : string ,
121
+ fillWith : string ,
126
122
isDeapostrophe ?: boolean ,
127
123
) => {
128
124
return fill (
1 commit comments
vercel[bot] commentedon Sep 28, 2023
Successfully deployed to the following URLs:
orval – ./
orval.vercel.app
www.orval.dev
orval-git-master-anymaniax.vercel.app
orval-anymaniax.vercel.app
orval.dev