npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cf-emoji

v1.0.6

Published

Ultra-fast country code to flag emoji converter

Readme

cf-emoji

npm version npm downloads npm bundle size License: MIT

A small, zero-dependency converter from two-letter country codes or locale suffixes to Unicode flag emoji.

Highlights

  • Constant-time suffix parsing with no split, regular expressions, or case-conversion allocation
  • Two-tier bounded caching for exact hot inputs and canonical country pairs
  • Case-insensitive ASCII input
  • Exhaustive tests for all 676 letter pairs and 100% source coverage
  • Native ESM with bundled TypeScript declarations
  • Node.js 14+ and Bun support

Installation

npm install cf-emoji

The package is also available through Yarn, pnpm, and Bun.

Usage

import { toFlag } from 'cf-emoji';

toFlag('US');         // 🇺🇸
toFlag('gb');         // 🇬🇧
toFlag('en-US');      // 🇺🇸
toFlag('zh-Hant-TW'); // 🇹🇼

API

toFlag(code: string): string

Converts the final two-letter region component to a pair of Unicode regional-indicator symbols.

Accepted inputs are either:

  • exactly two ASCII letters, such as US; or
  • a string ending in a hyphen and two ASCII letters, such as en-US or zh-Hant-TW.

Letter matching is case-insensitive. Invalid lengths, separators, non-ASCII letters, and non-string runtime values throw Error('Invalid code').

toFlag performs a syntactic conversion. It does not verify that a letter pair is an officially assigned ISO 3166-1 code, and flag rendering depends on the platform and font.

Performance

The implementation uses a fast exact-input path for common country and language-region strings. Cache misses are parsed without substrings, and all aliases for the same country share one canonical flag string.

Reference throughput on Bun 1.4.0 and an AMD Ryzen 5 3500U:

| Workload | cf-emoji 1.0.6 | cf-emoji 1.0.5 | Allocation-heavy baseline | | --- | ---: | ---: | ---: | | Single hot input | 95.74 M ops/s | 70.39 M ops/s | 3.19 M ops/s | | Mixed hot set | 72.97 M ops/s | 50.33 M ops/s | 3.00 M ops/s | | 4,096 locale prefixes | 98.30 M ops/s | 8.41 M ops/s | 1.70 M ops/s |

These are microbenchmark results, not application-level latency guarantees. See BENCHMARKS.md for the complete methodology, timings, environment, caveats, and reproduction steps.

Development

bun install --frozen-lockfile
bun test
bun run build
bun run bench

The build emits one minified ESM implementation file and one declaration file in dist/.

License

MIT © Dalist