country-data
Advanced tools
Comparing version 0.0.20 to 0.0.21
# Changes | ||
## v0.0.21 | ||
* Added callingCountries - thanks @chemerisuk | ||
* Updated docs to remove things that have been implemented from future additions list | ||
## v0.0.20 | ||
@@ -4,0 +9,0 @@ |
10
index.js
@@ -59,4 +59,11 @@ 'use strict'; | ||
var callingCountries = {all: []}; | ||
var callingCodesAll = _.reduce(countriesAll, function (codes, country) { | ||
if (country.countryCallingCodes && country.countryCallingCodes.length) { | ||
callingCountries.all.push(country); | ||
callingCountries[country.alpha2] = country; | ||
callingCountries[country.alpha3] = country; | ||
_.each(country.countryCallingCodes, function (code) { | ||
@@ -71,2 +78,5 @@ if (codes.indexOf(code) == -1) { | ||
delete callingCountries['']; // remove empty alpha3s | ||
exports.callingCountries = callingCountries; | ||
callingCodesAll.sort(function (a, b) { | ||
@@ -73,0 +83,0 @@ var parse = function (str) { return parseInt(str) }; |
{ | ||
"name": "country-data", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Data about countries - like their ISO codes and currencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/OpenBookPrices/country-data", |
@@ -42,3 +42,3 @@ # Country Data | ||
* `decimals` The number of decimal digits conventionally shown | ||
* `symbol` The currency symbol for the currency (e.g. ¥, $ etc.). Some symbols are not available, in which case | ||
* `symbol` The currency symbol for the currency (e.g. ¥, $ etc.). Some symbols are not available, in which case | ||
`symbol` contains the ISO 4217 code. Credit to [bengourley/currency-symbol-map](https://github.com/bengourley/currency-symbol-map) | ||
@@ -71,6 +71,7 @@ for the symbol database. | ||
``` javascript | ||
var countries = require('country-data').countries, | ||
currencies = require('country-data').currencies, | ||
regions = require('country-data').regions, | ||
languages = require('country-data').languages; | ||
var countries = require('country-data').countries, | ||
currencies = require('country-data').currencies, | ||
regions = require('country-data').regions, | ||
languages = require('country-data').languages, | ||
callingCountries = require('country-data').callingCountries; | ||
@@ -85,2 +86,4 @@ // .all gives you an array of all entries | ||
// callingCountries is like countries but only has entries with dialing codes. | ||
// currencies are accessed by their code (uppercase) | ||
@@ -113,11 +116,7 @@ console.log( currencies.USD.name ); // 'United States dollar' | ||
* Top level domains | ||
* Wikipedia links | ||
* Coordinates (centroid, bounding box, etc) | ||
* International dialling codes | ||
* Languages spoken - most common first | ||
### Currencies | ||
* currency symbols | ||
* other currency that it is [pegged](http://en.wikipedia.org/wiki/Fixed_exchange_rate) to | ||
@@ -124,0 +123,0 @@ |
var callingCodes = require('..').callingCodes.all, | ||
countries = require('..').countries.all, | ||
callingCountries = require('..').callingCountries, | ||
assert = require('assert'), | ||
@@ -22,2 +23,17 @@ _ = require('underscore'); | ||
describe('callingCountries', function () { | ||
// console.log(callingCountries); | ||
it('should contain countries with calling codes', function () { | ||
assert( callingCountries.BE ); | ||
}); | ||
it('should not contain countries without calling codes', function () { | ||
assert( !callingCountries.CP, 'Clipperton Island'); | ||
assert( !callingCountries[''], 'empty string' ); | ||
}); | ||
}); | ||
}); |
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
239007
9642
166