Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/utils / dist / formatPrice.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Format a price to standard fixed
const toFloat = (x) => parseFloat(x).toFixed(2);
/**
 * @todo currency from a config
 * @todo remove the try catches from here
 */
function formatPrice(price, currencycode = '$') {
    try {
        const asFloat = toFloat(price);
        // ...
        if (!asFloat) {
            return price;
        }
        const value = String(asFloat);
        if (value.includes(currencycode)) {
            return value;
        }
        else {
            return `${currencycode}${asFloat}`;
        }
    }
    catch (error) {
        return 'N/A';
    }
}
exports.formatPrice = formatPrice;
exports.default = formatPrice;
//# sourceMappingURL=formatPrice.js.map