ChemPare Documentation - v0.0.0
    Preparing search index...

    Module helpers/currency

    Functions - Suppliers

    isParsedPrice

    Functions - Helpers

    getCurrencySymbol

    Extracts the currency symbol from a price string. Uses Unicode property escapes to match currency symbols. Supports a wide range of international currency symbols.

    parsePrice

    Parses a price string into a structured object containing currency information. Handles various price formats and number representations:

    • Different currency symbol positions (prefix/suffix)
    • International number formats (e.g., 1.234,56 or 1,234.56)
    • Various currency symbols (€, $, £, ¥, etc.)
    getCurrencyRate

    Fetches the current exchange rate between two currencies. Uses the Hexarate API to get real-time exchange rates. Implements caching using LRU cache to minimize API calls.

    getCurrencyCodeFromSymbol

    Maps a currency symbol to its corresponding ISO currency code. Uses a predefined mapping from the CURRENCY_CODE_MAP constant. Supports major international currency symbols.

    getCurrencyCodeFromLocation

    Maps a location to its corresponding currency code. Uses a predefined mapping from the CURRENCY_CODE_MAP_BY_LOCATION constant. Supports major international locations.

    toUSD

    Converts a given amount from any supported currency to USD. Uses real-time exchange rates from the Hexarate API. Results are rounded to 2 decimal places for standard currency format.

    USDto

    Converts a given amount from USD to any supported currency. Uses real-time exchange rates from the Hexarate API. Results are rounded to 2 decimal places for standard currency format.