@toolsnap/discount-calculator
v1.0.0
Published
Lightweight discount and sale price calculation utility functions
Maintainers
Readme
@toolsnap/discount-calculator
Lightweight discount and sale price calculation utility functions.
Installation
npm install @toolsnap/discount-calculatorUsage
const { calculateDiscount, applyCoupon, stackDiscounts, effectiveDiscount } = require('@toolsnap/discount-calculator');
// Percentage discount
calculateDiscount(99.99, 25);
// { original: 99.99, discounted: 74.99, saved: 25.0 }
// Fixed coupon
applyCoupon(49.99, 10);
// { original: 49.99, discounted: 39.99, saved: 10.0 }
// Stack multiple discounts
stackDiscounts(200, [20, 10]);
// { original: 200, final: 144, totalSaved: 56, steps: [...] }
// Find effective discount rate
effectiveDiscount(79.99, 59.99);
// 25.0API
calculateDiscount(originalPrice, discountPercent)— Calculate discounted price and savingsapplyCoupon(price, couponAmount)— Apply a fixed-amount couponstackDiscounts(price, discountPercents[])— Apply multiple discounts sequentiallyeffectiveDiscount(originalPrice, salePrice)— Reverse-calculate the discount percentage
Links
- 🏠 ToolSnap - Free Online Discount Calculator
- 📦 More tools at risetop.top
License
MIT
