Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

Latest commit

 

History

History
51 lines (41 loc) · 1.6 KB

README.md

File metadata and controls

51 lines (41 loc) · 1.6 KB

Codacy Badge Build Status Coverage Status FOSSA Status

Weight.js

JavaScript classes to convert imperial mass units as well as output and parse as text.

Documentation

Install

npm install weight.js

Usage

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;

Example

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"
}