2.0.8 • Published 8 years ago

country-dictionary v2.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Country Dictionary

Node.JS Country Descriptor

This modules allows you to grab information about any country (cities, languages spoken, phone index, ...etc).

Installation

$ npm install country-dictionary

Example Code

var _ = require('underscore');
var countryDict = require('country-dictionary')();

// Set Google Maps Geocoding API Key if you would like to find a country from an address
countryDict.setGMapsAPIKey('<API Key>');

// Or:
var CountryDict = require('country-dictionary');

var countryDict = new CountryDict({
    GMapsApiKey: '<API Key>'
});

// get All countries
var countries = countryDict.getAllCountries();

// get country by name
var country = countryDict.getCountryByName('France');

// Get 100 cities in a country
countryDict.getCities('France', 100, function(error, cities){
  console.log("Found Cities: " + JSON.stringify(cities));
})

// get country by Phone Index
var country = countryDict.getCountryByPhoneIndex('49');

// get country from a given address (Uses Google Maps Geocoding API)
countryDict.getCountryByAddress('1600 Amphitheatre Pkwy, Mountain View', function(error, country){
  console.log("Found Country: " + country)
});

// get country's capital
var capital = countryDict.getCapital('Mexico');

// get country's spoken languages  (Array)
var languages = countryDict.getLanguages('Mexico');


// get countries by language spoken
countryDict.getCountriesByLanguage('arabic', function(error, countries){
  _.each(_.pluck(countries, 'name'), function(country){
    console.log("country: " + country);
  });
});

// get countries by currency used
countryDict.getCountriesByCurrency('EUR', function(error, countries){
  _.each(_.pluck(countries, 'name'), function(country){
    console.log("country: " + country);
  });
});

// get countries by contient
countryDict.getCountriesByContinent('EU', function(error, countries){
  _.each(_.pluck(countries, 'name'), function(country){
    console.log("country: " + country);
  });
});

// check if country is in Europe
countryDict.inEurope('India', function(error, found){
    console.log("Seriously? " + found);
});

Running Tests

Tests can be found in /test/api.test.js
$ npm test

License (MIT)

Copyright (c) 2016, Aymen Mouelhi.

Author: Aymen Mouelhi

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago