egydata 1.0.0 → 1.0.1
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/README.md +33 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,10 +19,10 @@ npm install egydata
|
|
|
19
19
|
|
|
20
20
|
```javascript
|
|
21
21
|
// CommonJS
|
|
22
|
-
const { governorates, cities, phoneArea, timezone } = require(
|
|
22
|
+
const { governorates, cities, phoneArea, timezone } = require("egydata");
|
|
23
23
|
|
|
24
24
|
// ESM
|
|
25
|
-
import { governorates, cities, phoneArea, timezone } from
|
|
25
|
+
import { governorates, cities, phoneArea, timezone } from "egydata";
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
@@ -30,14 +30,14 @@ import { governorates, cities, phoneArea, timezone } from 'egydata';
|
|
|
30
30
|
### Governorates
|
|
31
31
|
|
|
32
32
|
```javascript
|
|
33
|
-
const { governorates } = require(
|
|
33
|
+
const { governorates } = require("egydata");
|
|
34
34
|
|
|
35
35
|
// Get all 27 governorates
|
|
36
36
|
const all = governorates.getAll();
|
|
37
37
|
// [{ id: 1, code: 'CAI', name: 'القاهرة', nameEn: 'Cairo' }, ...]
|
|
38
38
|
|
|
39
39
|
// Find by code
|
|
40
|
-
const cairo = governorates.getByCode(
|
|
40
|
+
const cairo = governorates.getByCode("CAI");
|
|
41
41
|
// { id: 1, code: 'CAI', name: 'القاهرة', nameEn: 'Cairo' }
|
|
42
42
|
|
|
43
43
|
// Find by id
|
|
@@ -45,20 +45,20 @@ const gov = governorates.getById(2);
|
|
|
45
45
|
// { id: 2, code: 'ALX', name: 'الإسكندرية', nameEn: 'Alexandria' }
|
|
46
46
|
|
|
47
47
|
// Search (Arabic or English, partial match)
|
|
48
|
-
const results = governorates.search(
|
|
48
|
+
const results = governorates.search("alex");
|
|
49
49
|
// [{ id: 2, code: 'ALX', name: 'الإسكندرية', nameEn: 'Alexandria' }]
|
|
50
50
|
|
|
51
|
-
const arResults = governorates.search(
|
|
51
|
+
const arResults = governorates.search("القاهرة");
|
|
52
52
|
// [{ id: 1, code: 'CAI', name: 'القاهرة', nameEn: 'Cairo' }]
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
### Cities
|
|
56
56
|
|
|
57
57
|
```javascript
|
|
58
|
-
const { cities } = require(
|
|
58
|
+
const { cities } = require("egydata");
|
|
59
59
|
|
|
60
60
|
// Get cities by governorate code
|
|
61
|
-
const cairoCities = cities.getByGovernorate(
|
|
61
|
+
const cairoCities = cities.getByGovernorate("CAI");
|
|
62
62
|
// [{ id: 1, name: 'مدينة نصر', nameEn: 'Nasr City', governorateCode: 'CAI' }, ...]
|
|
63
63
|
|
|
64
64
|
// Find by id
|
|
@@ -66,37 +66,37 @@ const city = cities.getById(131);
|
|
|
66
66
|
// { id: 131, name: 'شرم الشيخ', nameEn: 'Sharm El Sheikh', governorateCode: 'SIS' }
|
|
67
67
|
|
|
68
68
|
// Search cities (Arabic or English, partial match)
|
|
69
|
-
const found = cities.search(
|
|
69
|
+
const found = cities.search("Maadi");
|
|
70
70
|
// [{ id: 3, name: 'المعادي', nameEn: 'Maadi', governorateCode: 'CAI' }]
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### Phone Area Codes
|
|
74
74
|
|
|
75
75
|
```javascript
|
|
76
|
-
const { phoneArea } = require(
|
|
76
|
+
const { phoneArea } = require("egydata");
|
|
77
77
|
|
|
78
78
|
// Get all area codes (landline and mobile)
|
|
79
79
|
const all = phoneArea.getAll();
|
|
80
80
|
// [{ code: '02', region: 'القاهرة والجيزة', regionEn: 'Cairo & Giza' }, ...]
|
|
81
81
|
|
|
82
82
|
// Look up a region by code
|
|
83
|
-
const region = phoneArea.getRegion(
|
|
83
|
+
const region = phoneArea.getRegion("03");
|
|
84
84
|
// { code: '03', region: 'الإسكندرية', regionEn: 'Alexandria' }
|
|
85
85
|
|
|
86
86
|
// Find area code by region name
|
|
87
|
-
const entry = phoneArea.getCode(
|
|
87
|
+
const entry = phoneArea.getCode("Mansoura");
|
|
88
88
|
// { code: '050', region: 'الدقهلية (المنصورة)', regionEn: 'Dakahlia (Mansoura)' }
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
### Timezone
|
|
92
92
|
|
|
93
93
|
```javascript
|
|
94
|
-
const { timezone } = require(
|
|
94
|
+
const { timezone } = require("egydata");
|
|
95
95
|
|
|
96
|
-
console.log(timezone.name);
|
|
97
|
-
console.log(timezone.offset);
|
|
96
|
+
console.log(timezone.name); // 'Africa/Cairo'
|
|
97
|
+
console.log(timezone.offset); // '+02:00'
|
|
98
98
|
|
|
99
|
-
const now = timezone.now();
|
|
99
|
+
const now = timezone.now(); // Current date/time in Egypt (Date object)
|
|
100
100
|
console.log(now.toISOString());
|
|
101
101
|
|
|
102
102
|
console.log(timezone.isDST()); // true or false depending on current date (Egypt resumed DST in 2023)
|
|
@@ -106,44 +106,37 @@ console.log(timezone.isDST()); // true or false depending on current date (Egypt
|
|
|
106
106
|
|
|
107
107
|
### `governorates`
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `search(query)` | `string` | `Array<Governorate>` | Search by Arabic or English name (partial, case-insensitive) |
|
|
116
|
-
|
|
109
|
+
| Method | Parameters | Returns | Description |
|
|
110
|
+
| ----------------- | ---------- | -------------------- | ------------------------------------------------------------ | --------------------------------------------- | ------------------------------------ |
|
|
111
|
+
| `getAll()` | — | `Array<Governorate>` | Returns all 27 Egyptian governorates |
|
|
112
|
+
| `getByCode(code)` | `string` | `Governorate | undefined` | Find a governorate by its code (e.g. `'CAI'`) |
|
|
113
|
+
| `getById(id)` | `number | string` | `Governorate | undefined` | Find a governorate by its numeric id |
|
|
114
|
+
| `search(query)` | `string` | `Array<Governorate>` | Search by Arabic or English name (partial, case-insensitive) |
|
|
117
115
|
|
|
118
116
|
**Governorate shape:** `{ id: number, code: string, name: string, nameEn: string }`
|
|
119
117
|
|
|
120
118
|
### `cities`
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `search(query)` | `string` | `Array<City>` | Search by Arabic or English name (partial, case-insensitive) |
|
|
128
|
-
|
|
120
|
+
| Method | Parameters | Returns | Description |
|
|
121
|
+
| --------------------------- | ---------- | ------------- | ------------------------------------------------------------ | ---------- | ----------------------------- |
|
|
122
|
+
| `getByGovernorate(govCode)` | `string` | `Array<City>` | Get all cities in a governorate |
|
|
123
|
+
| `getById(id)` | `number | string` | `City | undefined` | Find a city by its numeric id |
|
|
124
|
+
| `search(query)` | `string` | `Array<City>` | Search by Arabic or English name (partial, case-insensitive) |
|
|
129
125
|
|
|
130
126
|
**City shape:** `{ id: number, name: string, nameEn: string, governorateCode: string }`
|
|
131
127
|
|
|
132
128
|
### `phoneArea`
|
|
133
129
|
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `getCode(regionName)` | `string` | `AreaCode | undefined` | Find area code entry by region name (Arabic or English) |
|
|
140
|
-
|
|
130
|
+
| Method | Parameters | Returns | Description |
|
|
131
|
+
| --------------------- | ---------- | ----------------- | --------------------------------------------------- | ------------------------------------------------------- |
|
|
132
|
+
| `getAll()` | — | `Array<AreaCode>` | Returns all Egyptian landline and mobile area codes |
|
|
133
|
+
| `getRegion(code)` | `string` | `AreaCode | undefined` | Look up region info by area code |
|
|
134
|
+
| `getCode(regionName)` | `string` | `AreaCode | undefined` | Find area code entry by region name (Arabic or English) |
|
|
141
135
|
|
|
142
136
|
**AreaCode shape:** `{ code: string, region: string, regionEn: string }`
|
|
143
137
|
|
|
144
138
|
### `timezone`
|
|
145
139
|
|
|
146
|
-
|
|
147
140
|
| Property / Method | Returns | Description |
|
|
148
141
|
| ----------------- | ---------------- | --------------------------------------------------- |
|
|
149
142
|
| `name` | `'Africa/Cairo'` | IANA timezone identifier |
|
|
@@ -151,7 +144,6 @@ console.log(timezone.isDST()); // true or false depending on current date (Egypt
|
|
|
151
144
|
| `now()` | `Date` | Current date/time in Egypt |
|
|
152
145
|
| `isDST(date?)` | `boolean` | Whether DST is active (optionally for a given date) |
|
|
153
146
|
|
|
154
|
-
|
|
155
147
|
## Data Coverage
|
|
156
148
|
|
|
157
149
|
- **27** governorates with Arabic and English names
|
|
@@ -161,4 +153,4 @@ console.log(timezone.isDST()); // true or false depending on current date (Egypt
|
|
|
161
153
|
|
|
162
154
|
## License
|
|
163
155
|
|
|
164
|
-
[MIT](LICENSE)
|
|
156
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED