diff options
author | uncenter <47499684+uncenter@users.noreply.github.com> | 2024-09-30 16:40:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 22:40:54 +0200 |
commit | 14ccea31a8a2d3c3937277a38d577b6ecfa00332 (patch) | |
tree | b3090935b882e65c775598ffbdfadc6f91ce2213 | |
parent | 15a821e895fe65b36432f8d36be319b8c2a0be9f (diff) |
Use `Number.parseInt()` for hexadecimal/decimal conversions (#11902)
-rw-r--r-- | svglint.config.mjs | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/svglint.config.mjs b/svglint.config.mjs index b62a7b4b..b657cc58 100644 --- a/svglint.config.mjs +++ b/svglint.config.mjs @@ -141,22 +141,6 @@ const getTitleTextIndex = (svgFileContent) => { }; /** - * Convert a hexadecimal number passed as string to decimal number as integer. - * @param {string} hex The hexadecimal number representation to convert. - * @returns {number} The decimal number representation. - */ -const hexadecimalToDecimal = (hex) => { - let result = 0; - let digitValue; - for (const digit of hex.toLowerCase()) { - digitValue = '0123456789abcdefgh'.indexOf(digit); - result = result * 16 + digitValue; - } - - return result; -}; - -/** * Shorten a string with ellipsis if it exceeds 20 characters. * @param {string} string_ The string to shorten. * @returns {string} The shortened string. @@ -300,7 +284,7 @@ const config = { for (const match of hexadecimalCodepoints) { const charHexReprIndex = getTitleTextIndex(ast.source) + match.index + 1; - const charDec = hexadecimalToDecimal(match[1]); + const charDec = Number.parseInt(match[1], 16); let charRepr; if (xmlNamedEntitiesCodepoints.includes(charDec)) { |