Two-letter country code (e.g. "US", "GB")
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;
}
Looks up a country record by its two-letter ISO 3166-1 alpha-2 code. Wraps the untyped
country-list-jsfindByIso2in a type guard so callers get a typed result instead ofany.