@ultraviolet/plus
Version:
Ultraviolet Plus
17 lines (16 loc) • 513 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const constants = require("./constants.cjs");
const calculatePrice = ({
price,
amount,
amountFree = 0,
timeUnit,
timeAmount,
discount = 0
}) => {
const nonNanTimeAmount = Number.isNaN(timeAmount) ? 0 : timeAmount;
const value = (price - price * discount) * (nonNanTimeAmount * constants.multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0);
return value;
};
exports.calculatePrice = calculatePrice;