midpoint-postcode-uk

1.0.2 • Public • Published

midpoint-postcode-uk

Simple tool providing midpoint postcode for an array of postcodes. Endpoints and methods provided by https://postcodes.io/

badogan

Installation

$ npm install midpoint-postcode-uk

Usage

const MidpointPostcode = require("midpoint-postcode-uk");
const myMidpointPostcode = new MidpointPostcode();
 
let postcodesArr = ["RG109NY", "SW40NH"];
myMidpointPostcode
  .bringMidPointPostcode(postcodesArr)
  .then(postcode => console.log(postcode));

Postcode validation method

Method validates a postcode.

console.log(myMidpointPostcode.validate("RG109NY")); //true
console.log(myMidpointPostcode.validate("XXYYZZT")); //false

bringMidpointPostcode method

Method returns midpoint postcode for the input postcode(s) array. Method ignores invalid postcodes and returns the midpoint postcode for the valid postcodes only. Postcode validation recommended prior to calling the function. Please see validation method above.

let postcodesArr = ["RG109NY", "SW40NH"];
myMidpointPostcode
  .bringMidPointPostcode(postcodesArr)
  .then(postcode => console.log(postcode)); //SL30BQ

Testing

First, install development dependencies:

$ npm install midpoint-postcode-uk

Then, run the tests:

$ npm test

Support

Please open an issue on this repo

Authors

Basri Dogan https://basridogan.com/

License

MIT licensed - see LICENSE file

Package Sidebar

Install

npm i midpoint-postcode-uk

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.08 kB

Total Files

7

Last publish

Collaborators

  • badogan