country-data
Advanced tools
Comparing version 0.0.13 to 0.0.14
# Changes | ||
## v0.0.14 | ||
* Added languages - many thanks to Moritz Lawitschka (@lawitschka) for doing the initial work. | ||
## v0.0.13 | ||
* @carlosleopoldo added 521 calling code to Mexico | ||
## v0.0.12 | ||
@@ -4,0 +12,0 @@ |
@@ -31,3 +31,3 @@ // Take the csv and convert to json and tidy it up so that it is consistent. | ||
// change the appropriate fields to be an array | ||
_.each(['currencies', 'countryCallingCodes'], function(key) { | ||
_.each(['currencies', 'countryCallingCodes', 'languages'], function(key) { | ||
_.each(countries, function (country) { | ||
@@ -34,0 +34,0 @@ country[key] = country[key] ? country[key].split(',') : []; |
17
index.js
var countriesAll = require('./data/countries.json'), | ||
currenciesAll = require('./data/currencies.json'), | ||
languagesAll = require('./data/languages.json'), | ||
regions = require('./data/regions'), | ||
@@ -24,7 +25,21 @@ lookup = require('./lookup'), | ||
exports.languages = { | ||
all: languagesAll, | ||
}; | ||
// Note that for the languages there are several entries with the same alpha3 - | ||
// eg Dutch and Flemish. Not sure how to best deal with that - here whichever | ||
// comes last wins. | ||
_.each(languagesAll, function (language) { | ||
exports.languages[language.alpha2] = language; | ||
exports.languages[language.bibliographic] = language; | ||
exports.languages[language.alpha3] = language; | ||
}); | ||
exports.regions = regions; | ||
exports.lookup = lookup({ | ||
countries: countriesAll, | ||
currencies: currenciesAll | ||
currencies: currenciesAll, | ||
languages: languagesAll | ||
}); |
@@ -8,3 +8,4 @@ var _ = require('underscore'); | ||
countries: search.bind(null, o.countries), | ||
currencies: search.bind(null, o.currencies) | ||
currencies: search.bind(null, o.currencies), | ||
languages: search.bind(null, o.languages) | ||
}; | ||
@@ -11,0 +12,0 @@ } |
{ | ||
"name": "country-data", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Data about countries - like their ISO codes and currencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/OpenBookPrices/country-data", |
@@ -24,2 +24,3 @@ # Country Data | ||
* `currencies` An array of [ISO 4217 currency codes](http://en.wikipedia.org/wiki/ISO_4217) with the primary one first | ||
* `languages` An array of [ISO 639-2](http://en.wikipedia.org/wiki/ISO_639-2) codes for languages (may not be complete). | ||
* `countryCallingCodes` An array of the international call prefixes for this country. | ||
@@ -43,2 +44,11 @@ * `ioc` The [International Olympic Committee country code](http://en.wikipedia.org/wiki/List_of_IOC_country_codes) | ||
## Languages | ||
A list of languages provided by [ISO 639-2](http://en.wikipedia.org/wiki/ISO_639-2); | ||
* `name` The english name for the language | ||
* `alpha2` The two letter [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) code for the language (may be blank). | ||
* `alpha3` The three letter terminological [ISO 639-2](http://en.wikipedia.org/wiki/ISO_639-2) code for the language (may be blank). | ||
* `bibliograpic` The three letter bibliographic [ISO 639-2](http://en.wikipedia.org/wiki/ISO_639-2) code for the language (may be blank). | ||
## Lookup | ||
@@ -61,3 +71,4 @@ | ||
currencies = require('country-data').currencies, | ||
regions = regions('country-data').regions; | ||
regions = regions('country-data').regions, | ||
languages = require('country-data').languages; | ||
@@ -64,0 +75,0 @@ // .all gives you an array of all entries |
var countries = require('..').countries, | ||
currencies = require('..').currencies, | ||
languages = require('..').languages, | ||
assert = require('assert'), | ||
@@ -33,3 +34,3 @@ _ = require('underscore'); | ||
it(currency, function () { | ||
assert( currencies[currency] ); | ||
assert( currencies[currency] ); | ||
}); | ||
@@ -40,2 +41,14 @@ }); | ||
}); | ||
describe('check languages for each country', function () { | ||
_.each( countries.all, function (country) { | ||
describe(country.alpha2, function () { | ||
_.each( country.languages, function (language) { | ||
it(language, function () { | ||
assert( languages[language] ); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
var lookup = require('..').lookup, | ||
countries = require('..').countries, | ||
currencies = require('..').currencies, | ||
languages = require('..').languages, | ||
assert = require('chai').assert, | ||
@@ -41,2 +42,12 @@ _ = require('underscore'); | ||
describe("check languages by name", function () { | ||
_.each( languages, function (language, name) { | ||
describe(name, function () { | ||
it(name, function () { | ||
if(language.name) assert.include( lookup.languages({name: language.name}), language ); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
224803
26
9213
164
0