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 · Parsing, formatting and shared types

getZipPrefixesForStatefunction

The ZIP code prefixes a state or territory uses, the reverse of getStateFromZip: three digits where a whole block of a hundred belongs to it, five where only part of one does. Every ZIP starting with one of them resolves to that state.

Import it

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

Definition

function getZipPrefixesForState(state: string): string[]

Parameters

NameTypeDescription
statestring

The state or territory's two-letter code.

Returns

string[]

The prefixes in ascending order, or an empty array for an unknown code.

Examples

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

console.log(getZipPrefixesForState("RI"));
// → ["028","029"]
[ '028', '029' ]

What it prints (run when this page was built)

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