weighable
v0.2.0
Published
Helps you with math for weights and stuff.
Downloads
49
Readme
Weighable (JS)
A library for dealing with weights in Javascript.
Installation
npm install --save weighable
OR
yarn add weighable
Usage
Using the Weight class is as simple as:
import { Weight, GRAM, OUNCE } from 'weighable';
let weight = new Weight(1, GRAM);
weight = weight.plus(new Weight(1, OUNCE));
weight = weight.round(4);
It gets even cleaner when you use the helper methods:
import { grams, ounces } from 'weighable';
let weight = grams(1);
weight = weight.plus(ounces(1));
weight = weight.round(4);
Testing
yarn install
yarn jest