countrydata
v3.0.1
Published
A library for getting data about countries.
Downloads
1,615
Readme
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:
- Implement your new feature or bugfix
- Add or update tests to ensure coverage
- Ensure your code passes eslint using the included .eslintrc
- Ensure your code is formatted according to the .eslintrc
- Submit
License
MIT