dz-wilayas-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ThaBugMaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # dz-wilayas-core
2
+
3
+ ![npm](https://img.shields.io/npm/v/dz-wilayas-core?color=blue) ![license](https://img.shields.io/npm/l/dz-wilayas-core) ![downloads](https://img.shields.io/npm/dt/dz-wilayas-core)
4
+
5
+ **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.**
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Usage](#usage)
13
+ - [API](#api)
14
+ - [Data](#data)
15
+ - [TypeScript Support](#typescript-support)
16
+ - [Contributing](#contributing)
17
+ - [License](#license)
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install dz-wilayas-core
25
+ # or
26
+ yarn add dz-wilayas-core
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Usage
32
+
33
+ ```ts
34
+ import { WilayasStore, Wilaya, Baladiya } from "dz-wilayas-core";
35
+
36
+ const store = new WilayasStore();
37
+
38
+ // Get all wilayas
39
+ const allWilayas: Wilaya[] = store.getAllWilayas();
40
+
41
+ // Get a wilaya by code
42
+ const algerWilaya = store.getWilayaByCode("16");
43
+
44
+ // Search wilayas by name
45
+ const searchResults = store.searchWilayaByName("Oran");
46
+
47
+ // Get all baladiyat for a wilaya
48
+ const algerBaladiyat: Baladiya[] = store.getBaladiyatByWilayaCode("16");
49
+
50
+ console.log(algerWilaya, algerBaladiyat);
51
+ ```
52
+
53
+ ---
54
+
55
+ ## API
56
+
57
+ ### `class WilayasStore`
58
+
59
+ | Method | Description |
60
+ | ---------------------------------------------------- | ------------------------------------------ |
61
+ | `getAllWilayas(): Wilaya[]` | Returns all wilayas. |
62
+ | `getWilayaByCode(code: string): Wilaya \| undefined` | Find a wilaya by its code. |
63
+ | `searchWilayaByName(name: string): Wilaya[]` | Search wilayas by name (case-insensitive). |
64
+ | `getBaladiyatByWilayaCode(code: string): Baladiya[]` | Get all baladiyat for a given wilaya code. |
65
+
66
+ ---
67
+
68
+ ## Data
69
+
70
+ - **Wilaya** object example:
71
+
72
+ ```ts
73
+ interface Wilaya {
74
+ id: string;
75
+ code: string;
76
+ name: string;
77
+ ar_name: string;
78
+ }
79
+ ```
80
+
81
+ - **Baladiya** object example:
82
+
83
+ ```ts
84
+ interface Baladiya {
85
+ id: string;
86
+ wilaya_id: string;
87
+ name: string;
88
+ ar_name: string;
89
+ }
90
+ ```
91
+
92
+ All data is **preloaded from JSON** and typed for TypeScript.
93
+
94
+ ---
95
+
96
+ ## TypeScript Support
97
+
98
+ - Fully **typed** out-of-the-box.
99
+ - Provides `Wilaya` and `Baladiya` types.
100
+ - Includes `.d.ts` files for complete IDE autocompletion.
101
+
102
+ ---
103
+
104
+ ## Contributing
105
+
106
+ 1. Fork the repo
107
+ 2. Create your branch (`git checkout -b feature/my-feature`)
108
+ 3. Commit your changes (`git commit -am 'Add my feature'`)
109
+ 4. Push to the branch (`git push origin feature/my-feature`)
110
+ 5. Open a Pull Request
111
+
112
+ ---
113
+
114
+ ## License
115
+
116
+ This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>dz-wilayas-core Demo</title>
8
+ <style>
9
+ body {
10
+ background-color: rgb(0, 0, 47);
11
+ color: aliceblue;
12
+ }
13
+ </style>
14
+ </head>
15
+
16
+ <body>
17
+ <h1>🇩🇿 dz-wilayas-core Demo (check console) 🇩🇿</h1>
18
+ <script type="module" src="./main.ts"></script>
19
+ </body>
20
+
21
+ </html>