0

Is there are reputable and comprehensive unit conversion Javascript library? I do not want any libraries that makes AJAX calls to WolframAlpha or Google but something that does the calculation locally.

pathikrit
  • 32,469
  • 37
  • 142
  • 221

2 Answers2

5

The math.js library comes with support for units. The library does not yet support derived units but that is on the planning.

http://mathjs.org/

Example usage:

math.evaluate('2 inch in cm');
math.evaluate('0.5kg + 33g');
math.evaluate('cos(45 deg)');
Jos de Jong
  • 6,602
  • 3
  • 38
  • 58
2

The library "measure" converts between unit types (volume, mass, etc.) and supports multiple unit systems (US, Imperial, Metric)

// volume
measure('1 teaspoon').teaspoons() // 1
measure('1 1/2 tsp.').teaspoons() // 1.5
measure('2 cups and 1 pint').quarts() // 1

// mass
measure('1 pound').ounces() // 16
measure('1 1/2 oz.').ounces() // 1.5

// operations
measure('1 teaspoon').add('1 teaspoon').teaspoons();
measure('6 1/2 teaspoon').divide(2).teaspoons(); // 3.25

https://github.com/dubbs/measure

strictlyk3v
  • 562
  • 5
  • 7