npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

country-data-filter

v1.0.18

Published

A package to filter country data

Downloads

92

Readme

Country Data Filter country-data-filter is an npm package designed to provide detailed country data, including provinces, districts, cities, and postal codes. This package is useful for applications that need to access and filter geographical information.

Installation You can install the package via npm:

bash Copy code npm install country-data-filter Usage Importing the Package In your JavaScript or TypeScript project, you can import the functions provided by the package.

JavaScript javascript Copy code

const {
  getDataByCountry,
  getDataByProvince,
  getDataByDistrict,
  getDataByCity,
  getDataByCountryProvince,
  getDataByCountryProvinceDistrict,
  getDataByCountryProvinceDistrictCity,
  getDataByEtherCountryProvinceDistrictCity,
  getDataByCountryDistrict,
  getDataByCountryCity,
  getDataByProvinceDistrict,
  getDataByProvinceCity,
  getDataByDistrictCity,
  getCurrencyByCountry,
  getDataByPostalCode,
  listFunctions,
} = require("country-data-filter");

TypeScript typescript Copy code

import {
  getDataByCountry,
  getDataByProvince,
  getDataByDistrict,
  getDataByCity,
  getDataByCountryProvince,
  getDataByCountryProvinceDistrict,
  getDataByCountryProvinceDistrictCity,
  getDataByEtherCountryProvinceDistrictCity,
  getDataByCountryDistrict,
  getDataByCountryCity,
  getDataByProvinceDistrict,
  getDataByProvinceCity,
  getDataByDistrictCity,
  getCurrencyByCountry,
  getDataByPostalCode,
  listFunctions,
} from "country-data-filter";

javascript Copy code

const result = getDataByCountry(countryCode);
console.log(result);

Returns a list of provinces, districts, and cities for a given country code.

Parameters: code (string): The country code (e.g., 'LK' for Sri Lanka).

Returns: An object containing sorted arrays of provinces, districts, and cities, or an error message if the country code is invalid.

javascript Copy code

const result = getDataByDistrict(districtName);
console.log(result);

Returns the country code, province, and cities for a given district name.

Parameters: districtName (string): The name of the district.

Returns: An object containing the country code, province name, and list of cities, or an error message if the district name is invalid.

javascript Copy code

const result = getDataByProvince(provinceName);
console.log(result);

Returns the list of districts and cities for a given province name.

Parameters: provinceName (string): The name of the province.

Returns: An object containing the list of districts and cities, or an error message if the province name is invalid.

javascript Copy code

const result = listFunctions();
console.log(result);

Returns a list of all available functions in the package.

Returns: An object containing the filtered data list.

javascript Copy code

const result = getDataByEtherCountryProvinceDistrictCity();
console.log(result);

Parameters: countryCode (string)?: The code of the country. provinceName (string)?: The name of the province. districtName (string)?: The name of the district. cityName (string)?: The name of the city.

Data Structure The data for countries, provinces, districts, and cities is stored in JavaScript objects. Each country object contains provinces, and each province object contains districts and cities.

list of functions

javascript Copy code

getDataByCountry(countryCode); // countryCode: string
getDataByProvince(provinceName); // provinceName: string
getDataByDistrict(districtName); // districtName: string
getDataByCity(cityName); // cityName: string
getDataByCountryProvince(countryCode, provinceName); // countryCode: string, provinceName: string
getDataByCountryProvinceDistrict(countryCode, provinceName, districtName); // countryCode: string, provinceName: string, districtName: string
getDataByCountryProvinceDistrictCity(
  countryCode,
  provinceName,
  districtName,
  cityName
); // countryCode: string, provinceName: string, districtName: string, cityName: string
getDataByEtherCountryProvinceDistrictCity(
  countryCode,
  provinceName,
  districtName,
  cityName
); // countryCode: string, provinceName: string, districtName: string, cityName: string
getDataByCountryDistrict(countryCode, districtName); // countryCode: string, districtName: string
getDataByCountryCity(countryCode, cityName); // countryCode: string, cityName: string
getDataByProvinceDistrict(provinceName, districtName); // provinceName: string districtName: string
getDataByProvinceCity(provinceName, cityName); // provinceName: string, cityName: string
getDataByDistrictCity(districtName, cityName); // districtName: string, cityName: string
getCurrencyByCountry(countryCode); // countryCode: string
getDataByPostalCode(postalCode); // postalCode: string

Contributing If you want to contribute to this project, please follow these steps:

Fork the repository. Create a new branch for your changes. Make your changes and add tests if applicable. Submit a pull request with a clear description of your changes. License This project is licensed under the MIT License. See the LICENSE file for details.

Contact For any questions or support, please contact [email protected].