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

    Function findCountryByIso2

    • Looks up a country record by its two-letter ISO 3166-1 alpha-2 code. Wraps the untyped country-list-js findByIso2 in a type guard so callers get a typed result instead of any.

      Parameters

      • iso2: string

        Two-letter country code (e.g. "US", "GB")

      Returns undefined | CountryRecord

      The matching country record, or undefined if the code is unknown

      findCountryByIso2("US")?.name // "United States"
      findCountryByIso2("US")?.currency?.code // "USD"
      findCountryByIso2("ZZ") // undefined
      export function findCountryByIso2(iso2: string): CountryRecord | undefined {
      const result: unknown = findByIso2(iso2);
      return isCountryRecord(result) ? result : undefined;
      }