UnitOf 1.0.0
dotnet add package UnitOf --version 1.0.0
NuGet\Install-Package UnitOf -Version 1.0.0
<PackageReference Include="UnitOf" Version="1.0.0" />
paket add UnitOf --version 1.0.0
#r "nuget: UnitOf, 1.0.0"
// Install UnitOf as a Cake Addin #addin nuget:?package=UnitOf&version=1.0.0 // Install UnitOf as a Cake Tool #tool nuget:?package=UnitOf&version=1.0.0
A measurement and data type conversion library for Java
, JavaScript
and C#
.
- 20 complete units of measure.
- Parse any programming data type or convert fractions without any errors.
- Ability to create your own custom UnitOf measurements.
- Small (entire suite as little as 64kb), fast, and easy to use with super simple syntax.
Table of Contents
Examples
- https://digidemic.github.io/UnitOf/ provides full documentation of all measurements and units, live examples, FAQ, and much more.
- Cloning the repo and navigating to
/UnitOf-Examples/
provides in-depth runnable demo projects and examples for all languages of UnitOf. <br><br>
Java
&C#
(NOTE: Written in Java but C# is the exact same only Pascal Cased methods)
/* For Java, same for C# but Pascal Cased methods. C# also uses Dictionary instead of HashMap for UnitOf.Anything parameter */
//One Liner
double a = new UnitOf.Mass().fromPounds(5).toKilograms(); //2.26796 returned as 5 pounds is 2.26796 kilograms
//Set Then Convert
UnitOf.Length feet = new UnitOf.Length().fromFeet(5.5); //Instantiate UnitOf.Length and set "feet" as 5.5
double b = feet.toInches(); //66 returned as 5.5 feet is 66 inches
double c = feet.toMeters(); //1.6764 returned as 5.5 feet is 1.6764 meters
//Convert Data Type and Fractions
double d = new UnitOf.DataType("12.5").toDouble(); //12.5 of type double returned. 0.0 would be returned if conversion failed
int e = new UnitOf.DataType("Not A Number").toInt(10); //10 of type int returned since conversion fails
String f = new UnitOf.DataType(0.5).toFraction(); //"1/2" of type String returned. Empty string would be returned if failed
//Create Your Own Custom Measurement
UnitOf.Anything x = new UnitOf.Anything("FEET", new HashMap<Object, Double>() {{ put("METERS", 0.3048); put("INCHES", 12.0); }});
double g = x.convertNow(36, "INCHES", "FEET"); //3 returned as 36 inches is 3 feet
double h = x.convertNow(3, "FEET", "METERS"); //0.9144 returned as 3 feet is 0.9144 meters
<br>
JavaScript
/* For JavasScript */
//One Liner
var a = UnitOf.Mass.fromPounds(5).toKilograms; //2.26796 returned as 5 pounds is 2.26796 kilograms
//Set Then Convert
var feet = UnitOf.Length.fromFeet(5.5); //Instantiate UnitOf.Length and set "feet" as 5.5
var b = feet.toInches; //66 returned as 5.5 feet is 66 inches
var c = feet.toMeters; //1.6764 returned as 5.5 feet is 1.6764 meters
//Convert Data Type and Fractions
var d = UnitOf.DataType("12.5").toFloat(); //12.5 of type Float returned. 0 would be returned if conversion failed
var e = UnitOf.DataType("Not A Number").toInt(10); //10 of type Int returned since conversion fails
var f = UnitOf.DataType(0.5).toFraction(); //"1/2" of type string returned. Empty string would be returned if failed
//Create your own custom measurement
var x = UnitOf.Anything("FEET", 1, true, {METERS:0.3048, INCHES:12}); //Custom measurement w/ 3 units
var g = x.convertNow(36, "INCHES", "FEET"); //3 returned as 36 inches is 3 feet
var h = x.convertNow("3", "FEET", "METERS"); //0.9144 returned as 3 feet is 0.9144 meters
Installation
Clone the UnitOf repo to your local machine using
https://github.com/digidemic/UnitOf
<br>Only the single compiled UnitOf file of its language needs to be imported and referenced.
Java
- Import
/UnitOf.jar
from the cloned repo into your project.- In your classes using UnitOf, add
import com.digidemic.unitof.UnitOf;
to your list of imports.
Import using Netbeans IDE 8.2
- From within Netbeans, Right-click the project >
Properties
>Libraries
category >Compile
tab >Add JAR/Folder
> Navigate and selectUnitOf.jar
from the cloned repo.
- From within Netbeans, Right-click the project >
Import using Android Studio 3.1
- From within Android Studio with the project open,
Project
tab open > Switch folder structure toProject
> Expand the project and find thelibs
directory (if not there create it in the same directory assrc
andres
) > Add theUnitOf.jar
from the cloned repo tolibs
directory > Right-click the newly addedUnitOf.jar
node in thelibs
directory > clickAdd As Library...
> ClickOK
in theCreate Library
dialog.
- From within Android Studio with the project open,
JavaScript
By Node
npm install unitof
By script tag
- Import
/UnitOf.min.js
from the cloned repo into your project- Add the following script tag (with the full path of
/UnitOf.min.js
) to the index html file:
<script src="/UnitOf.min.js"></script>
C#
- Import
/UnitOf.dll
from the cloned repo into your project.- In your index class or any class needed, add
using UnitOf;
to your list of imports.
Import using Visual Studio 2012
- From within Visual Studio with the project open,
Solution Explorer
tab open > Expand the project directories navigating toReferences
> Right-clickReferences
> ClickAdd Reference...
> ClickBrowser...
> Navigate and selectUnitOf.dll
from the cloned repo > Make sureUnitOf.dll
is checked and clickOK
.
- From within Visual Studio with the project open,
Versioning
- A derivative of SemVer is used for versioning.
- Given a version number MAJOR . MINOR . PATCH . LANGUAGE_SPECIFIC_UPDATE COMMENT
- MAJOR version - Incompatible API changes.
- MINOR version - Functionality added in a backwards-compatible manner.
- PATCH version - Backwards-compatible bug fixes.
- LANGUAGE_SPECIFIC_UPDATE version - Specific functionality added or bug fixes only affecting a specific language (
Java
,JavaScript
, orC#
). - COMMENT version (optional) - Presented as an alphabetic letter starting with "a", includes anything that does not affect size, performance, features, or fixes to the compiled solution. Adding or editing comments in code would be an example of this version.
- Version number may vary slightly between
Java
,JavaScript
, andC#
instances of UnitOf.- MAJOR.MINOR.PATH will always be consistent across all languages.
- As an example they can be as follows:
Java
- UnitOf_v1.2.3.0JavaScript
- UnitOf_v1.2.3.0bC#
- UnitOf_v1.2.3.2a
Author
UnitOf website, logo, Palindrome Conversion Algorithm, and all source code & example projects for Java, JavaScript & C# created by Adam Steinberg of DIGIDEMIC, LLC
License
- UnitOf licensed under Apache License 2.0
- Copyright 2018 © <a href="http://digidemicsoftware.com/">DIGIDEMIC, LLC</a>.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 23,662 | 10/28/2018 |
1.0.0.0 Release added to NuGet