5 дней назад
История
README.md
@cutticat/country-code-emoji
Library for converting country codes (ISO 3166-1 alpha-2) to flag emojis and back.
Contents
Overview
The library provides functions for converting two-letter country codes (US, RU, GB, etc.) to flag emojis (🇺🇸, 🇷🇺, 🇬🇧) and back. Uses Unicode regional indicators (U+1F1E6–U+1F1FF).
Installation
pnpm i @cutticat/country-code-emoji
Quick start
import { countryCodeToFlagEmoji, flagEmojiToCountryCode } from "@cutticat/country-code-emoji"
// Country code → flag emoji
countryCodeToFlagEmoji("US") // "🇺🇸"
countryCodeToFlagEmoji("RU") // "🇷🇺"
countryCodeToFlagEmoji("GB") // "🇬🇧"
// Flag emoji → country code
flagEmojiToCountryCode("🇺🇸") // "US"
flagEmojiToCountryCode("🇷🇺") // "RU"
flagEmojiToCountryCode("🇬🇧") // "GB"
API
Functions
countryCodeToFlagEmoji(countryCode)— converts a country code to a flag emoji; returnsundefinedfor an invalid codeflagEmojiToCountryCode(flagEmoji)— extracts a country code from a flag emoji; returnsundefinedfor an invalid emoji
Constants
regionalIndicatorBase— base code point for regional indicators (127397)asciiA,asciiZ— ASCII codes for letters A and Z
Documentation
Further documentation:
Full API documentation is available in JSDoc comments. Use IDE autocomplete to browse.
Requirements
- Node.js >= 22.0.0
- pnpm >= 10.17.0
- TypeScript >= 5.9.0
Описание
A library for converting country codes to emoji and back
Конвейеры
8
успешных
2
с ошибкой