Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Node.js Example

This example demonstrates how to use malaysia-postcodes in a Node.js environment with both ES modules and CommonJS.

Requirements

  • Node.js 18.0.0 or higher

Installation

  1. Navigate to this directory:
cd examples/nodejs
  1. Install dependencies:
npm install

Running the Examples

ES Modules (Recommended)

npm start
# or
node index.js

CommonJS

npm run start:commonjs
# or
node index.cjs

What This Example Shows

  • Getting all states and cities
  • Finding specific cities and postcodes
  • Using the universal search function
  • Getting random data for testing
  • Both ES modules and CommonJS syntax

The examples use different states and cities to show various use cases of the library.