Parses a price string into a structured object containing currency information. Handles various price formats and number representations:
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.
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.
Maps a location to its corresponding currency code.
Looks the country up in country-list-js by its two-letter code and reads
the associated currency. Falls back to 'USD' for unknown locations (e.g. the
synthetic 'OTHER' option).
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.
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.
Extracts the currency symbol from a price string. Uses Unicode property escapes to match currency symbols. Supports a wide range of international currency symbols.