latest-ph-address-thanks-to-anehan 1.0.0 → 1.0.2
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 +128 -404
- package/data/by-level.json.gz +0 -0
- package/data/by-psgc.json.gz +0 -0
- package/index.js +26 -3
- package/package.json +4 -3
- package/data/addresses.json +0 -350154
- package/data/by-level.json +0 -350036
- package/data/by-psgc.json +0 -350154
- package/data/hierarchy.json +0 -3458
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const zlib = require('zlib');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// Load and decompress data files
|
|
6
|
+
function loadCompressedData(filename) {
|
|
7
|
+
const filePath = path.join(__dirname, 'data', filename);
|
|
8
|
+
|
|
9
|
+
// Try compressed file first, fallback to uncompressed
|
|
10
|
+
try {
|
|
11
|
+
const compressedPath = filePath + '.gz';
|
|
12
|
+
if (fs.existsSync(compressedPath)) {
|
|
13
|
+
const compressed = fs.readFileSync(compressedPath);
|
|
14
|
+
const decompressed = zlib.gunzipSync(compressed);
|
|
15
|
+
return JSON.parse(decompressed.toString());
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// Fallback to uncompressed if compression fails
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Fallback to uncompressed JSON
|
|
22
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const byPsgcData = loadCompressedData('by-psgc.json');
|
|
26
|
+
const byLevelData = loadCompressedData('by-level.json');
|
|
4
27
|
|
|
5
28
|
/**
|
|
6
29
|
* Get all regions
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "latest-ph-address-thanks-to-anehan",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Latest Philippine addresses database with complete coverage of all Regions, Provinces, Cities, Municipalities, and Barangays. Perfect for address forms and location-based applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"optimize": "node scripts/optimize-data.js",
|
|
8
|
+
"compress": "node scripts/compress-data.js",
|
|
9
|
+
"prepublishOnly": "npm run compress",
|
|
9
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|