UNPKG

@ultraviolet/plus

Version:
17 lines (16 loc) 513 B
"use strict"; 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;