This package, `parse-address`, currently at version 1.1.2, provides a JavaScript port of the Perl Geo::StreetAddress::US module for parsing US street addresses. It is designed to be highly forgiving and robust, using a regex-based approach to extract components like street number, prefix, street name, type, city, state, and ZIP code from various user-provided address strings. Key features include handling directional prefixes and suffixes, fractional building numbers, building units, grid-based addresses, and both 5 and 9-digit ZIP codes, along with all official USPS abbreviations for street types and state names. The package's release cadence appears to be infrequent, with the last significant version jump (1.0.0) occurring after a long period. Its core differentiator is its direct port from a proven Perl library, emphasizing fault tolerance in parsing diverse address formats prevalent in the United States.
npm install parse-addressVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the parser and use `parseLocation` to extract components from US street addresses, including common and informal formats.
Use `const parser = require('parse-address');` for Node.js environments. For browser usage, include `parse-address.min.js` directly via a script tag.Consider creating a `parse-address.d.ts` file in your project with `declare module 'parse-address' { ... }` or check for `@types/parse-address` on npm.Review parsing results for a representative set of addresses after upgrading to v1.x to ensure consistency with expected output.
Ensure you are using `const parser = require('parse-address');` in your JavaScript/TypeScript files, especially in Node.js or when configuring bundlers to correctly handle CommonJS modules. If using `import`, try `import * as parser from 'parse-address';` (though this might still have issues depending on bundler config).Use the CommonJS `require` syntax: `const parser = require('parse-address');` and then access `parser.parseLocation(...)`.No dependency data recorded yet.