latest-ph-address-thanks-to-anehan 1.0.2 → 1.0.4

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 CHANGED
@@ -25,20 +25,29 @@ npm install latest-ph-address-thanks-to-anehan
25
25
 
26
26
  ### Import
27
27
 
28
+ The package exports an object with functions. You can name the imported object anything you want:
29
+
28
30
  ```typescript
29
31
  // ES6 Import (Recommended)
32
+ // 'phAddress' is just a variable name - you can use any name you prefer
30
33
  import phAddress from 'latest-ph-address-thanks-to-anehan';
34
+ // OR: import address from 'latest-ph-address-thanks-to-anehan';
35
+ // OR: import philippines from 'latest-ph-address-thanks-to-anehan';
31
36
 
32
- // ES6 Named Imports
37
+ // ES6 Named Imports (Import specific functions)
33
38
  import { getRegions, getProvincesByRegion, getBarangaysByCityOrMun } from 'latest-ph-address-thanks-to-anehan';
34
39
 
35
40
  // CommonJS (Node.js)
36
41
  const phAddress = require('latest-ph-address-thanks-to-anehan');
42
+ // OR: const address = require('latest-ph-address-thanks-to-anehan');
37
43
  ```
38
44
 
45
+ **Note:** `phAddress` stands for "Philippine Address" - it's just a suggested variable name. You can use any name you prefer!
46
+
39
47
  ### Basic Usage
40
48
 
41
49
  ```typescript
50
+ // Using default import (object with all functions)
42
51
  import phAddress from 'latest-ph-address-thanks-to-anehan';
43
52
 
44
53
  // Get all regions
package/index.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Type definitions for latest-ph-address-thanks-to-anehan
3
+ * Complete Philippine addresses database with PSGC codes
4
+ */
5
+
6
+ export interface AddressItem {
7
+ psgc: string;
8
+ name: string;
9
+ correspondenceCode?: string;
10
+ geographicLevel?: string;
11
+ cityClass?: string | null;
12
+ }
13
+
14
+ export interface PhAddress {
15
+ /**
16
+ * Get all regions in the Philippines
17
+ * @returns Array of all regions (sorted A-Z)
18
+ */
19
+ getRegions(): AddressItem[];
20
+
21
+ /**
22
+ * Get provinces in a selected region
23
+ * @param regionPsgc - Optional: Region PSGC code
24
+ * @returns Array of provinces (sorted A-Z) when region is provided,
25
+ * Array of all provinces + "-NO PROVINCE-" (83 items) when no parameter,
26
+ * or "-NO PROVINCE-" (string) when region is NCR
27
+ */
28
+ getProvincesByRegion(regionPsgc?: string): AddressItem[] | string;
29
+
30
+ /**
31
+ * Get all cities and municipalities geographically located in selected province
32
+ * Includes HUCs (Highly Urbanized Cities) that are geographically located in the province
33
+ * @param provincePsgc - Province PSGC code or "-NO PROVINCE-"
34
+ * @param regionPsgc - Optional: Region PSGC code (required when provincePsgc is "-NO PROVINCE-")
35
+ * @returns Array of cities and municipalities (sorted A-Z)
36
+ */
37
+ getCitiesAndMunsByProvince(provincePsgc: string, regionPsgc?: string): AddressItem[];
38
+
39
+ /**
40
+ * Get all barangays located in selected city or municipality
41
+ * Works for all cities and municipalities including HUCs (Manila, Baguio, etc.)
42
+ * @param cityMunPsgc - City/Municipality PSGC code
43
+ * @returns Array of barangays (sorted A-Z)
44
+ */
45
+ getBarangaysByCityOrMun(cityMunPsgc: string): AddressItem[];
46
+
47
+ /**
48
+ * Get the region for a given province
49
+ * Useful for auto-selecting region when user chooses province first (province-first flow)
50
+ * @param provincePsgc - Province PSGC code
51
+ * @returns Region object or null if not found
52
+ */
53
+ getRegionByProvince(provincePsgc: string): AddressItem | null;
54
+ }
55
+
56
+ declare const phAddress: PhAddress;
57
+ export default phAddress;
58
+
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "latest-ph-address-thanks-to-anehan",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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
+ "types": "index.d.ts",
6
7
  "scripts": {
7
8
  "optimize": "node scripts/optimize-data.js",
8
9
  "compress": "node scripts/compress-data.js",