Giter VIP home page Giter VIP logo

country-flag-emoji's Introduction

Country Flag Emoji

Build Status Test Covarage Latest Version

List of country codes and its flag emojis.

Installation

$ npm install country-flag-emoji

CDN

The library is available over a CDN:

<script src="https://unpkg.com/country-flag-emoji@latest/dist/country-flag-emoji.umd.js"></script>

<!-- Or the minified version -->
<script src="https://unpkg.com/country-flag-emoji@latest/dist/country-flag-emoji.umd.min.js"></script>

Usage

import countryFlagEmoji from "country-flag-emoji";

// All country flag emojis keyed by country code
console.log(countryFlagEmoji.data);

// Array of all country flag emojis
console.log(countryFlagEmoji.list);

// Array of country codes
console.log(countryFlagEmoji.countryCodes);

// Get country flag emoji for the given country code
console.log(countryFlagEmoji.get("US"));
// US: {
//  code: "US",
//  unicode: "U+1F1FA U+1F1F8",
//  name: "United States",
//  emoji: "๐Ÿ‡บ๐Ÿ‡ธ"
// }

API

data Property

Get all country flag emojis keyed by country code.

countryFlagEmoji.data

Data format:

{
  //...
  ID: {
    code: "ID",
    unicode: "U+1F1EE U+1F1E9",
    name: "Indonesia",
    emoji: "๐Ÿ‡ฎ๐Ÿ‡ฉ"
  },
  IE: {
    code: "IE",
    unicode: "U+1F1EE U+1F1EA",
    name: "Ireland",
    emoji: "๐Ÿ‡ฎ๐Ÿ‡ช"
  },
  //...
}

list Property

Get all country flag emojis.

countryFlagEmoji.list

Data format:

[
  //...
  {
    code: "ID",
    unicode: "U+1F1EE U+1F1E9",
    name: "Indonesia",
    emoji: "๐Ÿ‡ฎ๐Ÿ‡ฉ"
  },
  {
    code: "IE",
    unicode: "U+1F1EE U+1F1EA",
    name: "Ireland",
    emoji: "๐Ÿ‡ฎ๐Ÿ‡ช"
  },
  //...
]

countryCodes Property

Get all country codes.

countryFlagEmoji.countryCodes

Data format:

[..., "IC", "ID", "IE", ...]

get() Method

countryFlagEmoji.get([countryCode])

Parameters

Returns

There are three possible return types:

  • Array: If no countryCode being passed, it returns array of all country flag emojis.
  • undefined: If the given country code is not found.
  • Object: If the emoji is found for the given country code. The returned object has 4 properties:
    • code: The two-letter country code in ISO 3166-1 alpha-2 format.
    • unicode: Flag emoji Unicode character sequence, e.g. U+1F1EE U+1F1E9. Read more about Regional Indicator Symbol.
    • name: The country name.
    • emoji: The country flag emoji.

Related

License

MIT ยฉ Risan Bagja Pradana

country-flag-emoji's People

Contributors

greenkeeper[bot] avatar risan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.