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

@alexbruf/usaddress-rs-wasm

v0.1.5

Published

A wasm wrapper for the usaddress crate

Downloads

6

Readme

usaddress-rs-wasm

A WebAssembly wrapper for the us-addrs Rust package, providing fast and accurate parsing of unstructured United States address strings into address components.

Overview

usaddress-rs-wasm brings the power of the us-addrs Rust crate to the web, allowing you to parse US addresses directly in the browser or in Node.js applications. This project wraps the core functionality of us-addrs in a WebAssembly module, making it easy to integrate into JavaScript and TypeScript projects.

Features

  • Parse unstructured US address strings into structured components
  • High-performance address parsing using Rust and WebAssembly
  • Easy integration with web and Node.js applications
  • Compatible with both synchronous and asynchronous usage patterns

Installation

npm install usaddress-rs-wasm

Usage

const { parse } = require('usaddress-rs-wasm');

const address = "123 Main St, Anytown, CA 12345";
const result = parse(address);

console.log(result);

API

parse(address: string): ParseResult

Parses the given address string and returns a ParseResult object.

type ParseResult = 
  | { data: Array<[string, string]> }
  | { error: string };
  • If parsing is successful, the data property will contain an array of tuples, where each tuple represents a parsed component of the address. The first element of the tuple is the component value, and the second element is the component type.
  • If an error occurs during parsing, the error property will contain an error message.

Example

const { parse } = require('usaddress-rs-wasm');

const address = "33 Nassau Avenue, Brooklyn, NY";
const result = parse(address);

if ('data' in result) {
  console.log("Parsed address components:");
  for (const [value, type] of result.data) {
    console.log(`${type}: ${value}`);
  }
} else {
  console.error("Error parsing address:", result.error);
}

Output:

Parsed address components:
AddressNumber: 33
StreetName: Nassau
StreetNamePostType: Avenue
PlaceName: Brooklyn
StateName: NY

Building from Source

To build the WebAssembly module from source, you'll need to have Rust and wasm-pack installed. Then, follow these steps:

  1. Clone the repository:

    git clone https://github.com/username/usaddress-rs-wasm.git
    cd usaddress-rs-wasm
  2. Build the WebAssembly module:

    wasm-pack build --target web
  3. The built files will be in the pkg directory, ready for use or distribution.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • This project is based on the us-addrs Rust crate, which is itself inspired by the usaddress Python library.
  • Thanks to the datamade team for their work on the original usaddress library.