A parser to find where zip/postal codes (and US 5-digit extensions) are in a string.
Full documentation is available at the zerodep.app page.
NOTE: currently supports US and CA zip/postal codes
All @zerodep packages support both ESM and CJS.
import { addressZip } from '@zerodep/address-zip';
// or
const { addressZip } = require('@zerodep/address-zip');
addressZip('1234 Main St, Los Angeles CA, US 90210-1234');
// [
// {
// zip: '90210',
// zipExt: '1234',
// countryIso2s: ['US'],
// source: '90210-1234',
// ndx: 34,
// length: 10,
// },
// ]
addressZip('12345 Main Street, Toronto ON, Canada M4A 3B6');
// [
// {
// zip: 'M4A 3B6',
// countryIso2s: ['CA'],
// source: 'M4A 3B6',
// ndx: 38,
// length: 7,
// },
// {
// zip: '12345',
// countryIso2s: ['US'],
// source: '12345',
// ndx: 0,
// length: 5,
// },
// ]