JavaScript API Reference#
The JavaScript build has two layers: the ergonomic wrapper
(bindings/js/wrapper) documented in the JavaScript / WASM guide, and the
raw core it wraps (bindings/js/pkg / pkg-web). This page is the
reference for both.
Wrapper surface#
Top-level exports (import * as m3s from "@nkarasiak/m3s"):
Export |
Description |
|---|---|
|
Initialize the WASM core. |
|
|
|
Geodesic area of a closed |
|
Grid singletons (see JavaScript / WASM). |
|
Classes, for |
The grid, Cell and CellCollection methods are listed in the
JavaScript / WASM guide. The wrapper’s public surface is frozen by
tests/golden/js_wrapper_surface.json.
Raw core functions#
The wrapper calls these generated functions. They are flat, named
<prefix>_<op>, take ``(lat, lon)`` order, and return { id, ring,
precision } (ring is a closed [[lon, lat], ...]). Use them directly only
if you need to bypass the wrapper.
Grid prefixes#
Grid |
Prefix |
Hierarchical |
Singleton |
|---|---|---|---|
Geohash |
|
yes |
|
H3 |
|
yes |
|
S2 |
|
yes |
|
Quadkey |
|
yes |
|
Slippy |
|
yes |
|
C-squares |
|
yes |
|
EA-Quad |
|
yes |
|
rHEALPix |
|
yes |
|
Plus Codes |
|
yes |
|
A5 |
|
yes |
|
GARS |
|
no |
|
Maidenhead |
|
no |
|
MGRS |
|
no |
|
Operations#
// per grid (replace <p> with the prefix above)
<p>_cell_from_point(lat, lon, precision) // -> {id, ring, precision}
<p>_cell_from_id(id) // -> {id, ring, precision}
<p>_cells_in_bbox(minLat, minLon, maxLat, maxLon, precision) // -> [cell, ...]
<p>_neighbors(id) // -> [cell, ...]
<p>_children(id) // hierarchical only
<p>_parent(id) // hierarchical only
// shared
all_precision_bounds() // Map {name -> [min, max, default]}
geodesic_area_km2(ring) // number, km²
a5_cell_area_m2(precision) // number, m² (A5 is equal-area)
The full frozen symbol list lives in tests/golden/binding_symbols.json and
is asserted identical to the Python binding by tests/js/parity.cjs.