current-currency
Version:
Making it easy to work with currencies and cryptos!
20 lines (19 loc) • 925 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addSymbol = void 0;
const currencies_1 = require("../utils/currencies");
const cryptocurrencies_1 = require("../utils/cryptocurrencies");
/**
* Adds the appropriate currency symbol
* @param currency The code of the currency e.g. USD
* @param amount The amount of money
* @param position Optional parameter to overwrite the position of the symbol
*/
function addSymbol(currency, amount, position) {
const currencyDetail = currencies_1.isCurrency(currency) ? currencies_1.Currencies[currency] : cryptocurrencies_1.Cryptocurrencies[currency];
if (position) {
return position === "pre" ? currencyDetail.symbol + amount : amount + currencyDetail.symbol;
}
return currencyDetail.position === "pre" ? currencyDetail.symbol + amount : amount + currencyDetail.symbol;
}
exports.addSymbol = addSymbol;