Class: Conversion

Conversion

Conversions between units

Available conversions:

Alcohol:

↓ from \ → to DENSITY ABV VV WV WW CW
DENSITY
ABV
VV
WV
WW
CW

Syrup:

↓ from \ → to DENSITY BRIX VV WV WW CW
DENSITY
BRIX
VV
WV
WW
CW

Members

correction

Properties:
Name Type Description
correction number

multiplier for complex compositions to avoid rounding errors while mixing

Source:

Methods

Binary search method for really complex things

Parameters:
Name Type Attributes Default Description
callback function

callback function, must take 1 number argument

target number

value to get from closure

min number

min value of argument to search

max number

max value of argument

precision number <optional>
0.00001

precision to target

inverse boolean <optional>
false

inverse search (if result is bigger than target, the argument gets smaller)

Source:
Throws:
Returns:
Type
number

(static) convert(ingredient, from, to, value) → {number}

Facade function for converting from anything to anything

Parameters:
Name Type Description
ingredient IngredientType
from MeasureVariant
to MeasureVariant
value number
Source:
Throws:
Returns:
Type
number
Example
// returns 0.61501
Conversion.convert('syrup', Measure.BRIX, Measure.WV, 50)

(static) validate(ingredient, measure, value) → {number}

Facade function for validation

Parameters:
Name Type Description
ingredient IngredientType
measure MeasureVariant
value number
Source:
Throws:
Returns:
Type
number
Example
// returns true
Conversion.validate('syrup', Measure.BRIX, 50)
// returns false
Conversion.validate('syrup', Measure.BRIX, 150)