moroccan-regions-cities
v1.0.8
Published
A Node.js package to handle Moroccan regions and cities.
Downloads
504
Maintainers
Readme
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.
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'
},...]
const { countMoroccanRegions } = require('moroccan-regions-cities');
const regionCount = countMoroccanRegions();
console.log(regionCount); Output: 12
--------------------------------------------------------- getAssignedMorrocanCities: Returns a list of cities that are assigned to regions.
const { getAssignedMorrocanCities } = require('moroccan-regions-cities');
const assignedCities = getAssignedMorrocanCities('arabic');
console.log(assignedCities); Output: ['طنجة','أصيلا','القصر الكبير',...]
const { getUnassignedCities } = require('moroccan-regions-cities');
const unassignedCities = getUnassignedCities('french');</br>
console.log(unassignedCities); Output: ['Rich','Arbaoua','Sebta'...]
--------------------------------------------------------- getRegionCities: Returns a list of cities within a specific region in the specified language.
const { getRegionCities } = require('moroccan-regions-cities');
const regionCities = getRegionCities();
console.log(regionCities); Output: ['Tanger','Tetouan','Alhoceima'...]
--------------------------------------------------------- countAllMoroccanCities: Returns the total number of cities in Morocco.
const { countAllMoroccanCities } = require('moroccan-regions-cities');
const countMorrocanCities = countAllMoroccanCities();
console.log(countMorrocanCities); Output: 114
--------------------------------------------------------- countAssignedCities: Returns the total count of cities that are assigned to regions.
const { countAssignedCities } = require('moroccan-regions-cities');
const countMorrocanAssignedCities = countAssignedCities();
console.log(countMorrocanAssignedCities); Output: 92
--------------------------------------------------------- countRegionCities: Returns the total count of cities that are assigned to regions.
const { countRegionCities } = require('moroccan-regions-cities');
const countregionCities = countRegionCities();
console.log(countregionCities); Output: 9
Note: the Output is the number of cities of the first region of 'getAllRegions' list.
--------------------------------------------------------- countUnassignedCities: Returns the total count of cities that are assigned to regions.
const { countUnassignedCities } = require('moroccan-regions-cities');
const countUnassignedcities = countUnassignedCities();
console.log(countUnassignedcities); Output: 22
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:
2. Caching Frequently Accessed Data:
3. Adding States For Each City:
How to Contribute
git https://github.com/Ezzagmoute-Hamza/moroccan-regions-cities.git
```bash
git checkout -b feature/add-new-feature-name
```
git add .
git commit -m "Add new feature: description"
git push origin feature/add-new-feature-name