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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wilayah

v1.3.0

Published

Module wilayah as client and server

Downloads

12

Readme

Author License Forks Stars Issues Release Package Donate

wilayah

Database wilayah non-SQL, parsed as JSON

Idea

Inspired by @cahyadsn/wilayah working as SQL and PHP app, then I've got an idea to build my own wilayah repo but parsed as JSON, base on his repo with his permission.

Sample

Sample website page, as demo or testing. in https://9r3i.github.io/force-sample/wilayah.html

The sample is plugged in ForceWebsite app.

Usage (Server - NodeJS)

Install

$ npm i wilayah

Usage as Server

Create file start.js with content require('wilayah/start')

$ echo "require('wilayah/start')">start.js

Then start the server

$ node start

Or with specific port, default: 3000

$ node start 4000

Output:

WilayahServer on http://localhost:4000

Then wilayah server is ready.

Usage (Client - NodeJS)

Install

$ npm i wilayah

Usage as Client

Create file client.js with content require('wilayah/client')

$ echo "require('wilayah/client')">client.js

Then put some command with path like:

$ node client <path>

Read more about leveling path here below, and also learn how to show index.

Example:

  • Level 1 is province code, sample JAWA BARAT is 32
  • Level 2 is kabupaten or kota, sample KAB. BANDUNG is 04
  • Level 3 is kecamatan, sample Banjaran is 13

So the path will be 32/04/13

$ node client 32/04/13

Output:

{
  "2001": "Kamasan",
  "2002": "Banjaran Wetan",
  "2003": "Banjaran Kulon",
  "2005": "Ciapus",
  "2006": "Sindangpanon",
  "2007": "Kiangroke",
  "2008": "Tarajusari",
  "2012": "Mekarjaya",
  "2013": "Margahurip",
  "2016": "Neglasari",
  "2018": "Pasirmulya"
}

This client method assumes the host is https://9r3i.github.io/wilayah/api/2022/

If you wish to use your own host, you might customize like the Usage as Client below.

Or use another argument in client CLI, like:

$ node client 32/04/13 http://localhost:4000/

The output will be the same as well as the database is.

Usage (NodeJS)

Install

$ npm i wilayah

Usage as Client

const { WilayahClient } = require('wilayah');

(async function(){
  const host='https://9r3i.github.io/wilayah/api/2022/',
  wilayah=new WilayahClient(host),
  result=await wilayah.fetch('index');
  console.log(result);
})();

Result

{
  "11": "ACEH",
  "12": "SUMATERA UTARA",
  "13": "SUMATERA BARAT",
  "14": "RIAU",
  "15": "JAMBI",
  "16": "SUMATERA SELATAN",
  "17": "BENGKULU",
  "18": "LAMPUNG",
  "19": "KEPULAUAN BANGKA BELITUNG",
  "21": "KEPULAUAN RIAU",
  "31": "DKI JAKARTA",
  "32": "JAWA BARAT",
  "33": "JAWA TENGAH",
  "34": "DAERAH ISTIMEWA YOGYAKARTA",
  "35": "JAWA TIMUR",
  "36": "BANTEN",
  "51": "BALI",
  "52": "NUSA TENGGARA BARAT",
  "53": "NUSA TENGGARA TIMUR",
  "61": "KALIMANTAN BARAT",
  "62": "KALIMANTAN TENGAH",
  "63": "KALIMANTAN SELATAN",
  "64": "KALIMANTAN TIMUR",
  "65": "KALIMANTAN UTARA",
  "71": "SULAWESI UTARA",
  "72": "SULAWESI TENGAH",
  "73": "SULAWESI SELATAN",
  "74": "SULAWESI TENGGARA",
  "75": "GORONTALO",
  "76": "SULAWESI BARAT",
  "81": "MALUKU",
  "82": "MALUKU UTARA",
  "91": "PAPUA",
  "92": "PAPUA BARAT"
}

Usage (ForceWebsite)

Install

{
  "plugins": [
    ["wilayah",{
        "host": "https://9r3i.github.io/wilayah/api/2022/"
      },
      "https://9r3i.github.com/wilayah/fw-plugin"
    ]
  ]
}

Usage

Just put :wilayah: in one of data content.

to get result

const result=(new wilayah).getResult();
console.log(result);

Result (sample)

Desa Baros, Arjasari, KAB. BANDUNG, JAWA BARAT

Usage (Browser)

Install

<script src="https://9r3i.github.io/wilayah/wilayah.js"></script>

Usage

(async function(){
  const host='https://9r3i.github.io/wilayah/api/2022/',
  wilayah=new WilayahClient(host),
  result=await wilayah.fetch('index');
  console.log(result);
})();

Result

{
  "11": "ACEH",
  "12": "SUMATERA UTARA",
  "13": "SUMATERA BARAT",
  "14": "RIAU",
  "15": "JAMBI",
  "16": "SUMATERA SELATAN",
  "17": "BENGKULU",
  "18": "LAMPUNG",
  "19": "KEPULAUAN BANGKA BELITUNG",
  "21": "KEPULAUAN RIAU",
  "31": "DKI JAKARTA",
  "32": "JAWA BARAT",
  "33": "JAWA TENGAH",
  "34": "DAERAH ISTIMEWA YOGYAKARTA",
  "35": "JAWA TIMUR",
  "36": "BANTEN",
  "51": "BALI",
  "52": "NUSA TENGGARA BARAT",
  "53": "NUSA TENGGARA TIMUR",
  "61": "KALIMANTAN BARAT",
  "62": "KALIMANTAN TENGAH",
  "63": "KALIMANTAN SELATAN",
  "64": "KALIMANTAN TIMUR",
  "65": "KALIMANTAN UTARA",
  "71": "SULAWESI UTARA",
  "72": "SULAWESI TENGAH",
  "73": "SULAWESI SELATAN",
  "74": "SULAWESI TENGGARA",
  "75": "GORONTALO",
  "76": "SULAWESI BARAT",
  "81": "MALUKU",
  "82": "MALUKU UTARA",
  "91": "PAPUA",
  "92": "PAPUA BARAT"
}

Methods

fetch

Promise method, parameters:

  • path string of path

Result will be an object on success or false on failed

fetchCB

Callback method, parameters:

  • path string of path
  • callback function of callback
    • callback argument will be an object on success or false on failed

Path

Level 1 index

First path is level 1 wilayah or province, fetch index using path index, sample:

await wilayah.fetch('index');

or number of level 1 index, sample of level 2 index of JAWA BARAT:

await wilayah.fetch('32/index');

Level 2 index

Second level is for level 2 as Kabupaten or Kota, sample of level 2 index of JAWA BARAT:

await wilayah.fetch('32/index');

or number of level 2 index, sample of level 3 index of KAB. BANDUNG:

await wilayah.fetch('32/04/index');

Level 3 index

Third level is for kecamatan, sample of level 4 index of Banjaran:

await wilayah.fetch('32/04/13');

Closing

That's all there is to it. Alhamdulillaah...

Visitors

9r3i/wilayah Visitors |---| | Since January 14th 2023 or when this repo was created and first commit |