country-data-filter 1.0.14 → 1.0.15
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/README.md +105 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Country Data Filter
|
|
2
|
+
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.
|
|
3
|
+
|
|
4
|
+
Installation
|
|
5
|
+
You can install the package via npm:
|
|
6
|
+
|
|
7
|
+
bash
|
|
8
|
+
Copy code
|
|
9
|
+
npm install country-data-filter
|
|
10
|
+
Usage
|
|
11
|
+
Importing the Package
|
|
12
|
+
In your JavaScript or TypeScript project, you can import the functions provided by the package.
|
|
13
|
+
|
|
14
|
+
JavaScript
|
|
15
|
+
javascript
|
|
16
|
+
Copy code
|
|
17
|
+
const {
|
|
18
|
+
getProvincesDistrictsCitiesByCountryFunction,
|
|
19
|
+
getCountryProvinceCityByDistrict,
|
|
20
|
+
getCountryDistrictsCitiesByProvince,
|
|
21
|
+
listFunctions
|
|
22
|
+
} = require('country-data-filter');
|
|
23
|
+
TypeScript
|
|
24
|
+
typescript
|
|
25
|
+
Copy code
|
|
26
|
+
import {
|
|
27
|
+
getProvincesDistrictsCitiesByCountryFunction,
|
|
28
|
+
getCountryProvinceCityByDistrict,
|
|
29
|
+
getCountryDistrictsCitiesByProvince,
|
|
30
|
+
listFunctions
|
|
31
|
+
} from 'country-data-filter';
|
|
32
|
+
Functions
|
|
33
|
+
getProvincesDistrictsCitiesByCountryFunction(code)
|
|
34
|
+
Returns a list of provinces, districts, and cities for a given country code.
|
|
35
|
+
|
|
36
|
+
Parameters:
|
|
37
|
+
|
|
38
|
+
code (string): The country code (e.g., 'LK' for Sri Lanka).
|
|
39
|
+
Returns:
|
|
40
|
+
|
|
41
|
+
An object containing sorted arrays of provinces, districts, and cities, or an error message if the country code is invalid.
|
|
42
|
+
Example:
|
|
43
|
+
|
|
44
|
+
javascript
|
|
45
|
+
Copy code
|
|
46
|
+
const result = getProvincesDistrictsCitiesByCountryFunction('LK');
|
|
47
|
+
console.log(result);
|
|
48
|
+
getCountryProvinceCityByDistrict(districtName)
|
|
49
|
+
Returns the country code, province, and cities for a given district name.
|
|
50
|
+
|
|
51
|
+
Parameters:
|
|
52
|
+
|
|
53
|
+
districtName (string): The name of the district.
|
|
54
|
+
Returns:
|
|
55
|
+
|
|
56
|
+
An object containing the country code, province name, and list of cities, or an error message if the district name is invalid.
|
|
57
|
+
Example:
|
|
58
|
+
|
|
59
|
+
javascript
|
|
60
|
+
Copy code
|
|
61
|
+
const result = getCountryProvinceCityByDistrict('Matara');
|
|
62
|
+
console.log(result);
|
|
63
|
+
getCountryDistrictsCitiesByProvince(provinceName)
|
|
64
|
+
Returns the list of districts and cities for a given province name.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
|
|
68
|
+
provinceName (string): The name of the province.
|
|
69
|
+
Returns:
|
|
70
|
+
|
|
71
|
+
An object containing the list of districts and cities, or an error message if the province name is invalid.
|
|
72
|
+
Example:
|
|
73
|
+
|
|
74
|
+
javascript
|
|
75
|
+
Copy code
|
|
76
|
+
const result = getCountryDistrictsCitiesByProvince('Southern');
|
|
77
|
+
console.log(result);
|
|
78
|
+
listFunctions()
|
|
79
|
+
Returns a list of all available functions in the package.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
|
|
83
|
+
An object containing the function names and their references.
|
|
84
|
+
Example:
|
|
85
|
+
|
|
86
|
+
javascript
|
|
87
|
+
Copy code
|
|
88
|
+
const functions = listFunctions();
|
|
89
|
+
console.log(functions);
|
|
90
|
+
Data Structure
|
|
91
|
+
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.
|
|
92
|
+
|
|
93
|
+
Contributing
|
|
94
|
+
If you want to contribute to this project, please follow these steps:
|
|
95
|
+
|
|
96
|
+
Fork the repository.
|
|
97
|
+
Create a new branch for your changes.
|
|
98
|
+
Make your changes and add tests if applicable.
|
|
99
|
+
Submit a pull request with a clear description of your changes.
|
|
100
|
+
License
|
|
101
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
102
|
+
|
|
103
|
+
Contact
|
|
104
|
+
For any questions or support, please contact knnadeera1@gmail.com.
|
|
105
|
+
|