holafly-location
v1.1.1
Published
This is a TypeScript library for retrieving information about countries and regions. It provides a simple and efficient way to access data such as country names, ISO codes, phone codes, and flag images.
Downloads
47
Readme
Location Library
This is a TypeScript library for retrieving information about countries and regions. It provides a simple and efficient way to access data such as country names, ISO codes, phone codes, and flag images.
Installation
To install this library, run the following command in your terminal:
npm install holafly-location
Usage
Import the location Controller
class from the library:
import { location } from 'holafly-location';
Get All Countries
Returns: A list of all countries, use the getCountries
method:
const countries = location.getCountries();
Returns: An array of country objects, each containing the following properties:
- name: The name of the country
- alias: The alias of the country
- iso2: The ISO 3166-1 alpha-2 code of the country
- iso3: The ISO 3166-1 alpha-3 code of the country
- phoneCode: The phone code of the country
- capital: The capital city of the country
- currency: The currency of the country
- flagImage: The URL of the flag image of the country
Get All Regions
To get a list of all regions, use the getRegions
method:
const regions = location.getRegions();
Returns: An array of region objects, each containing the following properties:
- name: The name of the region
- alias: The alias of the region
- flagImage: The URL of the flag image of the region
Get Country Phone Codes
This method returns a list of all phone codes.
const phoneCodes = Location.getPhoneCodes()
Returns: An array of objects, each containing the following properties:
iso2
: The ISO2 code of the country.code
: The phone code of the country.flagImage
: The URL of the country's flag image.
Contributing
Contributions are welcome! Please read our contributing guidelines to get started.
License
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
Made with ♥️ by kur0.