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

country-tools

v0.4.0

Published

Simple tool for getting information about countries.

Downloads

1,195

Readme

Country Tools

Build Status

A simple NodeJS helper for getting information about countries of the world.

Usage

npm install country-tools
import { getCurrencyFromIso2 } from 'country-tools';

Data

Data has been downloaded from mledoze/countries.

Included Tools

Get Currency Code from Country ISO2 Code

Returns a country's currency given it's ISO2 code (US, FI, etc).

getCurrencyFromIso2(countryCode: string): string | null

Sample:

getCurrencyFromIso2('US'); // USD
getCurrencyFromIso2('FI'); // EUR
getCurrencyFromIso2('XX'); // null

Get Country Information from Country ISO2 Code

Returns complete information for a given country:

findCountryByIso2(countryCode: string): Country | null

Sample:

findCountryByIso2('FI'); // { ...info }
findCountryByIso2('XX'); // null

This function returns type Country which looks like the following:

const test = {
  name: {
    common: 'Finland',
    official: 'Republic of Finland',
    native: {
      fin: {
        official: 'Suomen tasavalta',
        common: 'Suomi',
      },
      swe: {
        official: 'Republiken Finland',
        common: 'Finland',
      },
    },
  },
  tld: ['.fi'],
  cca2: 'FI',
  ccn3: '246',
  cca3: 'FIN',
  cioc: 'FIN',
  independent: true,
  status: 'officially-assigned',
  currencies: {
    EUR: {
      name: 'Euro',
      symbol: '€',
    },
  },
  idd: {
    root: '+3',
    suffixes: ['58'],
  },
  capital: ['Helsinki'],
  altSpellings: ['FI', 'Suomi', 'Republic of Finland', 'Suomen tasavalta', 'Republiken Finland'],
  region: 'Europe',
  subregion: 'Northern Europe',
  languages: {
    fin: 'Finnish',
    swe: 'Swedish',
  },
  translations: {
    ces: {
      official: 'Finská republika',
      common: 'Finsko',
    },
    deu: {
      official: 'Republik Finnland',
      common: 'Finnland',
    },
    est: {
      official: 'Soome Vabariik',
      common: 'Soome',
    },
    fin: {
      official: 'Suomen tasavalta',
      common: 'Suomi',
    },
    fra: {
      official: 'République de Finlande',
      common: 'Finlande',
    },
    hrv: {
      official: 'Republika Finska',
      common: 'Finska',
    },
    hun: {
      official: 'Finn Köztársaság',
      common: 'Finnország',
    },
    ita: {
      official: 'Repubblica di Finlandia',
      common: 'Finlandia',
    },
    jpn: {
      official: 'フィンランド共和国',
      common: 'フィンランド',
    },
    kor: {
      official: '핀란드 공화국',
      common: '핀란드',
    },
    nld: {
      official: 'Republiek Finland',
      common: 'Finland',
    },
    per: {
      official: 'جمهوری فنلاند',
      common: 'فنلاند',
    },
    pol: {
      official: 'Republika Finlandii',
      common: 'Finlandia',
    },
    por: {
      official: 'República da Finlândia',
      common: 'Finlândia',
    },
    rus: {
      official: 'Финляндская Республика',
      common: 'Финляндия',
    },
    slk: {
      official: 'Fínska republika',
      common: 'Fínsko',
    },
    spa: {
      official: 'República de Finlandia',
      common: 'Finlandia',
    },
    urd: {
      official: 'جمہوریہ فن لینڈ',
      common: 'فن لینڈ',
    },
    zho: {
      official: '芬兰共和国',
      common: '芬兰',
    },
  },
  latlng: [64, 26],
  landlocked: false,
  borders: ['NOR', 'SWE', 'RUS'],
  area: 338424,
  flag: '🇫🇮',
  demonyms: {
    eng: {
      f: 'Finnish',
      m: 'Finnish',
    },
    fra: {
      f: 'Finlandaise',
      m: 'Finlandais',
    },
  },
};

License

The code is licensed under the MIT License. See the data's LICENSE file for more information.