A library for getting data about countries.
  • JavaScript 100%
Find a file
2020-12-03 17:09:21 -08:00
.github/workflows feature: add test-publish workflow 2020-12-03 17:02:59 -08:00
data Added 656 area code 2020-12-03 11:35:17 +07:00
test test: update tests to run on 12.x 2020-12-03 17:09:21 -08:00
.eslintrc.json fix: ensure eslint rules pass 2020-08-24 18:11:45 -07:00
.gitignore Initial commit 2016-04-21 20:53:10 -07:00
index.js feature: refactor to split countries and currencies to reduce data size 2020-08-24 19:35:37 -07:00
package-lock.json chore: update deps, update version 2020-12-03 16:58:22 -08:00
package.json chore: update deps, update version 2020-12-03 16:58:22 -08:00
README.md feature: refactor to split countries and currencies to reduce data size 2020-08-24 19:35:37 -07:00

countrydata

A library for getting data about countries.

Code Example

const countrydata = require( 'countrydata' );

// look up country data by ISO3166 alpha3 code (default and fastest lookup)
const usa = countrydata.get( 'USA' );

// look up country by ISO3166 alpha2
const usa_by_alpha2 = countrydata.get( 'US' );

// look up country by ISO3166 numeric
const usa_by_numeric = countrydata.get( 840 );

// .all() will return an array of all countries
const countries_using_usd = countrydata.all().filter( country => {
    return country.currencies.some( ( currency ) => ( currency.code === 'USD' ) );
} );

const usa_by_find = countrydata.all().find( country => {
    return country.name.en && country.name.en === 'United States';
} );

Installation

npm install --save countrydata

Tests

npm run test

Contributing

Contributions are encouraged and appreciated. To make the process as quick and painless as possible for everyone involved, here's a checklist that will make a pull request easily accepted:

  1. Implement your new feature or bugfix
  2. Add or update tests to ensure coverage
  3. Ensure your code passes eslint using the included .eslintrc
  4. Ensure your code is formatted according to the .eslintrc
  5. Submit

License

MIT