npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

addresser

v1.1.20

Published

Street Address Parser for Node.js

Downloads

70,203

Readme

addresser Build Status Coverage Status npm version

A Node.js library for parsing property addresses. Also includes other address utilities such as a function that returns a random city.

Installation

npm install addresser

Usage

var addresser = require('addresser');

// Isn't confused by duplicate place names
console.log(addresser.parseAddress("400 South Orange Ave, South Orange , NJ 07079"););

{ id: '400-South-Orange-Ave,-South-Orange,-NJ-07079',
  formattedAddress: '400 South Orange Ave, South Orange, NJ 07079',
  zipCode: '07079',
  stateAbbreviation: 'NJ',
  stateName: 'New Jersey',
  placeName: 'South Orange',
  addressLine1: '400 South Orange Ave',
  streetNumber: '400',
  streetSuffix: 'Ave',
  streetName: 'South Orange' }

// Handles extra whitespace
console.log(addresser.parseAddress("123 Double  Space    St, Conway, SC 29526"));

{ id: '123-Double-Space-St,-Conway,-SC-29526',
  formattedAddress: '123 Double Space St, Conway, SC 29526',
  streetNumber: '123',
  streetSuffix: 'St',
  streetName: 'Double Space',
  addressLine1: '123 Double Space St',
  placeName: 'Conway',
  stateAbbreviation: 'SC',
  stateName: 'South Carolina',
  zipCode: '29526' }

// normalizes to Title Case  
console.log(addresser.parseAddress("123 Main St, Conway, south carolina 29526-1234"));

{ id: '123-Main-St,-Conway,-SC-29526',
  formattedAddress: '123 Main St, Conway, SC 29526',
  streetNumber: '123',
  streetSuffix: 'St',
  streetName: 'Main',
  addressLine1: '123 Main St',
  placeName: 'Conway',
  stateAbbreviation: 'SC',
  stateName: 'South Carolina',
  zipCode: '29526',
  zipCodePlusFour: '29526-1234'}

// Handles secondary address lines even without delimiters.
// Normalizes street types to standard abbreviations.
console.log(addresser.parseAddress("1301 Columbia College Drive Unit 101 Columbia, SC 29203"));

{ id: '1301-Columbia-College-Dr,-Unit-101,-Columbia,-SC-29203',
  formattedAddress: '1301 Columbia College Dr, Unit 101, Columbia, SC 29203',
  zipCode: '29203',
  stateAbbreviation: 'SC',
  stateName: 'South Carolina',
  placeName: 'Columbia',
  addressLine1: '1301 Columbia College Dr',
  addressLine2: 'Unit 101',
  streetNumber: '1301',
  streetSuffix: 'Dr',
  streetName: 'Columbia College' }       

// Handles trailing street directionals  
console.log(addresser.parseAddress("300 BOYLSTON AVE E SEATTLE WA 98102"));
{ id: '300-Boylston-Ave-E,-Seattle,-WA-98102',
  formattedAddress: '300 Boylston Ave E, Seattle, WA 98102',
  zipCode: '98102',
  stateAbbreviation: 'WA',
  stateName: 'Washington',
  placeName: 'Seattle',
  addressLine1: '300 Boylston Ave E',
  streetDirection: 'E',
  streetNumber: '300',
  streetSuffix: 'Ave',
  streetName: 'Boylston' }

// Handles post office boxes 
console.log(addresser.parseAddress("PO BOX 333 SEATTLE WA 98102"));
{ id: 'PO-BOX-333,-Seattle,-WA-98102',
  formattedAddress: 'PO BOX 333, Seattle, WA 98102',
  zipCode: '98102',
  stateAbbreviation: 'WA',
  stateName: 'Washington',
  placeName: 'Seattle',
  addressLine1: 'PO BOX 333' }

// Return a random valid city 
console.log(addresser.randomCity());
{ city: 'Irwin',
  state: 'ID' }

// Return an object containing all cities
console.log(addresser.cities());
{ 
  ...
  WI:
    [ 
      'Black River Falls',
      'Heafford Junction',
      'Washington Island',
      ...
    ],
  WY:
    [ 
      'Yellowstone National Park',
      'Saint Stephens',
      'Little America',
      ...
    ]
} 

NOTE: Currently addresser supports only US & Canada addresses.

Functions

parseAddress

parseAddress will accept an address string and convert it into structured address data. Addresser is designed to be flexible and forgiving in terms of the formatting of the address string but it does assume a general order of street data, city data and state data from left to right. parseAddress will normalize state names and abbreviations and can recognize state data regardless of case or format.

parseAddress will try to validate that the city provided is valid for the given state. This allows for more intelligent parsing logic when propert delimiters are not used. parseAddress also normalizes street types to standard abberviations ie. Drive to Dr, Street to St, etc.

parseAddress creates a unique id for all addresses based on the parsed values. Currently there is no easy, universal ID available for property addresses and this package should help bridge that gap for developers who need to cross reference property data across multiple data sources. An id is generated only if all the address components are present including street address, city, state and zipcode.

getRandomCity

The getRandomCity function can be used to generate a random valid city. This can be helpful when testing.

cities

The cities function returns a JSON object that contains a list of all known cities and states. The structure is as follows:

{ 
  ...
  WI:
    [ 
      'Black River Falls',
      'Heafford Junction',
      'Washington Island',
      ...
    ],
  WY:
    [ 
      'Yellowstone National Park',
      'Saint Stephens',
      'Little America',
      ...
    ]
}

Tests

npm test

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.