ac-countrylist

1.0.11 • Public • Published

AC CountryList

This is a little helper to retrieve a countrylist and query this countrylist.

The countrylist is forked from https://gist.github.com/stefanbauer/bf0720c6846a3cc9b59e

Usage

You can use the countrylist directly by importing countrylist.js. But it is recommended to use this little helper and require this module.

const acCountryList = require('ac-countrylist')

Fetch country list

Return a short list with iso2, country name and spoken languages.

const list = acCountryList.showList()
// -> [{ name: 'Afghanistan',
    iso2: 'af',
    alpha2Code: 'af',
    languages: [ 'ps', 'uz', 'tk' ] }, ...]

Query list

Query the country list (currently only iso2 and iso3 is supported)

const country = acCountryList.query({ iso2: 'de' })
// OR
const country = acCountryList.query({ iso3: 'deu' })

// -> { name: 'Germany',
  capital: 'Berlin',
  altSpellings:
   [ 'DE',
     'Federal Republic of Germany',
     'Bundesrepublik Deutschland' ],
  relevance: '3',
  region: 'Europe',
  subregion: 'Western Europe',
  translations:
   { de: 'Deutschland',
     es: 'Alemania',
     fr: 'Allemagne',
     ja: 'ドイツ',
     it: 'Germania' },
  population: 81083600,
  latlng: [ 51, 9 ],
  demonym: 'German',
  area: 357114,
  gini: 28.3,
  timezones: [ 'UTC+01:00' ],
  borders:
   [ 'AUT', 'BEL', 'CZE', 'DNK', 'FRA', 'LUX', 'NLD', 'POL', 'CHE' ],
  nativeName: 'Deutschland',
  callingCodes: [ '49' ],
  topLevelDomain: [ '.de' ],
  alpha2Code: 'DE',
  alpha3Code: 'DEU',
  currencies: [ 'EUR' ],
  languages: [ 'de' ] }

Fetch random country

Return a random country

const randomCountry = acCountryList.random()
//
{ name: 'Afghanistan',
  iso2: 'af',
  alpha2Code: 'af',
  languages: [ 'ps', 'uz', 'tk' ] 
}

Links

License

MIT License Copyright © 2009-present, AdmiralCloud, Mark Poepping

Readme

Keywords

none

Package Sidebar

Install

npm i ac-countrylist

Weekly Downloads

32

Version

1.0.11

License

MIT

Unpacked Size

223 kB

Total Files

10

Last publish

Collaborators

  • admiralcloud