npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@damarkuncoro/data-wilayah-indonesia

v1.2.1

Published

Package JavaScript/TypeScript untuk data wilayah administratif Indonesia dengan arsitektur pluginable

Downloads

391

Readme

Data Wilayah Administratif Indonesia

NPM version

Package JavaScript/TypeScript yang ringan, modern, dan dapat diperluas (pluginable) untuk mengakses data wilayah administratif Indonesia (Provinsi, Kabupaten/Kota, Kecamatan, dan Desa/Kelurahan).

Fitur Utama

  • Data Lengkap & Terverifikasi: Berdasarkan Kepmendagri No. 050-145 Tahun 2022 (Terupdate 2024).
  • Optimasi Bundle (Lazy Loading): Mendukung pemuatan data desa secara asinkron per provinsi untuk menjaga ukuran bundle aplikasi tetap kecil.
  • Hierarki Lengkap: Setiap objek wilayah menyertakan nama induknya (misal: Village menyertakan provinceName dan regencyName).
  • Modern & Type-Safe: Ditulis dalam TypeScript dengan dukungan Functional API untuk tree-shaking yang maksimal.
  • Arsitektur Pluginable: Perkaya data dengan mudah (Kodepos, Koordinat, dll.) tanpa mengubah kode inti.

Instalasi

npm install @damarkuncoro/data-wilayah-indonesia

Penggunaan

1. Functional API (Direkomendasikan)

Gunakan fungsi-fungsi ini untuk mendukung tree-shaking yang lebih baik di bundler modern seperti Vite atau Webpack.

import { 
  getAllProvinces, 
  getRegenciesByProvince, 
  getDistrictsByRegency, 
  fetchVillagesByDistrict 
} from '@damarkuncoro/data-wilayah-indonesia';

// Mendapatkan semua provinsi
const provinces = getAllProvinces();

// Mendapatkan kabupaten/kota di Jawa Barat (32)
const regencies = getRegenciesByProvince('32');

// Lazy Loading data desa (Hanya memuat data untuk provinsi yang dibutuhkan)
const villages = await fetchVillagesByDistrict('32.73.01');
console.log(villages[0].provinceName); // "JAWA BARAT"
console.log(villages[0].regencyName);  // "KOTA BANDUNG"

2. Service API (Class-based)

Gunakan jika Anda perlu menyuntikkan provider atau plugin kustom.

import { DataWilayahService } from '@damarkuncoro/data-wilayah-indonesia';

const service = new DataWilayahService();
const provinces = service.getAllProvinces();

Arsitektur Pluginable

Menggunakan DataPlugin untuk Memperkaya Data

Plugin memungkinkan Anda untuk menambahkan data tambahan seperti kodepos atau koordinat.

import { DataPlugin, Village, DataWilayahService } from '@damarkuncoro/data-wilayah-indonesia';

class MyCustomPlugin implements DataPlugin {
  name = 'my-custom-plugin';

  enrichVillages(villages: Village[]): Village[] {
    return villages.map(v => ({ ...v, customData: 'foo' }));
  }
}

const service = new DataWilayahService(undefined, [new MyCustomPlugin()]);

Menggunakan DataProvider Kustom

Ganti sumber data (misal: dari API atau Database) dengan mengimplementasikan DataProvider.

import { DataProvider, DataWilayahService } from '@damarkuncoro/data-wilayah-indonesia';

class MyDatabaseProvider implements DataProvider {
  // Implementasi getProvinces, getRegencies, dll.
}

const service = new DataWilayahService(new MyDatabaseProvider());

Metadata & Transparansi

  • Sumber Data: Kepmendagri No. 050-145 Tahun 2022.
  • Update Terakhir: 2024.
  • Versioning: Mengikuti Semantic Versioning (SemVer).

Lisensi

MIT