@benehmke/measurement
v0.1.0
Published
Javascript Classes for storing, and converting units of measurement
Readme
Measurement
Javascript Classes for storing, and converting units of measurement
Installation
npm install @benehmke/measurementimport {Length} from 'measurement';
const boxFront = new Length('9 ft');
const boxSide = new Length(4, 'ft');
const boxHeight = new Length({value: 4, unit: 'in'})Usage
to(units)
const boxFront = new Length('9 ft');
console.log(boxFront.to('in'));
// >> 108 invalueOf
const distanceA = new Length('9 ft');
const distanceB = new Length('5 m');
console.log(distanceA < distanceB);
// >> trueUnits
Length
|Name|Label|
| --- | --- |
|Millimeter|mm|
|Centimeter|cm|
|Meter|m|
|Kilometer|km|
|Inch|in|
|Foot|ft|
|Yard|yd|
|Mile|mi|
Area
|Name|Label|
| --- | --- |
|Square Meter|sqm|
|Square Foot|sqft|
|Tsubo|tsubo|
Development
TODO
- [ ] Add/Subtract Method
- [ ] Length.toArea
- [ ] Custom Unit rename (ex ft2 for sqft)
- [ ] Volume
- [ ] Weight
Build
npm run buildTest
npm run testRelease
npm publish