0.1.0 • Published 2 years ago

typed-si v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

typed-si: Strongly typed physical units

Node.js npm version

Installation via npm i typed-si

typed-si is a typescript library for working with si-based phyisical quantities and measures with strong type safety guarantees.

Basic usage:

import {Quantity, feet, kilo, newtons, atmospheres} from 'typed-si';

const sqft = Quantity.of(50, feet.squared());
const force = Quantity.of(10, kilo(newtons));
console.log(`Atmospheres: ${force.over(sqft).in(atmospheres)}`)

Rational by Default

All quantities in typed-si use rationals by default under the hood, leading to reasonable conversion with minimal loss of precision.

Aliases, Aliases, Aliases

typed-si has a lot of aliases for things to improve readability. They behave identically and are often the same function instance.

// Aliasing of singular and plurals
Quantity.of(1, mile).in(meters);

// Aliasing of unit and quantity division.
Quantity.of(60, miles.per(hour));
Quantity.of(60, miles.div(hour));
Quantity.of(60, miles.over(hour));
0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago