JSPM

postcodes-malaysia

1.2.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 65
  • Score
    100M100P100Q71979F
  • License ISC

List of Malaysia Postcodes with City and State (JSON)

Package Exports

  • postcodes-malaysia
  • postcodes-malaysia/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcodes-malaysia) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Postcodes Malaysia

npm version install size npm downloads

List of Malaysia Postcodes with City and State (JSON)

Table of Contents

Installation

Install the package from NPM.

npm install postcodes-malaysia

Include it in your script.

import {
  allPostcodes,
  getStates,
  getCities,
  getPostcodes,
  findPostcode,
} from "postcodes-malaysia";

Usage

allPostcodes

Return all states data with city and state and postcodes

Example usage

const postcodes = allPostcodes;

Example results

[
    {
      "name": "Kelantan",
      "city": [
        {
          "name": "Pasir Mas",
          "postcode": [
            "17000",
            "17007",
            "17009",
            "17010",
            "17020",
            "17030",
            "17040",
            "17050",
            "17060",
            "17070"
          ]
        },
        ...
      ]
    },
    ...
]

getStates

Return all states data

Example usage

const states = getStates();

Example results

[
  "Wp Kuala Lumpur",
  "Johor",
  "Kedah",
  "Kelantan",
  "Melaka",
  "Negeri Sembilan",
  "Pahang",
  "Penang",
  "Perak",
  "Perlis",
  "Sabah",
  "Sarawak",
  "Selangor",
  "Terengganu",
  "Wp Labuan",
  "Wp Putrajaya",
];

getCities

Return all cities data based on selected state

Example usage

const cities = getCities("Kelantan");

Example results

[
  "Ayer Lanas",
  "Bachok",
  "Cherang Ruku",
  "Dabong",
  "Gua Musang",
  "Jeli",
  "Kem Desa Pahlawan",
  "Ketereh",
  "Kota Bharu",
  "Kuala Balah",
  "Kuala Krai",
  "Machang",
  "Melor",
  "Pasir Mas",
  "Pasir Puteh",
  "Pulai Chondong",
  "Rantau Panjang",
  "Selising",
  "Tanah Merah",
  "Temangan",
  "Tumpat",
  "Wakaf Bharu",
];

getPostcodes

Return all postcodes data based on selected state and city

Example usage

const postcodes = getPostcodes("Kelantan", "Pasir Mas");

Example results

[
  "17000",
  "17007",
  "17009",
  "17010",
  "17020",
  "17030",
  "17040",
  "17050",
  "17060",
  "17070",
];

findPostcode

Return state and city data based on postcode

Example usage

const location = findPostcode("17070");

Example result if postcode found

{
  "found": true,
  "state": "Kelantan",
  "city": "Pasir Mas"
}

Example result if postcode not found

{
  "found": false
}

Contributing

If you spot any errors, typos or missing information, please submit a pull request.

License

ISC. See LICENSE for more details.

Resources

https://malaysiapostcode.com/