@brmorillo/global-locations
v4.0.3
Published
Public API for global locations
Downloads
192
Maintainers
Readme
@brmorillo/global-locations
Library for accessing global location data such as countries, states, and cities.
Installation
npm install @brmorillo/global-locationsUsage
import { GlobalLocations } from '@brmorillo/global-locations';
// Get all countries
const countries = GlobalLocations.Countries.getAllCountries();
// Get a specific country by ID
const brazil = GlobalLocations.Countries.getCountryBy({
property: 'id',
value: 'BR',
selectStates: true
});
// Get states of a country
const brazilStates = GlobalLocations.Countries.getStatesByCountryId('BR');
// Get cities of a state
const saoPauloCities = GlobalLocations.Countries.getCitiesByStateId({
countryId: 'BR',
stateId: '35'
});API
Countries
getAllCountriesAndData(): Returns all countries with complete datagetAllCountries(): Returns all countries without state datagetCountryBy({ property, value, selectStates }): Returns a specific countrygetAllStates(): Returns all states from all countriesgetStatesByCountryId(countryId): Returns states of a specific countrygetStateByParams({ countryId, params }): Searches for a specific stateisStateInCountry({ countryId, stateId }): Checks if a state belongs to a countrygetAllCities({ countryId }): Returns all cities of a countrygetCitiesByStateId({ countryId, stateId }): Returns cities of a specific stategetCitiesByParams({ countryId, stateId, params }): Searches for a specific city
License
MIT
