countryflag
Advanced tools
Comparing version 1.0.3 to 2.0.0
27
index.js
@@ -8,8 +8,22 @@ import countries from './countries' | ||
// Well if Bhutan is supported I think we're good to go | ||
const supportsEmojiFlags = ifEmoji('🇧🇹') | ||
// const supportsEmojiFlags = ifEmoji('🇧🇹') | ||
const supportsEmojiFlags = true | ||
const countryflag = _iso2 => { | ||
const iso2 = _iso2.toLowerCase(); | ||
const ISO2 = _iso2.toUpperCase(); | ||
const country = countries.find(c => c.ISO2 === ISO2) | ||
const countryflag = iso => { | ||
let iso2 | ||
let ISO2 | ||
let country | ||
if (iso.length === 2) { | ||
iso2 = iso.toLowerCase() | ||
ISO2 = iso2.toUpperCase() | ||
country = countries.find(c => c.ISO2 === ISO2) | ||
} | ||
else if (iso.length === 3) { | ||
const ISO3 = iso.toUpperCase() | ||
country = countries.find(c => c.ISO3 === ISO3) | ||
ISO2 = country.ISO2 | ||
iso2 = ISO2.toLowerCase() | ||
} else { | ||
throw new Error(iso, ' is not an ISO 2 nor ISO 3 code') | ||
} | ||
@@ -28,3 +42,2 @@ let emoji = null | ||
const svg = BASE_SVG_PATH_TEMPLATE.replace('{iso2}', iso2); | ||
return { | ||
@@ -37,2 +50,2 @@ emoji, | ||
export default countryflag | ||
export default countryflag |
{ | ||
"name": "countryflag", | ||
"description": "return an emoji flag or possible fallbacks for a given iso2 code", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -1,1 +0,1 @@ | ||
Returns an emoji flag or possible fallbacks for a given iso2 code | ||
Returns an emoji flag or possible fallbacks for a given iso2 or iso3 code |
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
ISO2: country.cca2, | ||
ISO3: country.cca3, | ||
name: country.name.common | ||
@@ -11,0 +12,0 @@ } |
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
67
3059
6