Moroccan Regions and Cities
A Node.js package to handle Moroccan regions and cities.
Installation
Install the package via npm:
npm install moroccan-regions-cities
Key Functions
Here are the key functions provided by this package, along with descriptions, parameters, and usage examples.
getAllRegions:
Returns a list of all Moroccan regions in specified language.
-
Parameters:
- "language" parameter of type string, provided options are ('arabic','french','english') and the default value is 'english'
-
Example:
const { getAllRegions } = require('moroccan-regions-cities');
const regions = getAllRegions('french');
console.log(regions); Output: [{
regionId: 'ba12f287-a8ea-4b11-9445-122c5f2e6a6c',
regionName: 'Guelmim-Oued Noun'
},
{
regionId: '51e3d7bb-fc82-4201-a852-bee031abe895',
regionName: 'Laâyoune-Sakia El Hamra'
},...]
---------------------------------------------------------
countMoroccanRegions:
Returns the total number of regions in Morocco.
---------------------------------------------------------
getAssignedMorrocanCities:
Returns a list of cities that are assigned to regions.
-
Parameters:
- "language" parameter of type string, provided options are ('arabic','french','english') and the default value is 'english'
-
Example:
const { getAssignedMorrocanCities } = require('moroccan-regions-cities');
const assignedCities = getAssignedMorrocanCities('arabic');
console.log(assignedCities); Output: ['طنجة','أصيلا','القصر الكبير',...]
---------------------------------------------------------
getUnassignedCities:
Returns a list of cities that are Unassigned to regions.
---------------------------------------------------------
getRegionCities:
Returns a list of cities within a specific region in the specified language.
---------------------------------------------------------
countAllMoroccanCities:
Returns the total number of cities in Morocco.
---------------------------------------------------------
countAssignedCities:
Returns the total count of cities that are assigned to regions.
---------------------------------------------------------
countRegionCities:
Returns the total count of cities that are assigned to regions.
---------------------------------------------------------
countUnassignedCities:
Returns the total count of cities that are assigned to regions.
Note :
Functions are available for both CommonJS (require) and ES Modules (import):
So you can do both of :
const {functionName} = require('moroccan-regions-cities');
import {functionName} from 'moroccan-regions-cities';
import allFunction from 'moroccan-regions-cities';
then call the function like this : allFunction.functionName(?params)
Contributing
We welcome contributions to improve and expand this package! Here are some ideas for potential features and improvements:
1. Additional Language Support:
-
Currently, the package supports English, French, and Arabic. Adding support for additional languages or enabling dynamic language loading could be valuable.
2. Caching Frequently Accessed Data:
-
Adding caching for frequently accessed functions (for example, getAllRegions, countMoroccanRegions) to improve performance.
3. Adding States For Each City:
-
Adding states or provinces within each city.
How to Contribute
-
1. Fork the Repository: Start by forking the repository to your own GitHub account.
-
2. Clone the Forked Repository:
git https://github.com/Ezzagmoute-Hamza/moroccan-regions-cities.git
-
3. Create a New Branch: Make a new branch for your feature or bug fix
```bash
git checkout -b feature/add-new-feature-name
```
-
4. Make Your Changes: Implement your changes in the appropriate files.
-
5. Ensure your feature is well-tested.
-
6. Commit and Push:
git add .
git commit -m "Add new feature: description"
git push origin feature/add-new-feature-name