daftar-wilayah-indonesia 1.0.0

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 (3) hide show
  1. package/index.js +37 -0
  2. package/package.json +25 -0
  3. package/wilayah.js +38791 -0
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ const satu = require('./wilayah')
2
+ const bn = ['provinsi', 'kabupaten', 'kecamatan', 'desa']
3
+ const w = (d = 'provinsi', k = '0') => {
4
+ for (const key in satu) {
5
+ if (bn.includes(d)) {
6
+ if (d !== "provinsi") {
7
+ if (k === "0") {
8
+ return { error: true, message: `silahkan masukan kode ${bn[bn.indexOf(d) - 1]}` }
9
+ } else {
10
+ let mmk = []
11
+ for (const kgh in satu[`${d}`][0]) {
12
+ mmk.push(kgh)
13
+ }
14
+ const pt = satu[`${d}`].filter(datan => datan[mmk[1]] === k)
15
+ return pt
16
+ }
17
+ } else {
18
+ return satu[`${d}`]
19
+ }
20
+ } else {
21
+ return { error: true, message: 'silahkan masukan keyword provinsi, kabupaten, kecamatan atau desa' }
22
+ }
23
+ }
24
+ }
25
+ const provinsi = () => {
26
+ return w()
27
+ }
28
+ const kabupaten = (kode = '0') => {
29
+ return w(kode, 'kabupaten')
30
+ }
31
+ const kecamatan = (kode = '0') => {
32
+ return w(kode, 'kecamatan')
33
+ }
34
+ const desa = (kode = '0') => {
35
+ return w(kode, 'desa')
36
+ }
37
+ module.exports = { provinsi, kabupaten, kecamatan, desa }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "daftar-wilayah-indonesia",
3
+ "version": "1.0.0",
4
+ "description": "kumpulan daftar wilayah indonesia",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "daftar",
11
+ "wilayah",
12
+ "indonesia",
13
+ "wilayah",
14
+ "indonesia",
15
+ "npm",
16
+ "wilayah",
17
+ "indonesia",
18
+ "provinsi",
19
+ "kabupaten",
20
+ "kecamatan",
21
+ "desa"
22
+ ],
23
+ "author": "Jellan Arta",
24
+ "license": "ISC"
25
+ }