Package Exports
- globalprice
- globalprice/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (globalprice) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐ globalprice
Smart and dynamic pricing engine for global applications, supporting real-time currency conversion, quantity, discounts, tax calculations, and formatted output.
๐ Features
- ๐ Supports 160+ currencies
- ๐ Auto-fetches latest exchange rates
- ๐งพ VAT / GST / custom tax support
- ๐ธ Discount by percentage or fixed value
- ๐ฆ Quantity multiplier
- ๐ช Currency symbol & locale-aware formatting
- ๐ง Works offline using cached or fallback rates
- ๐
.envsupport for premium API keys
๐ฆ Installation
npm install globalpriceโจ Usage Example
const { calculatePrice, updateRates } = require("globalprice");
await updateRates(); // optional, updates latest rates
const result = await calculatePrice({
basePrice: 100,
quantity: 2,
currency: "LKR",
discount: { type: "percent", value: 10 },
tax: { type: "VAT", rate: 12 },
format: true
});
console.log(result.formatted); // 'Rs 7320.00'๐งช Test Locally
npm test๐ Environment Setup
Add .env for custom API keys:
EXCHANGE_API_KEY=your_api_key_here๐ Folder Structure
globalprice/
โโโ src/
โ โโโ index.js
โ โโโ rates.js
โ โโโ currencies.js
โโโ cache/
โ โโโ exchangeRates.json
โโโ test/
โ โโโ globalprice.test.js
โโโ .env
โโโ package.json
โโโ LICENSE
โโโ README.md๐ License
MIT ยฉ Menula De Silva