Releases: buge/ts-units
v1.2.2
v1.2.1
v1.2.0
This release is mostly an internal change on how instances of Unit
and Quantity
are created where their methods (e.g. withSymbol
, plus
, toString
) are not redefined for each unit / quantity created but are defined in a prototype of the instances.
For most clients this should be a no-op change but there may be cases (e.g. if enumerating the object’s “own properties”) where their is a minor API change, which is also why we are increasing the minor version number with the release.
This change also includes base dimensions and units for volume and area.
Initial Version
I'm excited to be able to publish the first version of @buge/ts-units!
@buge/ts-units
is a library for type safe physical constants:
const temp: Temperature = celsius(21.3);
Quantities can be converted to other units:
temp.in(fahrenheit).toString(); // '70.34ºF'
And added and subtracted:
const length: Length = feet(6).plus(inches(4));
But the really, really cool thing is that you can also multiply/divide quantities and you will continue to get type safe units back. All the dimensional math happens at compile time so you can catch errors early and have peace of mind that your code is sane:
const speed: Speed = meters(10).per(seconds(2));
You can define new quantities and even new dimensions! See the documentation for more details.
This initial release contains support for all SI base and named derived units as well as a bunch of extra units for lengths and speed. I'll be adding more units (e.g. more imperial units, US volumetric units, etc.) in the coming weeks/months and value contributions.