forked from ElevenGiants/eleven-http-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
40 lines (34 loc) · 652 Bytes
/
utils.js
File metadata and controls
40 lines (34 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* utils.js contains functions from eleven-gsjs
* https://github.com/ElevenGiants/eleven-gsjs
*/
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
var romanMap = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
I: 1
};
exports.to_roman_numerals = function to_roman_numerals(num) {
var n = parseInt(num, 10);
var res = '';
for (var roman in romanMap) {
var number = romanMap[roman];
var matches = parseInt(n / number, 10);
for (var i = 0; i < matches; i++) {
res += roman;
}
n = n % number;
}
return res;
};
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers