1.1.2 • Published 4 years ago

kodepos.js v1.1.2

Weekly downloads
39
License
MIT
Repository
github
Last release
4 years ago

kodepos.js

kodepos.js

A simple Node.js module to search postal code (kode pos) in Indonesia.

Installation

npm install --save kodepos.js

Use this module in server environment as it contain relatively large json dataset. If you want to use it on client side, make sure to use compression. Haven't test it though.

Usage

kodepos.search()

const kodepos = require("kodepos.js");

const query = "bandung";
const limit = 10;
const exact = false; // Should match query? if false, LIKE (similar in SQL) method is used.

const search = kodepos.search(query, limit, exact);
console.log(search);

kodepos.searchBy()

const kodepos = require("kodepos.js");

const scope = "city"; // Check table below for available values
const query = "bandung";
const limit = 10;
const exact = true; // Should match query? if false, LIKE (similar in SQL) method is used.

const searchBy = kodepos.search(scope, query, limit, exact);
console.log(searchBy);
MethodParamTypeRequiredDefaultDescription
search()queryStringTrueNoneThe query of search operation
limitNumberFalse10Results limit. Set 0 to return all
exactBoolFalseFalseShould search to match query?
searchBy()scopeStringTrueNoneprovince / city / urban / disctrict
queryStringTrueNoneThe query of search operation
limitNumberFalse10Results limit. Set 0 to return all
exactBoolFalseFalseShould search to match query?

Returns

{
  count: Number,
  results: Array
}

Test

Clone this repository and run:

npm test