country-data-filter 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "country-data-filter",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "A package to filter country data",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -25,7 +25,9 @@
25
25
  "author": "K N Nadeera",
26
26
  "license": "ISC",
27
27
  "files": [
28
+ "src/*.js",
28
29
  "src/index.js",
30
+ "src/index.d.ts",
29
31
  "src/countries/*.js"
30
32
  ]
31
33
  }
@@ -0,0 +1,5 @@
1
+ import { LK } from "./countries/LK";
2
+
3
+ export const countryData = {
4
+ LK: LK,
5
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export function getProvincesByCountry(code: string): string[];
2
+ export function getDistrictsByProvince(
3
+ countryCode: string,
4
+ provinceName: string
5
+ ): string[];
6
+ export function getCityByDistrict(
7
+ countryCode: string,
8
+ provinceName: string,
9
+ districtName: string
10
+ ): any;
11
+ export function listFunctions(): {
12
+ getProvincesByCountry: (code: string) => string[];
13
+ getDistrictsByProvince: (
14
+ countryCode: string,
15
+ provinceName: string
16
+ ) => string[];
17
+ getCityByDistrict: (
18
+ countryCode: string,
19
+ provinceName: string,
20
+ districtName: string
21
+ ) => any;
22
+ };
package/src/index.js CHANGED
@@ -13,7 +13,7 @@ export function getProvincesByCountry(code) {
13
13
  // Function to get a list of district names by country code and province name
14
14
  export function getDistrictsByProvince(countryCode, provinceName) {
15
15
  const country = countryData[countryCode];
16
- if (country && country.province[provinceName]) {
16
+ if (country && country.province[provinceName.toLowerCase()]) {
17
17
  // Return an array of district names
18
18
  return Object.values(country.province[provinceName].districts).map(
19
19
  (district) => district.name
@@ -25,8 +25,8 @@ export function getDistrictsByProvince(countryCode, provinceName) {
25
25
  // Function to get city details by country code, province name, and district name
26
26
  export function getCityByDistrict(countryCode, provinceName, districtName) {
27
27
  const country = countryData[countryCode];
28
- const province = country.province[provinceName];
29
- if (province && province.districts[districtName]) {
28
+ const province = country.province[provinceName.toLowerCase()];
29
+ if (province && province.districts[districtName.toLowerCase()]) {
30
30
  return province.districts[districtName];
31
31
  }
32
32
  return null;