Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · /nz

getRegionFromNewZealandPostcodefunction

The region a postcode is in, by its ISO 3166-2 code without NZ- (AUK for Auckland): the one most of GeoNames' places for the postcode are in.

Import it

import { getRegionFromNewZealandPostcode } from "@johnmorrisdotca/address-plus/nz";

Definition

function getRegionFromNewZealandPostcode(postcode: string): string | undefined

Parameters

NameTypeDescription
postcodestring

The postcode.

Returns

string | undefined

The region's code, or undefined when the list does not have the postcode or gives it no region.

Examples

import { getRegionFromNewZealandPostcode } from "@johnmorrisdotca/address-plus/nz";

console.log(["1010", "6011", "8011", "9016", "9999"].map(getRegionFromNewZealandPostcode));
// → ["AUK","WGN","CAN","OTA",null]
[ 'AUK', 'WGN', 'CAN', 'OTA', undefined ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.10.2.