JavaScript and WebAssembly bindings for qtty, the Siderust physical quantities and unit conversion library.
This repository is the publishable JS workspace. It contains the npm packages,
the thin Rust transport layers for Node and Web, and the vendored qtty
submodule that provides the canonical conversion registry and unit model.
| Package | Target | Status | Notes |
|---|---|---|---|
@siderust/qtty |
Node.js | 0.1.0 |
Native addon built with napi-rs; includes @siderust/qtty/units factories. |
@siderust/qtty-web |
Browsers / bundlers | 0.1.0 |
WebAssembly build with wasm-bindgen; requires await init() before use. |
The Rust crates under qtty-node/ and qtty-web/ are transport layers only.
All unit metadata and conversion semantics come from the qtty
submodule through qtty-ffi.
qtty-js/
├── qtty/ Vendored Rust workspace (canonical units, FFI, docs)
├── qtty-node/ Node package: @siderust/qtty
├── qtty-web/ Browser package: @siderust/qtty-web
└── scripts/ CI helpers for the Node package
- A Node package with
Quantity,DerivedQuantity, conversion helpers, compatibility checks, JSON-friendly serialization helpers, and a typedUnitmap. - Node-side unit factories under
@siderust/qtty/unitsfor arithmetic-style construction such asKilometers(3.2)orDegrees(180). - A browser/WASM package exposing the same core quantity model with explicit
asynchronous initialization via
init(). - TypeScript declarations for both packages matching the current runtime surface.
- Node examples, tests, and CI for format, lint, build, test, and coverage.
npm install @siderust/qttyconst { Quantity, convert, Unit } = require('@siderust/qtty');
const distance = new Quantity(1500, Unit.Meter);
console.log(distance.to(Unit.Kilometer).value); // 1.5
console.log(convert(2, Unit.Hour, Unit.Minute)); // 120npm install @siderust/qtty-webimport { init, Quantity, Unit } from '@siderust/qtty-web';
await init();
const angle = new Quantity(180, Unit.Degree);
console.log(angle.to(Unit.Radian).value);Clone the repository with submodules so the vendored Rust workspace is present:
git clone --recurse-submodules git@github.com:Siderust/qtty-js.git
cd qtty-jsIf you already cloned without submodules:
git submodule update --init --recursivecd qtty-node
npm ci
npm run build:debug
npm testThe repository also exposes CI helpers:
./scripts/ci.sh allqtty-web uses wasm-pack:
cd qtty-web
wasm-pack build --target web --out-dir pkg --release --scope siderustThe npm packages in this repository start at 0.1.0, while the Rust transport
crate inside qtty-node still tracks the native layer
version (0.4.0). That is intentional: the JavaScript public release line and
the internal Rust crate line are versioned independently.
qtty-node/README.mdfor the Node package API and examples.qtty/README.mdfor the vendored Rust workspace.qtty/CHANGELOG.mdfor backend/library changes that feed these bindings.
AGPL-3.0. See LICENSE.