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

ph-address

v3.0.3

Published

Philippine addresses with PSGC codes.

Downloads

60

Readme

PH Address

Philippine addresses using Philippine Standard Geographic Code (PSGC).

What is this?

This is an npm module that you can include in your projects if you want to use Philippine addresses.

How does it work?

Backend:

  • In your database you only need to store the PSGC of the barangay.
  • The code for a barangay is self-contained. It is a 10-digit number containing the city/municipality, province, and region.

Frontend:

  • In your front-end you need to implement an autocomplete field of the full address. See ph-address-demo.

Why make this?

For web apps that need to input Philippine address, the usual implementation is:

  1. Four fields containing: region, province, city/municipality and barangay.
  2. You must provide input to these fields in a sequence. Select region, provinces are listed, select province, city/municipality is listed, select one, barangays are listed, so on and so forth.

This is problematic because this is the reverse of how we fill up form for address on paper. We start with our barangay, then last is province or city.

Also not everyone knows what their region is but everyone knows their barangay.

With the ph-address implementation, you only need to start typing the barangay and auto suggestions of a full address will show up. You only need an autocomplete field and perhaps a hidden field for the PSGC.

Install

Choose 1 of 3 options:

Install from NPM:

npm install ph-address

Install latest from GitHub:

npm install github:kosinix/ph-address --omit=dev

Tied to a specific version/release from GitHub:

npm install github:kosinix/ph-address#3.0.1 --omit=dev

Quickstart

Include it:

const { PhAddress } = require('ph-address')

(async () => {

    const phAddress = new PhAddress()
    const addressFinder = await phAddress.useSqlite()
    let addresses = await addressFinder.find('brgy 168')
    console.log(addresses)

})()

Usage

phAddress.find(search, minChar = 3, limit = 50, formatter = null)

Find address starting from barangay level with a given keywords

const phAddress = new PhAddress()
const addressFinder = await phAddress.useSqlite()
let addresses = await addressFinder.find('brgy 168')
console.log(addresses)

Response:

[
    {
        name: 'Barangay 168, City of Caloocan, National Capital Region (NCR)',
        id: '1380100168'
    },
    {
        name: 'Barangay 168, Pasay City, National Capital Region (NCR)',
        id: '1381100168'
    },
    {
        name: 'Barangay 168, Tondo I/II, City of Manila, National Capital Region (NCR)',
        id: '1380601168'
    }
]

NOTE: You can change the response format by providing your own formatter function in the find function.

Hierarchy of address:

  • Regions
  • Provinces (Does not exist for NCR)
  • Districts (NCR only - same level as province but not a province)
  • Cities and Municipalities
  • Sub Municipalities (NCR only)
  • Barangay
  • SGU - Special Government Unit (BARMM)

Development

git clone {path to repo}

cd ph-address

npm install

Updating the PSGC CSV File

This module includes the latest PSGC data (input/PSGC-3Q-2022-Publication-Datafile.xlsx) during the module's publishing. If you find the data obsolete and wish to manually update, do the following:

  • Download PSGC Excel file here: https://psa.gov.ph/classification/psgc/ and put it in input dir

  • Run scripts/to-sqlite.js. See file header comments for usage.

  • View database in sqlite/ph-addresses.db using DB Browser for SQLite

  • Run test: node test/find-sqlite.test.js