1.0.2 • Published 6 years ago
midpoint-postcode-uk v1.0.2
midpoint-postcode-uk
Simple tool providing midpoint postcode for an array of postcodes. Endpoints and methods provided by https://postcodes.io/
Installation
$ npm install midpoint-postcode-ukUsage
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")); //falsebringMidpointPostcode 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)); //SL30BQTesting
First, install development dependencies:
$ npm install midpoint-postcode-ukThen, run the tests:
$ npm testSupport
Please open an issue on this repo
Authors
Basri Dogan https://basridogan.com/
License
MIT licensed - see LICENSE file