X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=index.js;fp=index.js;h=cfdcd7d5b37ec1a0346ff87a52f4ff725ea71c59;hb=99be39d917216df6640b72671958a2d615f28fea;hp=daed9d7391aad73e9fc743a2d22a93cb3168305f;hpb=ecee0a82fcc130ff230c657e8ef4826784d496a4;p=squeep-roman diff --git a/index.js b/index.js index daed9d7..cfdcd7d 100644 --- a/index.js +++ b/index.js @@ -45,8 +45,8 @@ const mapping = { /** * Render all characters of #s as HTML-encoded entities. - * @param {String} s - * @returns {string} + * @param {string} s string to encode + * @returns {string} encoded string */ function htmlEncode(s) { return s @@ -68,9 +68,9 @@ const divisors = Object.keys(mapping) /** * Convert a number to its Roman representation, using Unicode characters * or HTML entities. - * @param {Number} num - * @param {Boolean} asEntities if true, return html instead of unicode - * @returns {String} + * @param {number} num number to convert + * @param {boolean} asEntities if true, return html instead of unicode + * @returns {string} roman numeric string * @throws {RangeError} */ function toRoman(num, asEntities = false) { @@ -82,11 +82,11 @@ function toRoman(num, asEntities = false) { } const romanDigits = []; if (num <= 12) { - romanDigits.push(singleMapping[num]); + romanDigits.push(singleMapping[num]); // eslint-disable-line security/detect-object-injection } else { divisors.forEach((d) => { const length = Math.floor(num / d); - romanDigits.push(mapping[d].repeat(length)); + romanDigits.push(mapping[d].repeat(length)); // eslint-disable-line security/detect-object-injection num %= d; }); } @@ -97,4 +97,4 @@ function toRoman(num, asEntities = false) { module.exports = { toRoman, -}; \ No newline at end of file +};