1.0.0 • Published 4 years ago
beer-color v1.0.0
beer-color
Simple library to convert between beer/malt color units and to hex.
- Convert between SRM, EBC and Lovibond
- Hex conversion is only a rough approximation and not an accurate prediction of actual beer color as this is influenced by a wide range of factors such as lighting, glass size, yeast action, additions, etc.
Usage
Install the module with:
npm install beer-colorimport { ebcToHex, lovibondToHex, srmToHex } from 'beer-color';
const hex = srmToHex(3.6);
// '#efec2e'
const hex = ebcToHex(23.6);
// '#c07238'
const hex = lovibondToHex(0.5);
// '#fafad2'import { convertColorUnits } from 'beer-color';
const ebc = convertColorUnits(12, 'srm', 'ebc');
// 23.64
const srm = convertColorUnits(12, 'ebc', 'srm');
// 6.096
const lovibond = convertColorUnits(12, 'ebc', 'lovibond');
// 5.06Documentation
srmToHex(value)
valuenumberSRM value to convert
returns approximate hex color equivalent
ebcToHex(value)
valuenumberEBC value to convert
returns approximate hex color equivalent
lovibondToHex(value)
valuenumberlovibond value to convert
returns approximate hex color equivalent
convertColorUnits(value, sourceUnit, targetUnit)
valuenumbervalue to convertsourceUnit'srm' | 'ebc' | 'lovibond'unit of value parametertargetUnit'srm' | 'ebc' | 'lovibond'unit to convert to
returns converted value for the specified unit
Testing
To run tests:
npm install
npm run test