country-data
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1674,3 +1674,2 @@ [ | ||
"currencies": [ | ||
"SVC", | ||
"USD" | ||
@@ -1981,3 +1980,3 @@ ], | ||
"currencies": [ | ||
"ZMK" | ||
"ZMW" | ||
], | ||
@@ -1990,3 +1989,7 @@ "name": "Zambia" | ||
"currencies": [ | ||
"ZWL" | ||
"USD", | ||
"ZAR", | ||
"BWP", | ||
"GBP", | ||
"EUR" | ||
], | ||
@@ -1993,0 +1996,0 @@ "name": "Zimbabwe" |
15
index.js
@@ -1,6 +0,8 @@ | ||
var data_countries = require('./data/countries.json'), | ||
_ = require('underscore'); | ||
var data_countries = require('./data/countries.json'), | ||
data_currencies = require('./data/currencies.json'), | ||
_ = require('underscore'); | ||
exports.data = { | ||
countries: data_countries | ||
countries: data_countries, | ||
currencies: data_currencies, | ||
}; | ||
@@ -18,1 +20,8 @@ | ||
exports.currencies = { | ||
code: {}, | ||
}; | ||
_.each(data_currencies, function (currency) { | ||
exports.currencies.code[currency.code] = currency; | ||
}); |
{ | ||
"name": "country-data", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Data about countries - like their ISO codes and currencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/LinkToBooks/country-data", |
@@ -8,2 +8,4 @@ # Country Data | ||
## Countries | ||
The data currently provided for each country is: | ||
@@ -16,3 +18,12 @@ | ||
## Currencies | ||
It is not that useful to just have the currency code(s) for a country, so included is currency data too: | ||
* `name` The english name for the currency | ||
* `code` The [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) code | ||
* `number` The [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) number | ||
* `decimals` The number of decimal digits conventionally shown | ||
## Installing | ||
@@ -28,6 +39,11 @@ | ||
``` javascript | ||
var countries = require('country-data').countries; | ||
var countries = require('country-data').countries, | ||
currencies = require('country-data').currencies; | ||
// countries are found using alpha2 or alpha3 | ||
console.log( countries.alpha2.BE.name ); // 'Belgium' | ||
console.log( countries.alpha3.FRA.currencies ); // ['EUR'] | ||
// currencies are accessed by their code | ||
console.log( currencies.code.USD.name ); // 'United States dollar' | ||
``` | ||
@@ -79,1 +95,5 @@ | ||
``` | ||
## Sources | ||
The currency data was copied from the [Wikipedia ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) page. |
@@ -1,3 +0,6 @@ | ||
var countries = require('..').countries, | ||
assert = require('assert'); | ||
var countries = require('..').countries, | ||
currencies = require('..').currencies, | ||
countryData = require('..').data.countries, | ||
assert = require('assert'), | ||
_ = require('underscore'); | ||
@@ -20,2 +23,13 @@ describe('countries', function () { | ||
describe('check currencies for each country', function () { | ||
_.each( countryData, function (country) { | ||
describe(country.alpha2, function () { | ||
_.each( country.currencies, function (currency) { | ||
it(currency, function () { | ||
assert( currencies.code[currency] ); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100027
16
3171
96