projects
/
squeep-roman
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update devDependencies, fix lint issues
[squeep-roman]
/
index.js
diff --git
a/index.js
b/index.js
index daed9d7391aad73e9fc743a2d22a93cb3168305f..cfdcd7d5b37ec1a0346ff87a52f4ff725ea71c59 100644
(file)
--- a/
index.js
+++ b/
index.js
@@
-45,8
+45,8
@@
const mapping = {
/**
* Render all characters of #s as HTML-encoded entities.
/**
* 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
*/
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.
/**
* Convert a number to its Roman representation, using Unicode characters
* or HTML entities.
- * @param {
Number} num
- * @param {
B
oolean} asEntities if true, return html instead of unicode
- * @returns {
String}
+ * @param {
number} num number to convert
+ * @param {
b
oolean} asEntities if true, return html instead of unicode
+ * @returns {
string} roman numeric string
* @throws {RangeError}
*/
function toRoman(num, asEntities = false) {
* @throws {RangeError}
*/
function toRoman(num, asEntities = false) {
@@
-82,11
+82,11
@@
function toRoman(num, asEntities = false) {
}
const romanDigits = [];
if (num <= 12) {
}
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);
} 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;
});
}
num %= d;
});
}
@@
-97,4
+97,4
@@
function toRoman(num, asEntities = false) {
module.exports = {
toRoman,
module.exports = {
toRoman,
-};
\ No newline at end of file
+};