UNPKG

@ultraviolet/plus

Version:
17 lines (16 loc) 403 B
import { multiplier } from "./constants.js"; const calculatePrice = ({ price, amount, amountFree = 0, timeUnit, timeAmount, discount = 0 }) => { const nonNanTimeAmount = Number.isNaN(timeAmount) ? 0 : timeAmount; const value = (price - price * discount) * (nonNanTimeAmount * multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0); return value; }; export { calculatePrice };