README
node-world
Utility to work with countries data.
Features
- European countries (for now)
- 4 languages for countries localized name (french, english, dutch and german)
Future
- Add web interface to manage countries data
- Add more countries
- Add more languages
- Add more data about each countries
Feel free to contribute.
Installation
$ npm install node-world
Quick Start
Load in the module
var World = require('node-world');
Retrieve country object
You can find a country by code, ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3, and by name.
var country = World.findCountryByCode('SP'); // ISO 3166-1-alpha-2
var country = World.findCountryByCode('ESP'); // ISO 3166-1-alpha-3
var country = World.findCountryByName('Spain'); // Country name
Country methods
- getAlpha2Code() : retrieve ISO 3166-1-alpha-2
SP
- getAlpha3Code() : retrieve ISO 3166-1-alpha-3
ESP
- getCodes() : retrieve a JSON object which contains the 2 codes above
{
"alpha_2_code": "ES",
"alpha_3_code": "ESP"
}
- getName() : retrieve international country name
Spain
- getLocalizedNames() : retrieve localized names
{
"fr": "Espagne",
"en": "Spain",
"de": "Spanien",
"nl": "Spanje"
}
- getLocalizedNameIn( language ) : retrieve a localized name by language
Spain
Tests
$ npm run-script be-data