-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (18 loc) · 939 Bytes
/
index.js
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
const currData = require('./currencyData.js');
const getData = (code, field) => {
code = code !== undefined && code !== '' ? code.toUpperCase() : code;
if (currData[code] !== undefined) {
if (field === 'all') return currData[code];
else return currData[code][field];
} else return undefined;
};
exports.getISOCode = (code) => getData(code, 'isoCode');
exports.getFractionDigit = (code) => getData(code, 'fractionDigit');
exports.getSymbol = (code) => getData(code, 'symbol');
exports.getUnicode = (code) => getData(code, 'unicode');
exports.getHtmlCode = (code) => getData(code, 'htmlCode');
exports.getHexCode = (code) => getData(code, 'hexCode');
exports.getCurrencyName = (code) => getData(code, 'currencyName');
exports.getCountriesUsingTheCurrency = (code) => getData(code, 'countries');
exports.getFullInformation = (code) => getData(code, 'all');
exports.getAllCurrencies = (code) => Object.keys(currData);