region-info-package

1.0.2 • Public • Published

Region-Info

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.

Table of Contents

Installation

To install this package, use npm:

npm install region-info-package

Usage

Importing the Module

const { getStatesByCountryId } = require('region-info-package');

Functions

getStatesByCountryId(countryId)

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);

getCitiesByStateId(stateId)

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);

getCountryById(countryId)

Gets the details of a country using its ID.

const country = getCountryById(1);
console.log(country);

getStateById(stateId)

Gets the details of a state using its ID.

const state = getStateById(1);
console.log(state);

getCityById(cityId)

Gets the details of a city using its ID.

const city = getCityById(1);
console.log(city);

getAllCountries()

Returns a list of all countries.

const allCountries = getAllCountries();
console.log(allCountries);

getAllStates()

Returns a list of all states.

const allStates = getAllStates();
console.log(allStates);

getAllCities()

Returns a list of all cities.

const allCities = getAllCities();
console.log(allCities);

getCountryNameByStateId(stateId)

Finds the country name for a specific state.

const countryName = getCountryNameByStateId(1);
console.log(countryName);

getStateNameByCityId(cityId)

Finds the state name for a specific city.

const stateName = getStateNameByCityId(1);
console.log(stateName);

getFullLocationByCityId(cityId)

Gets the full location (city, state, and country) for a specific city.

const fullLocation = getFullLocationByCityId(1);
console.log(fullLocation);

searchStatesByName(partialName)

Searches for states by name (case-insensitive).

const matchingStates = searchStatesByName('New');
console.log(matchingStates);

searchCitiesByName(partialName)

Searches for cities by name (case-insensitive).

const matchingCities = searchCitiesByName('York');
console.log(matchingCities);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i region-info-package

      Weekly Downloads

      4

      Version

      1.0.2

      License

      ISC

      Unpacked Size

      43.6 MB

      Total Files

      7

      Last publish

      Collaborators

      • mohanapriya0105