JavaScript classes to convert imperial mass units as well as output and parse as text.
npm install weight.js
ES6
import {Ounces, Pounds} from 'weight.js/src/weight';
//or
import Ounces from 'weight.js/src/ounces';
//or
import Pounds from 'weight.js/src/pounds';
CommonJS
var Weight = require('weight.js');
var Ounces = Weight.Ounces;
var Pounds = Weight.Pounds;
//or
var Ounces = require('weight.js').Ounces;
//or
var Pounds = require('weight.js').Pounds;
let ounces = Ounces.parse('5lbs 4 oz');
console.log(ounces.value); // 84
ounces.add(new Ounces(6));
console.log(ounces.value); // 90
if (ounces.isSame(new Ounces(90))) {
console.log(ounces.toString()); // "5 lbs 10 oz"
}