Skip to content

Commit

Permalink
chore: 优化style2Upper
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry008008 committed Oct 27, 2021
1 parent 2d6ac13 commit 8d48d33
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 8d48d33

Please sign in to comment.