Skip to content

Commit

Permalink
Merge pull request #190 from jerry008008/master
Browse files Browse the repository at this point in the history
chore: 优化style2Upper
  • Loading branch information
army8735 authored Oct 27, 2021
2 parents 2d6ac13 + 8d48d33 commit 07cba9c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/util/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,22 @@ const STYLE_KEY = {
TRANSLATE_PATH: 101,
};

const STYLE2LOWER_MAP = {};
function style2Lower(s) {
return s.toLowerCase().replace(/_([a-z])/g, function($0, $1) {
STYLE2LOWER_MAP[s] = STYLE2LOWER_MAP[s] || s.toLowerCase().replace(/_([a-z])/g, function($0, $1) {
return $1.toUpperCase();
});

return STYLE2LOWER_MAP[s];
}

const STYLE2UPPER_MAP = {};
function style2Upper(s) {
return s.replace(/([a-z\d_])([A-Z])/g, function($0, $1, $2) {
STYLE2UPPER_MAP[s] = STYLE2UPPER_MAP[s] || s.replace(/([a-z\d_])([A-Z])/g, function($0, $1, $2) {
return $1 + '_' + $2;
}).toUpperCase();

return STYLE2UPPER_MAP[s];
}

const STYLE_R_KEY = {};
Expand Down

0 comments on commit 07cba9c

Please sign in to comment.