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

@zerodep/address_parse

v0.0.11

Published

An address parser for American and Canadian addresses that breaks down the provided address into its component parts

Downloads

11

Readme

@zerodep/address_parse

minified size minified+gzipped size tree shaking language types

coverage last commit vulnerabilities

An address parser for American and Canadian addresses that breaks down the provided address into its component parts.

WARNING: THIS IS BETA SOFTWARE

The beta version focuses on accuracy over performance.

tl;dr

A short explanation / quick reference:

import { addressParse } from '@zerodep/address_parse';

const address = addressParse(
  '1600 Pennsylvania Avenue North West Office #100 Washington DC 20500'
);
// {
//   secondaryType: 'Ofc',
//   secondaryNumber: '100',
//   buildingNumber: '1600',
//   streetNamePre: 'PENNSYLVANIA',
//   streetType: 'AVE',
//   directionalPost: 'NW',
//   city: 'WASHINGTON',
//   state: 'DC',
//   zip: '20500',
//   country: 'US',
// }

const poBox = addressParse('Post office Box 3094 Collierville 38027');
// {
//   poBox: 'PO BOX 3094',
//   city: 'COLLIERVILLE',
//   state: 'TN',
//   zip: '38027',
//   country: 'US',
// }

Table of Contents

Install

npm install @zerodep/address_parse

Of course, you may use yarn, pnpm, or the package manager of your choice. Only npm examples are shown for brevity.

This package may also be found on both jsDelivr and unpkg in UMD, ESM and CJS formats.

How to Use

This package exports the following:

  • Functions
    • addressParse - a function that parses a string into its determinable address components
  • Interface
    • IAddress - a typescript interface of the components of an address
  • Error types
    • ZeroDepError - thrown if the address cannot be parsed completely, is an instance of the base Error object

Signature

Typescript declarations:

interface IAddress {
  attn?: string;
  careOf?: string;
  pmb?: string;
  msc?: string;
  poBox?: string;
  rural?: string;
  highway?: string;
  military?: string;
  generalDelivery?: string;
  secondaryType?: string;
  secondaryNumber?: string;
  buildingNumber?: string;
  directionalPre?: string;
  streetNamePre?: string;
  streetType?: string;
  streetNamePost?: string;
  directionalPost?: string;
  city?: string;
  state?: string;
  zip?: string;
  zipExt?: string;
  country?: string;
}

interface IAddressOptions {
  city?: string;
  state?: string;
  country?: string;
  zip?: string;
}

declare const addressParse: (
  line: string,
  options?: IAddressOptions
) => IAddress;

Advantages of @zerodep Packages

We help make source code more readable, more secure, faster to craft, less likely to have hidden defects, and easier to maintain.

  • Zero npm dependencies - completely eliminates all risk of supply-chain attacks, decreases node_modules folder size
  • Fully typed - typescript definitions are provided for every package for a better developer experience
  • Semantically named - package and method names are easy to grok, remember, use, and read
  • Documented - actually useful documentation with examples and helpful tips
  • Intelligently Packaged - multiple npm packages of different sizes available allowing a menu or a-la-carte composition of capabilities
  • 100% Tested - all methods and packages are fully unit tested
  • ESM & CJS - has both ecmascript modules and common javascript exports, both are fully tree-shakable
  • CDN Available - available on fast content delivery networks in UMD, CJS and ESM formats
  • FP Inspired - gently opinionated to encourage functional programming style for cleaner and more maintainable software
  • Predictably Versioned - semantically versioned for peace-of-mind upgrading, this includes changelogs
  • MIT Licensed - permissively licensed for maximum usability

Support

All @zerodep packages are built for the ES2020 specification. Should you need to support older environments you will need to add appropriate polyfills. All packages are tested on the following platforms/browsers:

Browsers

  • Chrome - last 2 major versions
  • Firefox - last 2 major versions
  • Safari - last 2 major versions
  • Edge - last 2 major versions
  • Android - last 2 major versions
  • iOS - last 2 major versions

Node

  • v18.x - Hydrogen LTS
  • v16.x - Gallium LTS

It is likely the package will work on other technologies and version, however development and testing effort is only spent on the above.

Semver

All @zerodep packages, including this one, adhere to Semantic Versioning practices:

  • major versions: correlates with breaking changes to one or more method signatures
  • minor versions: includes addition of new functionality or backwards-compatible software improvements
  • patch versions: are reserved for copy changes, documentation enhancements and bug fixes

The above said, a security best practice is to pin your software packages to specific versions and only upgrade to more recent releases after careful inspection of any CHANGELOG, release notes and all software changes.

Resources

License

MIT