Moolah
Moolah is a super simple math library specifically created for handling basic currency calculations for things like ecommerce. It offers:
- Handles/ouputs everything as floats with optional string output to 2 decimal places
- Provides simple routines for basic calculations, discounts, repeatable totalling etc
- 0.1 + 0.2 = 0.3
API
const moolah = // Initialize and just output as 2 dec rounded float // 0.33 // Initialize and just output as 2 dec string // '0.33' // Add // 0.3 // Subtract // 0.2 // Multiply // 100 // Divide // 50 // Return percentage left over // 40 // Return percentage left over using decimal // 40 // Return percentage discount // 10 // Return percentage discount using decimal // 10 // Add, subtract, multiply or divide using instances // 20 // Process array of items and return total (initialized with 10)const items = cost: 45 qty: 3 cost: 100 qty: 2 const total = // 345