Skip to content

baspeeters/measurement-toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c874c83 · Oct 7, 2023

History

92 Commits
Nov 4, 2022
May 30, 2020
Nov 3, 2022
Nov 3, 2022
Dec 4, 2019
Aug 31, 2022
Nov 3, 2022
Jan 12, 2020
Jan 26, 2020
Jan 22, 2020
Aug 27, 2022
Oct 7, 2023
Oct 7, 2023
Nov 3, 2022
Nov 3, 2022
Nov 3, 2022

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