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

all-country-data

v1.0.4

Published

This package provides extra functionality like list of countries and their capitals. Primary language, ISD Codes, Country Codes, Currency Name, Country Flags, Currency Codes will also be provided.

Downloads

417

Readme

All Country Data

Installation

npm i all-country-data

Newly Added

Flags images are now compressed. Package size reduced from 3.03 MB to ~899 KB.
Country Capital Geo: Lattitude and Longitude


Features

Country Flags, Country Capitals, Capital Lattitude/Longitude, Country List, ISD Code, Official Languages, etc...

Usage

import country from "all-country-data";

console.log(country.all());
console.log(country.findByCountryCode("+91"));
var country = require("all-country-data");

console.log(country.all());
console.log(country.findByCountryCode("+91"));

Use Only Required Function

import search from "all-country-data/dist/search";
or;
var search = require("all-country-data/dist/search");

console.log(search("India"));
import countryCapitalList from "all-country-data/dist/countryCapitalList";
or;
var countryCapitalList = require("all-country-data/dist/countryCapitalList");

console.log(countryCapitalList());
You can import any particular function by the above method.

Functions

| Function Name | Returns | Arguments | Description | | ---------------------- | -------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | all() | Array of Objects | null | Returns all countries data including "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code". | | count() | No. of countries {Integer} | null | Returns total number of countries in the world. | | countryCapitalList() | Array of Objects | null | Returns capitals of all the countries. | | countryCurrencyList() | Array of Objects | null | Returns every country name with currency name and currency code. | | countryIsdCodeList() | Array of Objects | null | Returns ISD Code of all the countries. | | countryLanguageList() | Array of Objects | null | Returns all country names with their languages. returns {"country": Type String, "languages": Type Array} | | countryList() | Array of Objects | null | Returns Country names with their Codes. {"country": Type String, "country_code": Type String } | | findByCountryCode() | Single Object | String | Returns empty object if country code not found or Returns an objects after finding. | | findByCountryISD() | Single Object | String | Returns empty object if country ISD not found or Returns an objects after finding. | | findByCountryName() | Single Object | String | Returns empty object if country name not found or returns an object after finding | | findCountryByCapital() | Single Object | String | Returns empty object if country capital not found or returns an object after finding | | search() | Array of Objects | String | Returns "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code". It will search in Country Name, Country Code, ISD Code, Capital, Currency, Currency Code. This will not search for Languages. Try searchByLanguage() function to search data by language | | searchByLanguage() | Array of Objects | String | Returns "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code". It only serach in languages. Try search() function to search data by country name, code, isd, capital, etc... | | countryFlag() | String (Base64) | String | Returns transparent image data in base64 format. It only find the flag by "country name" or "country code". | | searchFlag() | Array of Objects | String | Returns Array of Objects. Object contains 'country name', 'country code' and base64 string for the transparent flag of that country. | | new capitalGeo() | Single Object | null | Returns an object with properties "country", "capital", "capital_geo" |

Examples

import countries from "all-country-data";

var allCountries = countries.all();
allCountries.map((item) => {
  console.log(item.country);
  console.log(item.country_code);
});

var totalCountries = countries.count();
console.log(totalCountries);

var capitals = countries.countryCapitalList();
capitals.map((item) => {
  console.log(item.country);
  console.log(item.capital);
});

var currency = countries.countryCurrencyList();
allCountries.map((item) => {
  console.log(item.country);
  console.log(item.currency_code);
});

var base64flag = countries.countryFlag("india");
console.log(base64flag);
// data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cD...

var searchFlag = countries.searchFlag("India");
console.log(searchFalg);
/* [
  { name: 'British Indian Ocean Territory',
    country_code: 'IO',
    flag: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0...' },
  { name: 'India',
    country_code: 'IN',
    flag: 'data:image/svg+xml;base64,PHN2ZyB4bWxu...' }
]
*/
Remaining function can also be used like the above explained functions.

GitHub Repository

Git Repository

NPM Package

NPM Package Repository

License

MIT

Free Package, by shanuraj715!