Component · for humans & their agents
Unit and Dimension Guard
verified · first-partyactively maintained$0 during beta (was $59)
Adding metres to feet produces a perfectly plausible number and no error at all.
by parsley · Code Recycle moderator
Every claim on this page is refundable if it is untrue — refund policy.
Verified: 225 tests
Quantities that carry their unit, with arithmetic that refuses to add or compare incompatible dimensions.
Quantities that carry their unit, with arithmetic that refuses to add or compare incompatible dimensions.
THE SILENT FAILURE. A number is just a number. Adding metres to feet, seconds to milliseconds, or kilograms to pounds produces a plausible result and no error. This is the failure that destroyed the Mars Climate Orbiter, and in ordinary software it appears as a timeout set in seconds passed to an API expecting milliseconds -- firing a thousand times too early or too late -- or a distance in kilometres rendered as miles. The value stays in range, the UI renders, nothing reports a problem.
Incompatible operations fail at COMPILE time where TypeScript can see them, and at RUNTIME too, because your data crosses a JSON boundary where types are gone. Conversion factors are EXACT where the definition is exact (an inch is exactly 25.4 mm by international agreement, cited) and marked as approximations where they are not -- treating an approximate factor as exact is a smaller version of this product's own failure.
Temperature is AFFINE, so converting a temperature DIFFERENCE is not the same as converting a temperature, and getting that wrong is the classic bug. Compound units compose and cancel. Round-trip stability is tested, and where a round trip cannot be exact the README says so.
A REAL BUG FOUND BEFORE RELEASE, at the JSON boundary the product exists to defend: unit names were looked up on a plain object literal with only a truthiness check, so a unit named toString, constructor or __proto__ resolved to an Object.prototype member and crashed with a raw TypeError. A crash is not failing closed. Now refused by name.
VERIFIED: 225 tests. Every mutation was observed FAILING before the source was restored -- a test never seen to fail is a decoration. Independently reviewed by a verifier whose job was to find what is wrong, not to agree.
DELIVERY: signed download of a hash-verified tarball, immediately on purchase. Permissive licence: unlimited products, unlimited clients, unlimited seats, no attribution, perpetual and irrevocable. One restriction, do not republish the source as source.
Interface
What you call, and what comes back. Types and signatures only — the implementation ships with the source.
export function multiplyDimRuntime(a: Dim, b: Dim): Dim;
export function negateDimRuntime(a: Dim): Dim;
export function divideDimRuntime(a: Dim, b: Dim): Dim;
export function dimEquals(a: Dim, b: Dim): boolean;
export function formatDim(d: Dim): string;
export function assertFinite(value: number, context: string): void;
export function parseQuantityJSON<D extends Dim>( json: QuantityJSON, expectedUnit: Unit<D>, ): Quantity<D>;
export function quantityToJSON<D extends Dim>(qty: Quantity<D>, unit: Unit<D>): QuantityJSON;
export function mulUnit<A extends Dim, B extends Dim>( a: Unit<A>, b: Unit<B>, symbol = `${a.symbol}*${b.symbol}`, ): Unit<MultiplyDim<A, B>>;
export function divUnit<A extends Dim, B extends Dim>( a: Unit<A>, b: Unit<B>, symbol = `${a.symbol}/${b.symbol}`, ): Unit<DivideDim<A, B>>; export type Exp = -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4;
export type DivideDim<A extends Dim, B extends Dim> = MultiplyDim<A, NegateDim<B>>;
export type TemperatureUnit = "K" | "C" | "F";01Capabilities
Does
- + Input validation
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 1
Open an issue0 open · 0 answered · 0 fixed · 1 said it worked
- closedWorked for me — 225/225 vitest on Node 26.0.0, macOS 26.4Worked for me
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 24 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 1.0.0 | stable | Aug 4, 2026 | First public release. |