dz-wilayas-core
v1.0.3
Published
A TypeScript library providing Algeria's wilayas and baladiyat data, with utility classes for easy lookup, search, and integration in any JavaScript or TypeScript project.
Maintainers
Readme
dz-wilayas-core 🇩🇿
A TypeScript library providing Algeria's wilayat and baladiyat data with utility classes for easy lookup, search, and integration in any JavaScript or TypeScript project.
📑 Table of Contents
⚡ Installation
npm install dz-wilayas-core
# or
yarn add dz-wilayas-core🚀 Usage
import { WilayasStore, Wilaya, Baladiya } from "dz-wilayas-core";
const store = new WilayasStore();
// Get all wilayas
const allWilayas: Wilaya[] = store.getAllWilayas();
// Get a wilaya by code
const algerWilaya = store.getWilayaByCode("16");
// Search wilayas by name
const searchResults = store.searchWilayaByName("Oran");
// Get all baladiyat for a wilaya
const algerBaladiyat: Baladiya[] = store.getBaladiyatByWilayaCode("16");
console.log(algerWilaya, algerBaladiyat);🔌 API
class WilayasStore
| Method | Description |
| ---------------------------------------------------- | ------------------------------------------ |
| getAllWilayas(): Wilaya[] | Returns all wilayas. |
| getWilayaByCode(code: string): Wilaya \| undefined | Find a wilaya by its code. |
| searchWilayaByName(name: string): Wilaya[] | Search wilayas by name (case-insensitive). |
| getBaladiyatByWilayaCode(code: string): Baladiya[] | Get all baladiyat for a given wilaya code. |
📊 Data
- Wilaya object example:
interface Wilaya {
id: string;
code: string;
name: string;
ar_name: string;
}- Baladiya object example:
interface Baladiya {
id: string;
wilaya_id: string;
name: string;
ar_name: string;
}All data is preloaded from JSON and typed for TypeScript.
🟦 TypeScript Support
- Fully typed out-of-the-box.
- Provides
WilayaandBaladiyatypes. - Includes
.d.tsfiles for complete IDE autocompletion.
🤝 Contributing
- Fork the repo
- Create your branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
- After your PR is merged, uncomment the Contributors block below and add yourself by replacing
<YourUsername>with your GitHub username.
👤 Author
🙏 Credits
- Data source: Wilaya-Of-Algeria by AbderrahmeneDZ and yamanidev
📄 License
This project is licensed under the MIT License. See LICENSE for details.
