truncate
truncate(
code,to):Postcode
Shortens a postcode to a less precise segment, for example from a building to its area.
Parameters
Section titled “Parameters”A parsed postcode.
The precision to keep. It must not be more precise than the code.
Returns
Section titled “Returns”The shorter postcode.
Throws
Section titled “Throws”RangeError when to is more precise than the code, or is not a precision.
Example
Section titled “Example”const building = parse('EK-01-A03-FK-01');if (building.ok) { truncate(building.value, 'district').canonical; // 'EK-01-A03'}Unofficial. Not made or endorsed by NIPOST.