ChemPal Documentation - v1.7.0
    Preparing search index...

    Function getCurrencyCodeFromLocation

    • 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).

      Parameters

      • location: valueof

        The location to look up (e.g., 'US', 'GB')

      Returns valueof

      The corresponding currency code (e.g., 'USD', 'GBP')

      getCurrencyCodeFromLocation('US') // Returns 'USD'
      getCurrencyCodeFromLocation('GB') // Returns 'GBP'
      getCurrencyCodeFromLocation('OTHER') // Returns 'USD'
      export function getCurrencyCodeFromLocation(location: CountryCode): CurrencyCode {
      return findCountryByIso2(String(location))?.currency?.code ?? 'USD';
      }