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

@doubco/countries

v1.2.0

Published

Countries, regions, currencies, languages, phone codes, and timezones data formated as JSON.

Downloads

163

Readme

Countries 🏳

Countries is basically a data package (with some helpers) for easy access to country, locale, language, currency and time zone data.

Installation

yarn add @doubco/countries

Usage

⚠️ GraphQL versions' has matching object key and list _id with type definations.

Countries

Data Structure

countries example
{
  ...,
  "TR": {
    "name": "Turkey",
    "flag": "🇹🇷",
    "code": "+90",
    "currency": "TRY",
    "capital": "Ankara",
    "languages": ["tr"],
    "nativeName": "Türkiye"
  },
  ...
}
countryList example
[
  ...
  {
    "_id": "TR",
    "label": "Turkey (Türkiye)"
  },
  ...
]

Import Statements

import { countries, countryList } from "@doubco/countries";

// or

import countries from "@doubco/countries";

// default
// countries.data
// countries.list

// graphql alt.
// countries.graphql.data
// countries.graphql.list

Locales

Data Structure

locales example
{
  ...,
  "en_GB": "English - Great Britain",
  ...
}
localeList example
[
  ...
  {
    "_id": "en_GB",
    "label": "English - Great Britain"
  },
  ...
]

Import Statements

import { locales, localeList } from "@doubco/countries/locales";

// or

import locales from "@doubco/countries/locales";

// default
// locales.data
// locales.list

// graphql alt.
// locales.graphql.data
// locales.graphql.list

Languages

Data Structure

languages example
{
  ...,
  "tr": {
    "name": "Turkish",
    "nativeName": "Türkçe"
  },
  ...
}
languageList example
[
  ...
  {
    "_id": "tr",
    "label": "Turkish (Türkçe)"
  },
  ...
]

Import Statements

import { languages, languageList } from "@doubco/countries/languages";

// or

import languages from "@doubco/countries/languages";

// default
// languages.data
// languages.list

// graphql alt.
// languages.graphql.data
// languages.graphql.list

Currencies

Data Structure

currencies example
{
  ...,
  "TRY": {
    "symbol": "TRY",
    "nativeSymbol": "\u20BA",
    "decimalDigits": 2,
    "name": "Turkish Lira",
    "nativeName": "Türk Lirası",
    "namePlural": "Turkish Lira"
  },
  ...
}

⚠️ nativeName is only available on some currencies.

currencyList example
[
  ...
  {
    "_id": "TRY",
    "label": "Turkish Lira (₺)",
  },
  ...
]
currencyListLite example
[
  ...
  {
    "_id": "TRY",
    "label": "TRY",
  },
  ...
]

Import Statements

import {
  currencies,
  currencyList,
  currencyListSimple,
  currenciesLite,
  currencyListLite,
  currencyListLiteSimple,
} from "@doubco/countries/currencies";

import currencies from "@doubco/countries/currencies";

// default
// currencies.data;
// currencies.list;
// currencies.simpleList;

// lite
// currencies.lite.data;
// currencies.lite.list;
// currencies.lite.simpleList;

// graphql alt.
// currencies.graphql.data;
// currencies.graphql.list;
// currencies.graphql.simpleList;
// currencies.graphql.lite.data;
// currencies.graphql.lite.list;
// currencies.graphql.lite.simpleList;

Simple list versions' uses key as label.

Lite versions' includes only currencies supported by most currency convertion APIs.


Timezones

Data Structure

timezones example
{
  ...,
  "TRY": {
    "symbol": "TRY",
    "nativeSymbol": "\u20BA",
    "decimalDigits": 2,
    "name": "Turkish Lira",
    "nativeName": "Türk Lirası",
    "namePlural": "Turkish Lira"
  },
  ...
}
timezoneList example
[
  ...
  {
    "_id": "TRY",
    "label": "Turkish Lira (₺)",
  },
  ...
]

Import Statements

import { timezones, timezoneList } from "@doubco/countries/timezones";

// or

import timezones from "@doubco/countries/timezones";

// default
// timezones.data
// timezones.list

// lite
// timezones.lite.data
// timezones.lite.list

// graphql alt.
// timezones.graphql.data
// timezones.graphql.list
// timezones.graphql.lite.data
// timezones.graphql.lite.list

Lite versions only includes one time zone once.


Usage with GraphQL

This library also exposes GraphQL resolvers and type definations.

es6

import { countries, locales } from "@doubco/countries/graphql";

export default {
  typeDefs: [
    countries.typeDefs, // this is it.
    locales.typeDefs, // this is it.
    User.typeDefs,
    Log.typeDefs,
  ...
  ],
  resolvers: merge(
    countries.resolvers, // this is it.
    locales.resolvers, // this is it.
    Auth.resolvers,
    User.resolvers,
    ...
  ),
};

nodejs

const { countries, locales } = require("@doubco/countries/graphql");

module.exports = {
  typeDefs: [
    countries.typeDefs, // this is it.
    locales.typeDefs, // this is it.
    Auth.typeDefs,
    User.typeDefs,
    Log.typeDefs,
  ...
  ],
  resolvers: merge(
    countries.resolvers, // this is it.
    locales.resolvers, // this is it.
    Auth.resolvers,
    User.resolvers,
    ...
  ),
};

This usage is for Apollo Server, you can use similar approach on other frameworks.


Contribute

Pull requests are welcome and please submit bugs 🐛.

Contact

Notes

Region data is from https://github.com/country-regions/country-region-data