Skip to content

baspeeters/measurement-toolkit

Repository files navigation

Measurement Toolkit

Perform math operations and conversions on object-oriented weights & measurements.

GitHub Actions CI codecov Gitter npm version

Basic Usage

Conversion

import {Gram} from "measurement-toolkit";

const grams = new Gram(245);
const ounces = grams.to.Ounce();

> Ounce {
>   value: 8.6421206776472
> }

Math operations

Example

import {Kilogram, TroyOunce} from "measurement-toolkit";

const kgs = new Kilogram(5);
const toz = new TroyOunce(3);

kgs.subtract(toz);

> Kilogram {
>   value: 4.9066895696
> }

API

Unit support

Measure System Units
Mass SI Yoctogram, Zeptogram, Attogram, Femtogram, Picogram, Nanogram, Microgram, Milligram, Centigram, Decigram, Gram, Decagram, Hectogram, Kilogram, Megagram, Gigagram, Teragram, Petagram, Exagram, Zettagram, Yottagram
US Avoirdupois Grain, Dram, Ounce, Quarter, Hundredweight, Pound, AvoirdupoisTon
Troy TroyOunce, TroyPound
Length SI Yoctometer, Zeptometer, Attometer, Femtometer, Picometer, Nanometer, Micrometer, Millimeter, Centimeter, Decimeter, Meter, Decameter, Hectometer, Kilometer, Megameter, Gigameter, Terameter, Petameter, Exameter, Zettameter, Yottameter
US Yard, Inch, Foot, Mile
Time SI Yoctosecond, Zeptosecond, Attosecond, Femtosecond, Picosecond, Nanosecond, Microsecond, Millisecond, Centisecond, Decisecond, Second, Decasecond, Hectosecond, Kilosecond, Megasecond, Gigasecond, Terasecond, Petasecond, Exasecond, Zettasecond, Yottasecond
Other Minute, Hour, Day

Installation

npm i measurement-toolkit

API Documentation

npm run build:docs

Testing

Run tests

npm test

Run Linter

npm run lint

Coverage

Run tests with coverage

npm run test:coverage

Coverage graph

Code Coverage

About

Object Oriented Unit Converter built in TypeScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published