region-info-package
provides a comprehensive set of functions to manage and retrieve information about countries, region-info-package management for both frontend and backend applications states, and cities. This package is designed to simplify the handling of geographical data and enhance your application's location-based features.
To install this package, use npm:
npm install region-info-package
Importing the Module
const { getStatesByCountryId } = require('region-info-package');
Finds all states in a specific country. Pass in the country ID, and it returns a list of states.
const states = getStatesByCountryId(1);
console.log(states);
Finds all cities in a specific state. Pass in the state ID, and it returns a list of cities.
const cities = getCitiesByStateId(1);
console.log(cities);
Gets the details of a country using its ID.
const country = getCountryById(1);
console.log(country);
Gets the details of a state using its ID.
const state = getStateById(1);
console.log(state);
Gets the details of a city using its ID.
const city = getCityById(1);
console.log(city);
Returns a list of all countries.
const allCountries = getAllCountries();
console.log(allCountries);
Returns a list of all states.
const allStates = getAllStates();
console.log(allStates);
Returns a list of all cities.
const allCities = getAllCities();
console.log(allCities);
Finds the country name for a specific state.
const countryName = getCountryNameByStateId(1);
console.log(countryName);
Finds the state name for a specific city.
const stateName = getStateNameByCityId(1);
console.log(stateName);
Gets the full location (city, state, and country) for a specific city.
const fullLocation = getFullLocationByCityId(1);
console.log(fullLocation);
Searches for states by name (case-insensitive).
const matchingStates = searchStatesByName('New');
console.log(matchingStates);
Searches for cities by name (case-insensitive).
const matchingCities = searchCitiesByName('York');
console.log(matchingCities);