@zerodep/address-state
TypeScript icon, indicating that this package has built-in type declarations

2.3.4 • Public • Published

@zerodep/address-country

version language types license

CodeFactor Known Vulnerabilities

A parser to find where a state name or abbreviation is in a string.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

import { addressState } from '@zerodep/address-state';
// or
const { addressState } = require('@zerodep/address-state');

Well Formatted Case

// American address
addressState('1234 Main Street, Los Angeles California, 90210');
//  [
//    {
//      stateAbbr: 'CA',
//      source: 'California',
//      ndx: 30,
//      length: 10
//    },
//  ]

// Canadian address
addressState('13375 rue rita pierrefonds quebec h8z1j3');
// [
//   {
//     "stateAbbr": "QC",
//     "source": "quebec",
//     "ndx": 27,
//     "length": 6
//   }
// ]

With Multiple Results

addressCountry('#4 Washington Street, Portland OR 97603');
// [
//   {
//     "stateAbbr": "OR",
//     "source": "OR",
//     "ndx": 31,
//     "length": 2
//   },
//   {
//     "stateAbbr": "WA",
//     "source": "Washington",
//     "ndx": 3,
//     "length": 10
//   }
// ]

Successful Case - Mixed Countries

addressState('1234 oregon street, toronto ont');
// [
//   {
//     "stateAbbr": "ON",
//     "source": "ont",
//     "ndx": 28,
//     "length": 3
//   },
//   {
//     "stateAbbr": "OR",
//     "source": "oregon",
//     "ndx": 5,
//     "length": 6
//   }
// ]

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @zerodep/address-state

      Homepage

      zerodep.app

      Weekly Downloads

      3

      Version

      2.3.4

      License

      MIT

      Unpacked Size

      13.1 kB

      Total Files

      7

      Last publish

      Collaborators

      • cdepage