emoji-flag

1.1.0 • Public • Published

emoji-flag

This is a simple module that takes an ISO 3166-1 alpha-2 country code and returns the regional indicator symbol pair that corresponds to a given emoji flag.

Build status

Install

$ npm install emoji-flag

Usage

var flag = require('emoji-flag')
var code = require('emoji-flag/to-country-code')
 
flag('AU')
=> 🇦🇺
 
flag('CA')
=> 🇨🇦
 
code('🇦🇺')
=> 'AU'
 
code('🇨🇦')
=> 'CA'
 
code(flag('AU'))
=> 'AU'
 
// and so on…

Example

var flag = require('emoji-flag')
var countries = require('country-list/data')
 
countries.slice(0, 5).forEach(function (country) {
  console.log(
    country.code, flag(country.code), country.name
  )
})
 
=>
AF 🇦🇫   Afghanistan
AX 🇦🇽  Åland Islands
AL 🇦🇱   Albania
DZ 🇩🇿   Algeria
AS 🇦🇸   American Samoa

Page weight (browserified)

compression size
emoji-flag.js 1.76 kB
emoji-flag.min.js 925 B
emoji-flag.min.js.gz 502 B

What about the emoji-flags module?!

This has a simpler implementation and API. You should use emoji-flags if you need meta information about a given flag.

License

MIT

Package Sidebar

Install

npm i emoji-flag

Weekly Downloads

975

Version

1.1.0

License

MIT

Last publish

Collaborators

  • michaelrhodes