Last active
December 7, 2023 02:38
-
-
Save boboidream/329c2fa394f1b5e91b1345588288f045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function camelize(str) { | |
return (str + "").replace(/-\D/g, | |
function(match) { | |
return match.charAt(1).toUpperCase(); | |
}); | |
} | |
camelize("border-bottom-color"); // "borderBottomColor" | |
function hyphenate(str) { | |
return (str + "").replace(/[A-Z]/g, | |
function(match) { | |
return "-" + match.toLowerCase(); | |
}); | |
} | |
hyphenate("borderBottomColor"); // "border-bottom-color" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 格式化 size | |
_formatSize(size) { | |
let unitK = Math.round(size / 1024), | |
unitM = (size / 1048576).toFixed(1) | |
return unitM > 0.9 ? unitM + 'M' : unitK + 'K' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment