JSPM

globalprice

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3
    • Score
      100M100P100Q14848F
    • License MIT

    Smart pricing engine with live exchange rates, discount, tax and quantity support.

    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
    • ๐Ÿ” .env support 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