The Address class is designed to wrap a Postcode Address File (PAF)
record and provide utility methods to make this data more readily
consumable for humans
Address requires an object of type AddressRecord to be instantiated
which is comprised of fields readily found on PAF
Address can be used to
Compute address lines based on premise and locality information
Sensibly compute a premise label based on (sub) building name and number
Sensibly compute number and unit labels based on (sub) building name and number
Sensibly sort an array of addresses
example
// Formatting an address
constaddress = newAddress({ postcode:"WS11 5SB", post_town:"CANNOCK", dependant_locality:"", double_dependant_locality:"", thoroughfare:"Pye Green Road", building_number:"", building_name:"Flower House 189A", sub_building_name:"", dependant_thoroughfare:"", organisation_name:'S D Alcott Florists', });
constaddresses = awaitquery("SELECT * FROM postcode_address_file LIMIT 10");
addresses .map(address=>newAddress(address)) // Instantiate an `Address` instances .sort(Address.sort) // Now sort
// Print an example to console .forEach(address=>console.log(address.line_1)); // "190 Elm Road" // "190a Elm Road" // "191 Elm Road" // "191a Elm Road" // "192 Elm Road" // "193 Elm Road" // "193a Elm Road" // "197 Elm Road" // "197a Elm Road" // "199 Elm Road"
The
Address
class is designed to wrap a Postcode Address File (PAF) record and provide utility methods to make this data more readily consumable for humansAddress
requires an object of typeAddressRecord
to be instantiated which is comprised of fields readily found on PAFAddress
can be used topremise
label based on (sub) building name and numbernumber
andunit
labels based on (sub) building name and number