JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q62420F
  • License ISC

A package to filter country data

Package Exports

  • country-data-filter
  • country-data-filter/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (country-data-filter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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 knnadeera1@gmail.com.