A library providing a list of Algerian administrative areas with many useful APIs.
npm install @dzcode-io/leblad --save
Returns a list of Algerian provinces (Wilayas)
Arguments
projection: string[]
(optional) Array of Wilaya Object attributes to keep.
Examples
const { getWilayaList, getWilayaByZipCode } = require('@dzcode-io/leblad');
const allWilayasDetails = getWilayaList();
// if we only want the wilaya names for example:
const wilayasNames = getWilayaList(['name', 'name_ar', 'name_en']);
Returns a wilaya that includes the given zipCode.
Arguments
zipCode: number
(required) A zip codeprojection: string[]
(optional) Array of Wilaya Object attributes to keep
Examples
const { getWilayaByZipCode } = require('@dzcode-io/leblad');
// To get the wilaya that includes the zip code 1000, We can use getWilayaByZipCode
// This example will return Adrar { name: "Adrar", ...}
const wilaya = getWilayaByZipCode(1000);
// We can also select only attributes that we want, For example select name and mattricule:
const wilayaAttributes = getWilayaByZipCode(1000, ['name', 'mattricule']);
Takes a wilaya code (matricule) and returns the matching wilaya
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"projection: string[]
(optional) Array of Wilaya Object attributes
Examples
const { getWilayaByCode } = require('@dzcode-io/leblad');
console.log(getWilayaByCode(31)); // will the wilaya object ({name: "Oran"...})
Takes a wilaya code (matricule) and returns a list of adjacent wilayas codes
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"
Examples
const { getAdjacentWilayas } = require('@dzcode-io/leblad');
console.log(getAdjacentWilayas(31)); // will print [46, 22, 29, 27]
Takes a wilaya code (matricule) and returns a list of Respective Zip-Codes for that wilaya
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"
Examples
const { getZipCodesForWilaya } = require('@dzcode-io/leblad');
console.log(getZipCodesForWilaya(31)); //returns list of zip codes for wilaya 31
Takes a wilaya code (matricule) ans returns list of all dairats of that wilaya.
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"projection: string[]
(optional) Array of Wilaya Object attributes to keep
Examples
const { getDairatsForWilaya } = require('@dzcode-io/leblad');
console.log(getDairatsForWilaya(3)); //returns list of dairats for wilaya 3
Takes a phone code and returns the matching wilaya.
Arguments
phoneCode: number|string
(required) the Wilaya's "phoneCode" or the full phone numberprojection: string[]
(optional) Array of Wilaya Object attributes to keep
Examples
const { getWilayaByPhoneCode } = require('@dzcode-io/leblad');
console.log(getWilayaByPhoneCode(34)); //will the wilaya object ({name: "Béjaïa"...})
Takes a wilaya code (matricule) and returns a list of phone codes for given wilaya
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"
Examples
const { getPhoneCodesForWilaya } = require('@dzcode-io/leblad');
console.log(getPhoneCodesForWilaya(31)); //returns list of phone codes for wilaya 31
Takes a wilaya code (matricule) and returns the first phone code from a list of phone codes for given wilaya
Arguments
wilayaCode: number
(required) the Wilaya's "matricule"
Examples
const { getPhoneCodeForWilaya } = require('@dzcode-io/leblad');
console.log(getPhoneCodeForWilaya(16)); //returns first phone code for wilaya 16
Takes a Daira name (French, English or Arabic) and returns either the corresponding wilaya or null.
Arguments
dairaName: string
(required) the Daira name
Examples
const { getWilayaByDairaName } = require('@dzcode-io/leblad');
console.log(getWilayaByDairaName('Charouine')); //returns wilaya object
Return an object or an array of object with only wilaya attribute you select in the projection
attributes array.
Arguments
wilaya: (object|array)
(required) A wilaya object or an array of wilaya objectsprojection: string[]
(optional) Array of Wilaya Object attributes
Examples
const { projectWilaya } = require('@dzcode-io/leblad').utils;
...
const wilayasNames = projectWilaya(someWilayaObject, ['name', 'name_ar', 'name_en']);
Check if a given wilaya code (matricule) is valid (i.e is an integer between 1 and 48).
Arguments
code: number
(required) Wilaya code
Check if a given zip code is valid (i.e is an integer between 1000 and 48073).
Arguments
code: (number|string)
(required) zip code
Make sure you have:
npm install
npm run update-dataset
Simply run
npm test
Or this command for the watch mode
:
npm run test.watch
You can also run mutation tests (using Stryker-mutator)
npm run test.mutation
Thanks goes to these wonderful people (emoji key):
Zakaria Mansouri 🔧 👀 |
Oussama Bouchikhi 💻 |
Nasser Abachi 💻 |
Anurag sati 💻 |
HamdiAmine 💻 |
xxKeefer 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
When contributing to this repository, please first discuss the change you wish to make by opening an issue, sending an e-mail, or any other method with us before making a change.
And also, please make sure to read our guidelines for contributing.
- dz-communes An NPM package exposing a list of all of the 48 wilayas of Algeria and their communes.
- algeria-api An web API exposing Wilayas data. We data from that project as a source of truth for (data/WilayaList.json)
This project is licensed under the MIT License - see the LICENSE file for details