1.0.4 • Published 4 months ago

all-country-data v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

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 NameReturnsArgumentsDescription
all()Array of ObjectsnullReturns all countries data including "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code".
count()No. of countries {Integer}nullReturns total number of countries in the world.
countryCapitalList()Array of ObjectsnullReturns capitals of all the countries.
countryCurrencyList()Array of ObjectsnullReturns every country name with currency name and currency code.
countryIsdCodeList()Array of ObjectsnullReturns ISD Code of all the countries.
countryLanguageList()Array of ObjectsnullReturns all country names with their languages. returns {"country": Type String, "languages": Type Array}
countryList()Array of ObjectsnullReturns Country names with their Codes. {"country": Type String, "country_code": Type String }
findByCountryCode()Single ObjectStringReturns empty object if country code not found or Returns an objects after finding.
findByCountryISD()Single ObjectStringReturns empty object if country ISD not found or Returns an objects after finding.
findByCountryName()Single ObjectStringReturns empty object if country name not found or returns an object after finding
findCountryByCapital()Single ObjectStringReturns empty object if country capital not found or returns an object after finding
search()Array of ObjectsStringReturns "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 ObjectsStringReturns "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)StringReturns transparent image data in base64 format. It only find the flag by "country name" or "country code".
searchFlag()Array of ObjectsStringReturns Array of Objects. Object contains 'country name', 'country code' and base64 string for the transparent flag of that country.
new capitalGeo()Single ObjectnullReturns 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!

1.0.4

4 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.3

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.21

3 years ago

0.0.2

3 years ago

1.0.0

3 years ago