Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

coodes-country-codes

Daniciany471ISC1.2.5

get Country from alpha2, alpha3 or UN (numeric) codes

country-code, country-codes, countries, countries-code, countries-codes, coodes, codes-of-country, codes-of-countries, codes, code, country-data, countries-data

readme

coodes - country-codes

new Update -> performance is now blazingly fast...

brand new version 1.2.6 upcoming...

shout out to He1senberg31415!

functions:

coodes provides 6 functions

1.: findCountryFromAlpha2(code)

accepts alpha2-code (2 letters) as a string - Capitalization does not matter

2.: findCountryFromAlpha3(code)

accepts alpha3-code (3 letters) as a string - Capitalization does not matter as well

3.: findCountryFromUN(code)

accepts UN-code (3 numbers) as a string or as an integer

For the following functions:

functions accepts strings of any form, don't worry about capitalization like "United States" or "united states", "United states", "united States", ...

4.: findAlpha2FromCountry(country)
5.: findAlpha3FromCountry(country)
6.: findUNFromCountry(country)

example:

import { findCountryFromAlpha2 } from 'coodes-country-codes'

const country = findCountryFromAlpha2("US") // country = "United States of America"

Note:

  • every function returns a country by its english name if it exists in the international country codes
  • if a country is not included in the international country codes, then every function returns undefined