measure is a library for converting between units and unit systems.
It was created out of the need to adjust recipe amounts based on servings on the client-side, while also providing various output types.
There are some inconsistencies between US and Imperial systems. One example would be, a UK "pint" is 568ml, while a US "pint" is 473ml. There are many more. Because of this reason, it is important to state the unit system your are starting with when developing a recipe, unless you are using metric.
To use US customary units (default):
measure('1 teaspoon').milliliters() // 4.93
measure('1 teaspoon', 'US').milliliters() // 4.93
To use the Imperial units:
measure('1 teaspoon', 'Imperial').milliliters() // 4.74
// US and Imperial
// long inputs
measure('1 teaspoon').teaspoons() // 1
measure('1 tablespoon').teaspoons() // 3
// abbrev. inputs
measure('1 1/2 tsp.').teaspoons() // 1.5
measure('1 tbsp.').teaspoons() // 3
// multiple inputs
measure('2 cups and 1 pint').quarts() // 1
// Metric
// long inputs
measure('1 milliliter').milliliters() // 1
measure('1 liter').milliliters() // 1000
// abbrev. inputs
measure('1.5 ml').milliliters() // 1.5
measure('1 l').milliliters() // 1000
// multiple inputs
measure('1 liter and 1 centiliter').milliliters() // 1010
// US and Imperial
// long inputs
measure('1 ounce').ounces() // 1
measure('1 pound').ounces() // 16
// abbrev. inputs
measure('1 1/2 oz.').ounces() // 1.5
measure('1 lbs.').pounds() // 1
// multiple inputs
measure('7 pounds 8 ounces').ounces() // 120
// Metric
// long inputs
measure('1 gram').grams() // 1
measure('1 kilogram').kilograms() // 1
// abbrev. inputs
measure('1 g.').grams() // 1
measure('1 kg.').kilograms() // 1
// multiple inputs
measure('3 kilograms and 2 grams').kilograms() // 3.002
measure('1 teaspoon').add('1 teaspoon').teaspoons(); // 2
measure('3 1/4 teaspoon').subtract('2 3/4 teaspoon').teaspoons(); // .5
measure('1 1/2 teaspoon').multiply(3).teaspoons(); // 4.5
measure('6 1/2 teaspoon').divide(2).teaspoons(); // 3.25
NPM is used for build and tests, JSHint to enforce style.
npm install
$(npm bin)/jasmine
Build is executed using pre-commit hooks
The great moment.js