country-locale-map
Advanced tools
Comparing version 1.4.12 to 1.5.1
12
index.js
@@ -12,3 +12,2 @@ const fuzz = require('fuzzball'); | ||
for(let i=0; i<countries.length; ++i) { | ||
@@ -20,4 +19,15 @@ countryByAlpha2Code[countries[i]['alpha2']] = countries[i]; | ||
countryNames.push(countries[i]['name']); | ||
if(countries[i]['alternate_names']) { | ||
for(let j=0; j<countries[i]['alternate_names'].length; ++j) { | ||
countryByName[countries[i]['alternate_names'][j]] = countries[i]; | ||
countryNames.push(countries[i]['alternate_names'][j]); | ||
} | ||
} | ||
} | ||
clm.getAllCountries = function(){ | ||
return countries; | ||
} | ||
/* get values by alpha2 */ | ||
@@ -24,0 +34,0 @@ clm.getAlpha3ByAlpha2 = function(alpha2) { |
{ | ||
"name": "country-locale-map", | ||
"version": "1.4.12", | ||
"version": "1.5.1", | ||
"description": "Provides mapping between country codes and provides default country locals. Includes optional fuzzy matching for country name.", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"chai": "^4.2.0", | ||
"countries-list": "^2.5.4", | ||
"countries-list": "^2.5.6", | ||
"country-code-lookup": "0.0.14", | ||
@@ -37,0 +37,0 @@ "eslint": "^6.8.0", |
@@ -287,1 +287,12 @@ # Country Locale Map [![Build Status](https://travis-ci.com/atnmorrison/country-locale-map.svg?branch=master)](https://travis-ci.com/atnmorrison/country-locale-map) | ||
- getAllCountries() | ||
```javascript | ||
clm.getCountryByName('Candaa', true); | ||
/*returns | ||
the list of all countries | ||
*/ | ||
``` | ||
@@ -185,7 +185,2 @@ /* eslint-env node, mocha */ | ||
it('getCountryByAlpha3 should return object if passed USA', function(){ | ||
@@ -200,2 +195,28 @@ let result = clm.getCountryByAlpha3('USA'); | ||
}); | ||
it('getCountryByName should return Russia if passed Russia', function(){ | ||
let result = clm.getCountryByName('Russia', false) | ||
expect(result.alpha3).to.equal('RUS') | ||
expect(result.currency).to.equal('RUB') | ||
}); | ||
it('getCountryByName should return UK if passed United Kingdom', function(){ | ||
let result = clm.getCountryByName('United Kingdom', true) | ||
expect(result.alpha3).to.equal('GBR') | ||
expect(result.currency).to.equal('GBP') | ||
}); | ||
it('getAllCountries should return 193 countries', function(){ | ||
let result = clm.getAllCountries(); | ||
expect(result.length).to.equal(248) | ||
}); | ||
}) |
Sorry, the diff of this file is too big to display
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
95056
390
298