Simple tool providing midpoint postcode for an array of postcodes. Endpoints and methods provided by https://postcodes.io/
$ npm install midpoint-postcode-uk
const MidpointPostcode = require("midpoint-postcode-uk");
const myMidpointPostcode = new MidpointPostcode();
let postcodesArr = ["RG109NY", "SW40NH"];
myMidpointPostcode
.bringMidPointPostcode(postcodesArr)
.then(postcode => console.log(postcode));
Method validates a postcode.
console.log(myMidpointPostcode.validate("RG109NY")); //true
console.log(myMidpointPostcode.validate("XXYYZZT")); //false
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
First, install development dependencies:
$ npm install midpoint-postcode-uk
Then, run the tests:
$ npm test
Please open an issue on this repo
Basri Dogan https://basridogan.com/
MIT licensed - see LICENSE file