countries-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Country Information Finder 🌎

An elegant TypeScript module to fetch information about countries from a comprehensive JSON data file. Query by various criteria including region, country code, currency, and language.

Features 🌟

  • Rich Data Source: Uses a structured JSON file containing detailed country data.
  • Typed with TypeScript: Uses TypeScript for static type checking.
  • Multiple Query Options: Find countries by different criteria.

Installation 📦

# if your project uses npm
npm install --save countries-ts
# if your project uses yarn
yarn add countries-ts

Usage 🚀

First, you'll need to import the necessary methods:

import {
  getByCodeArea,
  getByCode,
  getByCountry,
  getByCurrency,
  getByLanguage,
  getByCountryCode,
  listCountries
} from 'countries-ts';

API Reference 📘

getByCodeArea(region: string): Country[] Retrieve countries based on their region.

const europeanCountries = getByCodeArea('EU');

getByCode(code: string): Country | undefined Retrieve a country by its code.

const infoAboutFrance = getByCode('FR');

getByCountry(countryName: string): Country | undefined Fetch country details using its name.

const infoAboutCanada = getByCountry('Canada');

getByCurrency(currencyCode: string): Country[] Find countries that use a specific currency.

const countriesUsingEuro = getByCurrency('EUR');

getByLanguage(languageCode: string): Country[] Find countries where a specific language is spoken.

const englishSpeakingCountries = getByLanguage('en');

getByCountryCode(countryCode: string): Country | undefined Retrieve country information using its phone code.

const infoAboutIndia = getByCountryCode('+91');

listCountries(): Country[] Retrieve all countries as a list.

const result = listCountries();

Contribution 💪

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing 📄

The code in this project is licensed under MIT license.

Readme

Keywords

Package Sidebar

Install

npm i countries-ts

Weekly Downloads

275

Version

1.0.3

License

ISC

Unpacked Size

219 kB

Total Files

14

Last publish

Collaborators

  • esmatnawahda
  • mohammedfaraj
  • geniucode-dev