11/**
2- * Convert group name, token name and possible prefix into camelCased string, joining everything together
3- */
4- Pulsar . registerFunction ( "readableVariableName" , function ( token , tokenGroup , prefix ) {
5-
2+ * Convert group name, token name and possible prefix into camelCased string, joining everything together
3+ */
4+ Pulsar . registerFunction (
5+ "readableVariableName" ,
6+ function ( token , tokenGroup , prefix ) {
67 // Create array with all path segments and token name at the end
7- let segments = [ ...tokenGroup . path , token . name ]
8+ let segments = [ ...tokenGroup . path , token . name ] ;
89 if ( prefix && prefix . length > 0 ) {
9- segments . unshift ( prefix )
10+ segments . unshift ( prefix ) ;
1011 }
1112
1213 // Create "sentence" separated by spaces so we can camelcase it all
13- let sentence = segments . join ( " " )
14+ let sentence = segments . join ( " " ) ;
1415
1516 // Return camelcased string from all segments
16- return sentence . toLowerCase ( ) . replace ( / [ ^ a - z A - Z 0 - 9 ] + ( .) / g, ( m , chr ) => chr . toUpperCase ( ) ) ;
17- } )
17+ sentence = sentence
18+ . toLowerCase ( )
19+ . replace ( / [ ^ a - z A - Z 0 - 9 ] + ( .) / g, ( m , chr ) => chr . toUpperCase ( ) ) ;
20+
21+ if ( / ^ \d / . test ( sentence ) ) {
22+ sentence = "_" + sentence ;
23+ }
24+ return sentence ;
25+ }
26+ ) ;
1827
1928/**
20- * Behavior configuration of the exporter
21- * Prefixes: Add prefix for each category of the tokens. For example, all colors can start with "color, if needed"
22- */
29+ * Behavior configuration of the exporter
30+ * Prefixes: Add prefix for each category of the tokens. For example, all colors can start with "color, if needed"
31+ */
2332Pulsar . registerPayload ( "behavior" , {
24- colorTokenPrefix : "color" ,
25- borderTokenPrefix : "border" ,
26- gradientTokenPrefix : "gradient" ,
27- measureTokenPrefix : "measure" ,
28- shadowTokenPrefix : "shadow" ,
29- typographyTokenPrefix : "typography"
30- } )
33+ colorTokenPrefix : "color" ,
34+ borderTokenPrefix : "border" ,
35+ gradientTokenPrefix : "gradient" ,
36+ measureTokenPrefix : "measure" ,
37+ shadowTokenPrefix : "shadow" ,
38+ typographyTokenPrefix : "typography" ,
39+ } ) ;
0 commit comments