@id-region-data/data 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +94 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @id-region-data/data
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@id-region-data/data.svg)](https://www.npmjs.com/package/@id-region-data/data)
4
+ [![license](https://img.shields.io/npm/l/@id-region-data/data.svg)](https://github.com/id-region-data/id-region-data/blob/master/LICENSE)
5
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@id-region-data/data)](https://bundlephobia.com/package/@id-region-data/data)
6
+
7
+ High-performance, ultra-lightweight Indonesian region data (Provinces, Regencies, Districts, Villages) optimized for modern web applications.
8
+
9
+ ## 🚀 Why this package?
10
+
11
+ Most Indonesian region packages are **monolithic**, forcing users to download a **24MB+ JSON file** just to pick a single village. This causes massive frontend bundle bloat and slow page loads.
12
+
13
+ **@id-region-data/data** solves this by using **Dynamic Chunking**:
14
+ - **0MB Initial Load**: The core library is almost weightless.
15
+ - **Lazy Loading**: Data is fetched on-demand using dynamic imports.
16
+ - **Tree-Shaking**: Only the functions you use are included in your bundle.
17
+ - **Modern**: Fully supports ESM, CommonJS, and TypeScript.
18
+ - **Up-to-Date**: Based on the latest **Kepmendagri 2025** data (38 Provinces, 83,345 Villages).
19
+
20
+ ---
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ npm install @id-region-data/data
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 🛠 Usage
31
+
32
+ All functions are asynchronous and return a `Promise`. Data is only downloaded when a function is called for a specific parent code.
33
+
34
+ ### 1. Get All Provinces
35
+ ```typescript
36
+ import { getProvinces } from '@id-region-data/data';
37
+
38
+ const provinces = await getProvinces();
39
+ // [ { code: '11', name: 'ACEH' }, ... ]
40
+ ```
41
+
42
+ ### 2. Get Regencies by Province
43
+ ```typescript
44
+ import { getRegenciesByProvince } from '@id-region-data/data';
45
+
46
+ const regencies = await getRegenciesByProvince('32'); // 32 = Jawa Barat
47
+ ```
48
+
49
+ ### 3. Get Districts by Regency
50
+ ```typescript
51
+ import { getDistrictsByRegency } from '@id-region-data/data';
52
+
53
+ const districts = await getDistrictsByRegency('3273'); // 3273 = Kota Bandung
54
+ ```
55
+
56
+ ### 4. Get Villages by District
57
+ ```typescript
58
+ import { getVillagesByDistrict } from '@id-region-data/data';
59
+
60
+ const villages = await getVillagesByDistrict('3273100'); // Arcamanik
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 📐 Data Interfaces
66
+
67
+ Strict TypeScript interfaces are exported for your convenience:
68
+
69
+ ```typescript
70
+ import type { Province, Regency, District, Village } from '@id-region-data/data';
71
+ ```
72
+
73
+ ---
74
+
75
+ ## ⚡ Performance Deep Dive
76
+
77
+ This library splits the Indonesian hierarchy into **23,531 small JSON chunks**.
78
+
79
+ | Level | Fetch Trigger | Result |
80
+ | :--- | :--- | :--- |
81
+ | **Province** | `getProvinces()` | Loads `provinces.json` (~4KB) |
82
+ | **Regency** | `getRegenciesByProvince('11')` | Loads `regencies/11.json` (~2KB) |
83
+ | **District** | `getDistrictsByRegency('1101')` | Loads `districts/1101.json` (~2KB) |
84
+ | **Village** | `getVillagesByDistrict('110101')` | Loads `villages/110101.json` (~1KB) |
85
+
86
+ Instead of downloading **24MB**, your user's browser only downloads roughly **10KB** of data to complete a full "Province → Village" selection flow.
87
+
88
+ ---
89
+
90
+ ## 📂 Source Data
91
+ Data is parsed and verified from the authoritative [cahyadsn/wilayah](https://github.com/cahyadsn/wilayah) repository, ensuring compliance with the latest government regional codes.
92
+
93
+ ## 📄 License
94
+ MIT © [id-region-data](https://www.npmjs.com/org/id-region-data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@id-region-data/data",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "High-performance, ultra-lightweight Indonesian region data package with tree-shaking and lazy loading support.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",