
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@zerodep/address-state
Advanced tools
A parser to find where a state name or abbreviation is in a string
A parser to find where a state name or abbreviation is in a string.
Full documentation is available at the zerodep.app page.
declare const addressState: (address: string, countryIso2?: CountryIso2) => AddressState[];
interface AddressState {
stateAbbr: StateUsAbbr | StateCaAbbr;
source: string;
ndx: number;
length: number;
}
The addressState function has the following parameters:
The addressState function will return the following:
The addressState function will throw an Error if the state cannot be found.
All @zerodep packages support both ESM and CJS formats, each complete with Typescript typings.
// ESM
import { addressState } from '@zerodep/address-state';
// CJS
const { addressState } = require('@zerodep/address-state');
// American address
addressState('1234 Main Street, Los Angeles California, 90210');
// or
addressState('1234 Main Street, Los Angeles California, 90210', 'US');
// [
// {
// stateAbbr: 'CA',
// source: 'California',
// ndx: 30,
// length: 10,
// },
// ]
// Canadian Address
addressState('13375 rue rita pierrefonds quebec h8z1j3');
// or
addressState('13375 rue rita pierrefonds quebec h8z1j3', 'CA');
// [
// {
// "stateAbbr": "QC",
// "source": "qc",
// "ndx": 27,
// "length": 6,
// }
// ]
// Unspecified country
addressState('1234 oregon street, toronto on');
// [
// {
// "stateAbbr": "ON",
// "source": "on",
// "ndx": 28,
// "length": 2
// },
// {
// "stateAbbr": "OR",
// "source": "oregon",
// "ndx": 5,
// "length": 6
// }
// ]
// no results found
addressState('unknown');
// []
FAQs
A parser to find where a state name or abbreviation is in a string
We found that @zerodep/address-state demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.