Reference · Parsing, formatting and shared types
TERRITORY_POSTAL_RANGESconstant
The patterns that tell the Northwest Territories' X codes from Nunavut's, by their first three characters.
Import it
import { TERRITORY_POSTAL_RANGES } from "@johnmorrisdotca/address-plus";
Definition
const TERRITORY_POSTAL_RANGES: { pattern: RegExp; province: string; }[] = [
{ pattern: /^Y/, province: "YT" },
{ pattern: /^X0[ABC]/, province: "NU" },
{ pattern: /^X[01]/, province: "NT" },
]
Examples
import { TERRITORY_POSTAL_RANGES } from "@johnmorrisdotca/address-plus";
console.log(TERRITORY_POSTAL_RANGES.find((range) => range.pattern.test("X0A"))?.province);
// → "NU"NUWhat it prints (run when this page was built)