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 🙏

© 2025 – Pkg Stats / Ryan Hefner

h3o-wasm

v0.7.1-alpha.1

Published

An experimental WASM package from Rust implementation of the H3 geospatial indexing system

Downloads

86

Readme

h3o-wasm

Crates.io Docs.rs CI Status Coverage License

A Rust implementation of the H3 geospatial indexing system, compiled to WebAssembly for use in JavaScript projects.

Design

Experimental: this package compiles some functions from h3o to WASM (see check-list). Performance might be slower than the reference h3-js implementation in browsers, as the reference implementation compiles the C code to asm.js, which is already optimized for the browser. Performance has not been tested in Node.js yet, but it should be faster than the reference. I will add some testing soon. I'm adding the functions one by one, as time permits, but it should be complete soon. See available methods below.

H3 should also be easy to compile to Wasm, using the emscripten toolchain, changing the flags to use the wasm target instead of asm.js.

h3o is a Rust reimplementation of the H3 geospatial indexing system, designed with the following goals:

  • Leverage Rust's strong typing for safer usage.
  • Provide a 100% Rust solution, eliminating C dependencies for painless compilation to WebAssembly and easier link-time optimization.
  • Match or exceed the performance of the reference H3 library.

h3o-wasm exposes h3o functions to Javascript

Available methods and properties

The goal is to provide equivalent functions to all H3 functions

h3o

  • [ ] .UNITS
  • [ ] .h3IndexToSplitLong(h3Index) ⇒ SplitLong
  • [ ] .splitLongToH3Index(lower, upper) ⇒ H3Index
  • [x] .isValidCell(h3Index) ⇒ boolean
  • [x] .isPentagon(h3Index) ⇒ boolean
  • [x] .isResClassIII(h3Index) ⇒ boolean
  • [x] .getBaseCellNumber(h3Index) ⇒ number
  • [ ] .getIcosahedronFaces(h3Index) ⇒ Array.
  • [x] .getResolution(h3Index) ⇒ number
  • [x] .latLngToCell(lat, lng, res) ⇒ H3Index
  • [x] .cellToLatLng(h3Index) ⇒ CoordPair
  • [x] .cellToBoundary(h3Index, [formatAsGeoJson]) ⇒ Array.
  • [x] .cellToParent(h3Index, res) ⇒ H3Index
  • [x] .cellToChildren(h3Index, res) ⇒ Array.
  • [ ] .cellToChildrenSize(h3Index, res) ⇒ number
  • [x] .cellToCenterChild(h3Index, res) ⇒ H3Index
  • [ ] .cellToChildPos(h3Index, parentRes) ⇒ number
  • [ ] .childPosToCell(childPos, h3Index, childRes) ⇒ H3Index
  • [ ] .gridDisk(h3Index, ringSize) ⇒ Array.
  • [ ] .gridDiskDistances(h3Index, ringSize) ⇒ Array.<Array.>
  • [ ] .gridRingUnsafe(h3Index, ringSize) ⇒ Array.
  • [x] .polygonToCells(coordinates, res, [isGeoJson]) ⇒ Array.
  • [ ] .cellsToMultiPolygon(h3Indexes, [formatAsGeoJson]) ⇒ Array.<Array.<Array.>>
  • [ ] .compactCells(h3Set) ⇒ Array.
  • [ ] .uncompactCells(compactedSet, res) ⇒ Array.
  • [ ] .areNeighborCells(origin, destination) ⇒ boolean
  • [ ] .cellsToDirectedEdge(origin, destination) ⇒ H3Index
  • [ ] .getDirectedEdgeOrigin(edgeIndex) ⇒ H3Index
  • [ ] .getDirectedEdgeDestination(edgeIndex) ⇒ H3Index
  • [ ] .isValidDirectedEdge(edgeIndex) ⇒ boolean
  • [ ] .directedEdgeToCells(edgeIndex) ⇒ Array.
  • [ ] .originToDirectedEdges(h3Index) ⇒ Array.
  • [ ] .directedEdgeToBoundary(edgeIndex, [formatAsGeoJson]) ⇒ Array.
  • [ ] .gridDistance(origin, destination) ⇒ number
  • [ ] .gridPathCells(origin, destination) ⇒ Array.
  • [ ] .cellToLocalIj(origin, destination) ⇒ CoordIJ
  • [ ] .localIjToCell(origin, coords) ⇒ H3Index
  • [ ] .greatCircleDistance(latLng1, latLng2, unit) ⇒ number
  • [x] .cellArea(h3Index, unit) ⇒ number
  • [x] .edgeLength(edge, unit) ⇒ number
  • [ ] .getHexagonAreaAvg(res, unit) ⇒ number
  • [ ] .getHexagonEdgeLengthAvg(res, unit) ⇒ number
  • [ ] .cellToVertex(h3Index, vertexNum) ⇒ H3Index
  • [ ] .cellToVertexes(h3Index) ⇒ Array.
  • [ ] .vertexToLatLng(h3Index) ⇒ CoordPair
  • [ ] .isValidVertex(h3Index) ⇒ boolean
  • [ ] .getNumCells(res) ⇒ number
  • [ ] .getRes0Cells() ⇒ Array.
  • [ ] .getPentagons(res) ⇒ Array.
  • [ ] .degsToRads(deg) ⇒ number
  • [ ] .radsToDegs(rad) ⇒ number
  • [ ] .H3Index : string
  • [ ] .H3IndexInput : string | Array.
  • [ ] .CoordIJ
  • [ ] .H3Error
  • [ ] .CoordPair : Array.
  • [ ] .SplitLong : Array.

Installation

The h3o-wasm package is distributed via npm.

npm install h3o-wasm

Building

  • Install the rust toolchain in order to have cargo installed by following this guide.
  • run cargo install wasm-bindgen-cli
  • run wasm-pack build --target web

Usage

import init, * as h3o from "h3o-wasm";

async function run() {
  await init(); // Initialize the WASM module
  const h3Index = h3o.latLngToCell(37.3615593, -122.0553238, 7);
  console.log("H3 Index: ", h3Index);
}

run();

Testing performance (browser)

An example file is available in the root of the repository, to run it you can use a simple http server like http-server:

npm -g install http-server
http-server .

Why this name?

Rust is an iron oxide. A Rust version of H3 is an H3 oxide, in other word $H_3O$ (a.k.a hydronium). Chemically speaking this is wrong ( $H_3O$ is produced by protonation of $H_2O$, not oxidation of $H_3$), but ¯\(ツ)

License

BSD 3-Clause