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 🙏

© 2024 – Pkg Stats / Ryan Hefner

countryinfo

v1.0.5

Published

ISO-codes, currencies, languages... All you need to know about countries.

Downloads

1,125

Readme

country.

Build Status

country. provides all kinds of data on countries. It offers the following information:

  • ISO-3611-1/2/3 code
  • International Olympic Committee Code (IOC)
  • Spoken languages
  • Used currencies
  • Calling codes
  • Country Flag as an Emoji
  • Names in the following languages:

Code | Language ------------- | ------------- ar | Arabic cs | Czech de | German en | English et | Estonian fi | Finnish fr | French it | Italian nb | Norwegian Bokmål nn | Norwegian Nynorsk nl | Dutch pl | Polish pt | Portuguese ru | Russian sv | Swedish tr | Turkish zh | Chinese

This library also classifies countries into regions. The following regions are supported:

  • Asia (Central + Southern + Southeast + East + Western)

  • Central Asia

  • Southern Asia

  • Southeast Asia

  • East Asia

  • Western Asia

  • Africa (Central + North + Southern + East + West)

  • Central Africa

  • North Africa

  • Southern Africa

  • East Africa

  • West Africa

  • Europe (Northern + Southern + Eastern + Western)

  • Northern Europe

  • Southern Europe

  • Eastern Europe

  • Western Europe

  • America (Central + Northern + Southern)

  • Central America

  • Northern America

  • South America

  • Other

  • Australia

  • Melanesia

  • Micronesia

  • Polynesia

  • Antartica

  • Caribbean

Usage

Require country. in your project.

'use strict';
const country = require('countryinfo');

ISO 3166-1 codes

// ISO 3166-1 numeric identifiers from ...
country.iso1('DE');                 // ... ISO 3166-1 alpha-2
country.iso1('DEU');                // ... ISO 3166-1 alpha-3
country.iso1('Germany');            // ... country name
country.iso1('Deutschland', 'de');  // ... localized country name

// ISO 3166-1 alpha-2 identifiers from ...
country.iso2('276');                // ... ISO 3166-1 numeric
country.iso2('DEU');                // ... ISO 3166-1 alpha-3
country.iso2('Germany');            // ... country name
country.iso2('Deutschland', 'de');  // ... localized country name

// ISO 3166-1 alpha-3 identifiers from ...
country.iso3('276');                // ... ISO 3166-1 numeric
country.iso3('DE');                 // ... ISO 3166-1 alpha-2
country.iso3('Germany');            // ... country name
country.iso3('Deutschland', 'de');  // ... localized country name

IOC

// IOC identifiers from ...
country.ioc('276');                // ... ISO 3166-1 numeric
country.ioc('DE');                 // ... ISO 3166-1 alpha-2
country.ioc('DEU');                // ... ISO 3166-1 alpha-3
country.ioc('Germany');            // ... country name
country.ioc('Deutschland', 'de');  // ... localized country name

Languages

// Spoken languages from ...
country.languages('276');                // ... ISO 3166-1 numberic
country.languages('DE');                 // ... ISO 3166-1 alpha-2
country.languages('DEU');                // ... ISO 3166-1 alpha-3
country.languages('Germany');            // ... country name
country.languages('Deutschland', 'de');  // ... localized country name

Currencies

// Used currencies in country from ...
country.currencies('276');                // ... ISO 3166-1 numberic
country.currencies('DE');                 // ... ISO 3166-1 alpha-2
country.currencies('DEU');                // ... ISO 3166-1 alpha-3
country.currencies('Germany');            // ... country name
country.currencies('Deutschland', 'de');  // ... localized country name

Country data

// Complete data of country from ...
country.data('276');                // ... ISO 3166-1 numberic
country.data('DE');                 // ... ISO 3166-1 alpha-2
country.data('DEU');                // ... ISO 3166-1 alpha-3
country.data('Germany');            // ... country name
country.data('Deutschland', 'de');  // ... localized country name

Regions

// Region data
country.regions();                   // all regions
country.regionsData();               // all regions including data for all countries (ISO 3166-1 codes, IOC,...)
country.regions('europe');           // find region by identifier ...
country.regions('Central Asia');     // ... or by name
country.regionsData('europe');       // complete region data by identifier...
country.regionsData('Central Asia'); // ... or by name

Contribution & Data Sources

If you want to add additional country names to the list, feel free to do so in the /lib/data/names.json file. The structure should be clear.

{
	"DE": {                        // ISO 3166-1 alpha-2 identifier
		"en": ["Germany"],        // array of to be added names in the set locale
		"ar": [" ألمانيا"]
	}
}

To import the data into the library, run make in the root directory. This recreates the /lib/data/masterData.json file.

Data sources

I don't need a JS library, I just need the data.

Run make in the root directory of the project and copy the /lib/data/masterData.json file. This file contains all the mentioned data.

Build / Test / Update

In package json:

  • npm test - run tests
  • npm run cleaner - update master data