Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moroccan-regions-cities

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moroccan-regions-cities

A Node.js package to handle Moroccan regions and cities.

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
Maintainers
0
Weekly downloads
 
Created
Source

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.
  • Parameters: None
  • Example:
     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.

  • 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.
  • Parameters:
    • "language" parameter of type string, provided options are ('arabic','french','english') and the default value is 'english'
  • Example:
     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.

  • Parameters:
    • "regionId" parameter of type string, form of uuid, you can get it from the returned list of 'getAllRegions' function.
      it's default value is the first regionId
    • "language" parameter of type string, provided options are ('arabic','french','english') and the default value is 'english'
  • Example:
     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.

  • Parameters: None
  • Example:
     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.

  • Parameters: None
  • Example:
     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.

  • Parameters:
    • "regionId" parameter of type string, form of uuid, you can get it from the returned list of 'getAllRegions' function.
      it's default value is the first regionId of 'getAllRegions' returned list
  • Example:
     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.

  • Parameters: None
  • Example:
     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:

  • 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
     
    

Keywords

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc