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

TylerVigario/Weight.js

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors