country-code-lookup
Advanced tools
Comparing version 0.0.23 to 0.1.0
66
index.js
@@ -7,3 +7,3 @@ module.exports.byFips = function(code) { | ||
if (!isNaN(parseInt(code))) { | ||
return search('isoNo', parseInt(code).toString()) | ||
return search('isoNo', ("00" + parseInt(code).toString()).slice(-3) ) | ||
} | ||
@@ -48,3 +48,3 @@ | ||
iso3: 'AFG', | ||
isoNo: '4', | ||
isoNo: '004', | ||
internet: 'AF' | ||
@@ -60,3 +60,3 @@ }, | ||
iso3: 'ALB', | ||
isoNo: '8', | ||
isoNo: '008', | ||
internet: 'AL' | ||
@@ -72,3 +72,3 @@ }, | ||
iso3: 'DZA', | ||
isoNo: '12', | ||
isoNo: '012', | ||
internet: 'DZ' | ||
@@ -84,3 +84,3 @@ }, | ||
iso3: 'ASM', | ||
isoNo: '16', | ||
isoNo: '016', | ||
internet: 'AS' | ||
@@ -96,3 +96,3 @@ }, | ||
iso3: 'AND', | ||
isoNo: '20', | ||
isoNo: '020', | ||
internet: 'AD' | ||
@@ -108,3 +108,3 @@ }, | ||
iso3: 'AGO', | ||
isoNo: '24', | ||
isoNo: '024', | ||
internet: 'AO' | ||
@@ -131,3 +131,3 @@ }, | ||
iso3: 'ATG', | ||
isoNo: '28', | ||
isoNo: '028', | ||
internet: 'AG' | ||
@@ -143,3 +143,3 @@ }, | ||
iso3: 'ARG', | ||
isoNo: '32', | ||
isoNo: '032', | ||
internet: 'AR' | ||
@@ -155,3 +155,3 @@ }, | ||
iso3: 'ARM', | ||
isoNo: '51', | ||
isoNo: '051', | ||
internet: 'AM' | ||
@@ -178,3 +178,3 @@ }, | ||
iso3: 'AUS', | ||
isoNo: '36', | ||
isoNo: '036', | ||
internet: 'AU' | ||
@@ -190,3 +190,3 @@ }, | ||
iso3: 'AUT', | ||
isoNo: '40', | ||
isoNo: '040', | ||
internet: 'AT' | ||
@@ -202,3 +202,3 @@ }, | ||
iso3: 'AZE', | ||
isoNo: '31', | ||
isoNo: '031', | ||
internet: 'AZ' | ||
@@ -214,3 +214,3 @@ }, | ||
iso3: 'BHS', | ||
isoNo: '44', | ||
isoNo: '044', | ||
internet: 'BS' | ||
@@ -226,3 +226,3 @@ }, | ||
iso3: 'BHR', | ||
isoNo: '48', | ||
isoNo: '048', | ||
internet: 'BH' | ||
@@ -238,3 +238,3 @@ }, | ||
iso3: 'BGD', | ||
isoNo: '50', | ||
isoNo: '050', | ||
internet: 'BD' | ||
@@ -250,3 +250,3 @@ }, | ||
iso3: 'BRB', | ||
isoNo: '52', | ||
isoNo: '052', | ||
internet: 'BB' | ||
@@ -273,3 +273,3 @@ }, | ||
iso3: 'BEL', | ||
isoNo: '56', | ||
isoNo: '056', | ||
internet: 'BE' | ||
@@ -285,3 +285,3 @@ }, | ||
iso3: 'BLZ', | ||
isoNo: '84', | ||
isoNo: '084', | ||
internet: 'BZ' | ||
@@ -293,3 +293,3 @@ }, | ||
country: 'Benin', | ||
capital: 'Porto-Novo��', | ||
capital: 'Porto-Novo', | ||
fips: 'BN', | ||
@@ -309,3 +309,3 @@ iso2: 'BJ', | ||
iso3: 'BMU', | ||
isoNo: '60', | ||
isoNo: '060', | ||
internet: 'BM' | ||
@@ -321,3 +321,3 @@ }, | ||
iso3: 'BTN', | ||
isoNo: '64', | ||
isoNo: '064', | ||
internet: 'BT' | ||
@@ -333,3 +333,3 @@ }, | ||
iso3: 'BOL', | ||
isoNo: '68', | ||
isoNo: '068', | ||
internet: 'BO' | ||
@@ -345,3 +345,3 @@ }, | ||
iso3: 'BIH', | ||
isoNo: '70', | ||
isoNo: '070', | ||
internet: 'BA' | ||
@@ -357,3 +357,3 @@ }, | ||
iso3: 'BWA', | ||
isoNo: '72', | ||
isoNo: '072', | ||
internet: 'BW' | ||
@@ -369,3 +369,3 @@ }, | ||
iso3: 'BRA', | ||
isoNo: '76', | ||
isoNo: '076', | ||
internet: 'BR' | ||
@@ -381,3 +381,3 @@ }, | ||
iso3: 'VGB', | ||
isoNo: '92', | ||
isoNo: '092', | ||
internet: 'VG' | ||
@@ -393,3 +393,3 @@ }, | ||
iso3: 'BRN', | ||
isoNo: '96', | ||
isoNo: '096', | ||
internet: 'BN' | ||
@@ -2110,3 +2110,3 @@ }, | ||
iso3: 'SLB', | ||
isoNo: '90', | ||
isoNo: '090', | ||
internet: 'SB' | ||
@@ -2617,3 +2617,3 @@ }, | ||
iso3: 'ATA', | ||
isoNo: '10', | ||
isoNo: '010', | ||
internet: 'AQ' | ||
@@ -2629,3 +2629,3 @@ }, | ||
iso3: 'BVT', | ||
isoNo: '74', | ||
isoNo: '074', | ||
internet: 'BV' | ||
@@ -2641,3 +2641,3 @@ }, | ||
iso3: 'IOT', | ||
isoNo: '86', | ||
isoNo: '086', | ||
internet: 'IO' | ||
@@ -2828,3 +2828,3 @@ }, | ||
iso2: 'XK', | ||
iso3: 'UNK', | ||
iso3: 'XKS', | ||
isoNo: null, | ||
@@ -2831,0 +2831,0 @@ internet: 'XK' |
{ | ||
"name": "country-code-lookup", | ||
"version": "0.0.23", | ||
"version": "0.1.0", | ||
"description": "Finds countries by various country codes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
15
test.js
@@ -76,3 +76,3 @@ var countries = require("./index.js"); | ||
try { | ||
var uk = countries.byIso("foo bar baz"); | ||
countries.byIso("foo bar baz"); | ||
return done("exception should be thrown"); | ||
@@ -118,7 +118,16 @@ } catch (e) { | ||
var bangladesh = countries.byIso("050"); | ||
if (null == bangladesh || bangladesh.country !== "Bangladesh") | ||
return done("Bangladesh not found"); | ||
if (null == bangladesh) return done("Bangladesh not found"); | ||
if (bangladesh.country !== "Bangladesh") return done(`${bangladesh.country} found`); | ||
done(); | ||
}); | ||
it("All iso numbers are 3 digits", function (done) { | ||
var iso2 = countries.countries | ||
.filter(country => country.country !== "Republic of Kosovo") | ||
.filter(country => country.isoNo.length !== 3); | ||
if (iso2.length > 0) return done(`iso numbers are not all 3 digits - check ${iso2[0].country}`); | ||
done(); | ||
}) | ||
}); |
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
60103
2919