indopkkd
v0.0.8
Published
Listing kode provinsi, kabupaten, kecamatan, desa indonesia
Readme
indopkkd
Get Indonesian region details from a region code.
Benefits and Ease of Use
The indopkkd package simplifies retrieving detailed information about Indonesian regions based on standardized region codes. You can access hierarchical region data, including provinces, cities, sub-districts, and villages, without manual parsing of raw data.
Key Benefits:
- Efficiency: Quickly retrieve detailed region information by code.
- Accuracy: Maps standardized region codes to correct names.
- Ease of Use: Simple API functions for easy integration.
- Scalability: Easily extendable to include more regions or data.
Installation
Install via npm:
npm install indopkkdUsage
Import and invoke the provided helper functions:
const {
getRegion,
getProvinsi,
getKota,
getKecamatan,
getDesa,
listProvinsi,
listKota,
listKecamatan,
listDesa,
} = require('indopkkd');1. Get Region Details
const region = getRegion('1101012001');
console.log(region);
// {
// provinsi: 'ACEH',
// kab: 'KAB. ACEH SELATAN',
// kecamatan: 'Bakongan',
// desa: 'Keude Bakongan'
// }getRegion(regionCode: string)
- Input: 10-digit numeric string (unformatted).
- Output: Object with
provinsi,kab,kecamatan,desakeys (strings or null).
2. Get Province (Provinsi) Names
const prov = getProvinsi('11');
console.log(prov);
// ['ACEH']getProvinsi(provinsiCode: string)
- Input: 2-digit code.
- Output: Array of province names matching the code.
3. Get City (Kota) Names
const cities = getKota('01');
console.log(cities);
// ['KAB. ACEH SELATAN']getKota(kotaCode: string)
- Input: 2-digit city code.
- Output: Array of city names matching the code.
4. Get Sub-district (Kecamatan) Names
const subdistricts = getKecamatan('01');
console.log(subdistricts);
// ['Bakongan', 'Kluet Utara']getKecamatan(kecamatanCode: string)
- Input: 2-digit sub-district code.
- Output: Array of sub-district names matching the code.
5. Get Village (Desa) Names
const villages = getDesa('2001');
console.log(villages);
// ['Keude Bakongan', 'Fajar Harapan']getDesa(desaCode: string)
- Input: 4-digit village code.
- Output: Array of village names matching the code.
Dropdown List Helpers
For hierarchical dropdowns in UI:
listProvinsi()
listProvinsi();
// [{ code: '11', name: 'ACEH' }, ...]- Returns array of
{ code, name }for all provinces.
listKota(provinsiCode)
listKota('11');
// [{ code: '01', name: 'KAB. ACEH SELATAN' }, ...]- Filter cities by 2-digit province code.
listKecamatan(kotaCode)
listKecamatan('01');
// [{ code: '01', name: 'Bakongan' }, ...]- Filter sub-districts by 2-digit city code.
listDesa(kecamatanCode)
listDesa('01');
// [{ code: '2001', name: 'Keude Bakongan' }, ...]- Filter villages by 2-digit sub-district code.
Testing
Include the pre-made test script to validate all functions:
node test/test.jsOutput will list results for each helper. Modify or extend the tests as needed.
Versioning
Follow SemVer for version increments:
- Patch for bug fixes (e.g.
npm version patch). - Minor for backward-compatible features (e.g.
npm version minor). - Major for breaking changes (e.g.
npm version major).
After bumping version:
git push origin main --tags
npm publish --access publicContribution Guidelines
- Fork the repository and create a feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
Please follow existing code style and include tests for new functionality.
License
MIT © [fandilladp] 2025
